From 84e5760a1637d89c6c90a218abfe6d4d0ce85c97 Mon Sep 17 00:00:00 2001 From: Sourabh Singh Tomar Date: Fri, 7 Feb 2020 10:18:54 +0530 Subject: [PATCH] [DebugInfo]: Reorderd the emission of debug_str section. Summary: This patch reorders the emission of debug_str section, so that string can come after macros. This is necessary for macro forms like DW_MACRO_define_strp, which emits macro as a string in debug_str section. --- llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp | 4 ++-- .../DebugInfo/MIR/X86/dbg-stack-value-range.mir | 8 +++----- llvm/test/DebugInfo/X86/stringpool.ll | 14 ++++++++------ 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp index 447d3fa3e206..3a8252e8b320 100644 --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -1260,8 +1260,6 @@ void DwarfDebug::endModule() { // Finalize the debug info for the module. finalizeModuleInfo(); - emitDebugStr(); - if (useSplitDwarf()) // Emit debug_loc.dwo/debug_loclists.dwo section. emitDebugLocDWO(); @@ -1289,6 +1287,8 @@ void DwarfDebug::endModule() { // Emit info into a debug macinfo section. emitDebugMacinfo(); + emitDebugStr(); + if (useSplitDwarf()) { emitDebugStrDWO(); emitDebugInfoDWO(); diff --git a/llvm/test/DebugInfo/MIR/X86/dbg-stack-value-range.mir b/llvm/test/DebugInfo/MIR/X86/dbg-stack-value-range.mir index a1dae268e326..6664a8127866 100644 --- a/llvm/test/DebugInfo/MIR/X86/dbg-stack-value-range.mir +++ b/llvm/test/DebugInfo/MIR/X86/dbg-stack-value-range.mir @@ -18,9 +18,6 @@ # CHECK-NEXT: .Ltmp6: # CHECK: .Lfunc_end0: # -# CHECK: .Linfo_string7: -# CHECK-NEXT: .asciz "local1" -# # CHECK: .Ldebug_loc2: # CHECK-NEXT: .quad .Ltmp1-.Lfunc_begin0 # CHECK-NEXT: .quad .Ltmp4-.Lfunc_begin0 @@ -34,8 +31,9 @@ # # CHECK: .long .Ldebug_loc2 # DW_AT_location # CHECK-NEXT: .long .Linfo_string7 # DW_AT_name - - +# +# CHECK: .Linfo_string7: +# CHECK-NEXT: .asciz "local1" --- | ; ModuleID = 'dbg-stack-value-range.ll' source_filename = "dbg-stack-value-range.c" diff --git a/llvm/test/DebugInfo/X86/stringpool.ll b/llvm/test/DebugInfo/X86/stringpool.ll index 95c514997de4..219e6728c6ce 100644 --- a/llvm/test/DebugInfo/X86/stringpool.ll +++ b/llvm/test/DebugInfo/X86/stringpool.ll @@ -14,11 +14,6 @@ source_filename = "test/DebugInfo/X86/stringpool.ll" !3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed) !4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.1 (trunk 143009)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5) !5 = !{} -; Verify that "yyyy" ended up in the stringpool. -; LINUX: .section .debug_str,"MS",@progbits,1 -; LINUX: yyyy -; DARWIN: .section __DWARF,__debug_str,regular,debug -; DARWIN: .asciz "yyyy" ## string offset=[[YYYY:[0-9]+]] ; Verify that we refer to 'yyyy' with a relocation. ; LINUX: .long .Linfo_string3 # DW_AT_name @@ -29,9 +24,14 @@ source_filename = "test/DebugInfo/X86/stringpool.ll" ; LINUX-NEXT: .byte 9 # DW_AT_location ; LINUX-NEXT: .byte 3 ; LINUX-NEXT: .quad yyyy +; Verify that "yyyy" ended up in the stringpool. +; LINUX: .section .debug_str,"MS",@progbits,1 +; LINUX: yyyy ; Verify that we refer to 'yyyy' with a direct offset. -; DARWIN: .long [[YYYY]] +; DARWIN: .section __DWARF,__debug_info,regular,debug +; DARWIN: DW_TAG_variable +; DARWIN: .long [[YYYY:[0-9]+]] ; DARWIN-NEXT: .long {{[0-9]+}} ## DW_AT_type ; DARWIN-NEXT: ## DW_AT_external ; DARWIN-NEXT: .byte 1 ## DW_AT_decl_file @@ -39,5 +39,7 @@ source_filename = "test/DebugInfo/X86/stringpool.ll" ; DARWIN-NEXT: .byte 9 ## DW_AT_location ; DARWIN-NEXT: .byte 3 ; DARWIN-NEXT: .quad _yyyy +; DARWIN: .section __DWARF,__debug_str,regular,debug +; DARWIN: .asciz "yyyy" ## string offset=[[YYYY]] !6 = !{!0} !7 = !{i32 1, !"Debug Info Version", i32 3}