From 99778149bd59b02817a66a3a69d89097cd3ea4a6 Mon Sep 17 00:00:00 2001 From: Fangrui Song Date: Mon, 12 Jul 2021 17:44:02 -0700 Subject: [PATCH] [llc] Default MCUseDwarfDirectory to true For Clang, `MCUseDwarfDirectory` is true by default for the majority cases (-fintegrated-as or -gdwarf-5; most targets use -fintegrated-as by default). Defaulting MCUseDwarfDirectory to true can reduce the differences between clang and llc. Reviewed By: #debug-info, dblaikie Differential Revision: https://reviews.llvm.org/D105856 --- test/CodeGen/Generic/dwarf-md5.ll | 10 +++++++--- test/CodeGen/Generic/dwarf-source.ll | 6 +++--- test/DebugInfo/Generic/lto-comp-dir.ll | 4 ++-- test/DebugInfo/NVPTX/dbg-declare-alloca.ll | 2 +- test/DebugInfo/NVPTX/debug-loc-offset.ll | 2 +- test/DebugInfo/X86/dbg-file-name.ll | 2 +- test/DebugInfo/X86/inline-asm-locs.ll | 2 +- tools/llc/llc.cpp | 9 +++++---- 8 files changed, 21 insertions(+), 16 deletions(-) diff --git a/test/CodeGen/Generic/dwarf-md5.ll b/test/CodeGen/Generic/dwarf-md5.ll index 2fc25f3a3ed..e76a70012a8 100644 --- a/test/CodeGen/Generic/dwarf-md5.ll +++ b/test/CodeGen/Generic/dwarf-md5.ll @@ -3,18 +3,22 @@ ; REQUIRES: object-emission ; RUN: %llc_dwarf -dwarf-version 4 -filetype=asm -o - %s | FileCheck %s --check-prefix=ASM-4 +; RUN: %llc_dwarf -dwarf-version 4 -filetype=asm -dwarf-directory=0 < %s | FileCheck %s --check-prefix=ASM-4-GAS ; RUN: %llc_dwarf -dwarf-version 5 -filetype=asm -o - %s | FileCheck %s --check-prefix=ASM-5 ; RUN: %llc_dwarf -dwarf-version 4 -filetype=obj -o %t4.o %s ; RUN: llvm-dwarfdump -debug-line %t4.o | FileCheck %s --check-prefix=OBJ ; RUN: %llc_dwarf -dwarf-version 5 -filetype=obj -o %t5.o %s ; RUN: llvm-dwarfdump -debug-line %t5.o | FileCheck %s --check-prefixes=OBJ,OBJ-5 +; ASM-4-GAS: .file 1 "/scratch{{/|\\\\}}t1.h" +; ASM-4-GAS: .file 2 "/scratch{{/|\\\\}}t2.h" + ; ASM-4-NOT: .file 0 -; ASM-4: .file 1 "/scratch{{.*[/\\]}}t1.h" +; ASM-4: .file 1 "/scratch" "t1.h" ; ASM-4-NOT: md5 -; ASM-4: .file 2 "/scratch{{.*[/\\]}}t2.h" +; ASM-4: .file 2 "/scratch" "t2.h" ; ASM-4-NOT: md5 -; ASM-5: .file 0 "/scratch{{.*[/\\]}}t.c" md5 0x00000000000000000000000000000000 +; ASM-5: .file 0 "/scratch" "t.c" md5 0x00000000000000000000000000000000 ; ASM-5: .file 1 "t1.h" md5 0x11111111111111111111111111111111 ; ASM-5: .file 2 "t2.h" md5 0x22222222222222222222222222222222 diff --git a/test/CodeGen/Generic/dwarf-source.ll b/test/CodeGen/Generic/dwarf-source.ll index 41441110f2f..bd18eec7709 100644 --- a/test/CodeGen/Generic/dwarf-source.ll +++ b/test/CodeGen/Generic/dwarf-source.ll @@ -9,9 +9,9 @@ ; RUN: %llc_dwarf -dwarf-version 5 -filetype=obj -o %t5.o %s ; RUN: llvm-dwarfdump -debug-line %t5.o | FileCheck %s --check-prefixes=OBJ,OBJ-5 -; ASM-4: .file 1 "/test{{.*[/\\]}}t1.h" source "11111111111111111111111111111111" -; ASM-4: .file 2 "/test{{.*[/\\]}}t2.h" source "22222222222222222222222222222222" -; ASM-5: .file 0 "/test{{.*[/\\]}}t.c" source "00000000000000000000000000000000" +; ASM-4: .file 1 "/test" "t1.h" source "11111111111111111111111111111111" +; ASM-4: .file 2 "/test" "t2.h" source "22222222222222222222222222222222" +; ASM-5: .file 0 "/test" "t.c" source "00000000000000000000000000000000" ; ASM-5: .file 1 "t1.h" source "11111111111111111111111111111111" ; ASM-5: .file 2 "t2.h" source "22222222222222222222222222222222" diff --git a/test/DebugInfo/Generic/lto-comp-dir.ll b/test/DebugInfo/Generic/lto-comp-dir.ll index 9e781bd0680..0eff732eec9 100644 --- a/test/DebugInfo/Generic/lto-comp-dir.ll +++ b/test/DebugInfo/Generic/lto-comp-dir.ll @@ -27,8 +27,8 @@ ; interpretations depending on which CU lead to the table - so ensure that ; full paths are always emitted in this case, never comp_dir relative. -; ASM: .file 1 "/tmp/dbginfo/a{{[/\\]+}}a.cpp" -; ASM: .file 2 "/tmp/dbginfo/b{{[/\\]+}}b.cpp" +; ASM: .file 1 "/tmp/dbginfo/a" "a.cpp" +; ASM: .file 2 "/tmp/dbginfo/b" "b.cpp" ; Generated from the following source compiled to bitcode from within their ; respective directories (with debug info) and linked together with llvm-link diff --git a/test/DebugInfo/NVPTX/dbg-declare-alloca.ll b/test/DebugInfo/NVPTX/dbg-declare-alloca.ll index 6bfc3d1e94c..d5bd573c3b8 100644 --- a/test/DebugInfo/NVPTX/dbg-declare-alloca.ll +++ b/test/DebugInfo/NVPTX/dbg-declare-alloca.ll @@ -1,4 +1,4 @@ -; RUN: llc < %s -mtriple=nvptx64-nvidia-cuda | FileCheck %s +; RUN: llc < %s -mtriple=nvptx64-nvidia-cuda -dwarf-directory=0 | FileCheck %s ; CHECK: .target sm_20, debug diff --git a/test/DebugInfo/NVPTX/debug-loc-offset.ll b/test/DebugInfo/NVPTX/debug-loc-offset.ll index c932ea0af46..43cc586fff1 100644 --- a/test/DebugInfo/NVPTX/debug-loc-offset.ll +++ b/test/DebugInfo/NVPTX/debug-loc-offset.ll @@ -1,4 +1,4 @@ -; RUN: llc -mtriple=nvptx64-nvidia-cuda < %s | FileCheck %s +; RUN: llc -mtriple=nvptx64-nvidia-cuda -dwarf-directory=0 < %s | FileCheck %s ; CHECK: .target sm_{{[0-9]+}}, debug diff --git a/test/DebugInfo/X86/dbg-file-name.ll b/test/DebugInfo/X86/dbg-file-name.ll index 633b9c069c5..a26b0f3c1f4 100644 --- a/test/DebugInfo/X86/dbg-file-name.ll +++ b/test/DebugInfo/X86/dbg-file-name.ll @@ -1,4 +1,4 @@ -; RUN: llc -enable-dwarf-directory -mtriple x86_64-apple-darwin10.0.0 < %s | FileCheck %s +; RUN: llc -mtriple x86_64-apple-darwin10.0.0 < %s | FileCheck %s ; Verify that the file name is relative to the directory. ; rdar://problem/8884898 diff --git a/test/DebugInfo/X86/inline-asm-locs.ll b/test/DebugInfo/X86/inline-asm-locs.ll index 75c334b61cc..ef1f89235c5 100644 --- a/test/DebugInfo/X86/inline-asm-locs.ll +++ b/test/DebugInfo/X86/inline-asm-locs.ll @@ -22,7 +22,7 @@ ; CHECK: .file 2 "B.asm" ; CHECK: .loc 1 111 ; CHECK: .loc 2 222 -; CHECK: .file 3 "{{.*[/\\]}}test.c" +; CHECK: .file 3 "{{.*}}" "test.c" ; CHECK: .loc 3 14 0 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128" diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index c319b7dad81..6a1e2bae209 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -126,9 +126,10 @@ static cl::opt DisableSimplifyLibCalls("disable-simplify-libcalls", static cl::opt ShowMCEncoding("show-mc-encoding", cl::Hidden, cl::desc("Show encoding in .s output")); -static cl::opt EnableDwarfDirectory( - "enable-dwarf-directory", cl::Hidden, - cl::desc("Use .file directives with an explicit directory.")); +static cl::opt + DwarfDirectory("dwarf-directory", cl::Hidden, + cl::desc("Use .file directives with an explicit directory"), + cl::init(true)); static cl::opt AsmVerbose("asm-verbose", cl::desc("Add comments to directives."), @@ -473,7 +474,7 @@ static int compileModule(char **argv, LLVMContext &Context) { TargetMachine::parseBinutilsVersion(BinutilsVersion); Options.DisableIntegratedAS = NoIntegratedAssembler; Options.MCOptions.ShowMCEncoding = ShowMCEncoding; - Options.MCOptions.MCUseDwarfDirectory = EnableDwarfDirectory; + Options.MCOptions.MCUseDwarfDirectory = DwarfDirectory; Options.MCOptions.AsmVerbose = AsmVerbose; Options.MCOptions.PreserveAsmComments = PreserveComments; Options.MCOptions.IASSearchPaths = IncludeDirs;