[PATCH] D29315: MCMacho: Allow __thread_ptr section after dwarf sections

Matthias Braun via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 30 19:14:42 PST 2017


MatzeB created this revision.
Herald added subscribers: mcrosier, aemerson.

r232842 added an assert that fires with the included testcase. Add an exception for '__thread_ptr' to canGoAfterDWARF().

Note: I don't know much about MC or whether this is the right thing to do. At a first glance this code looks like we should rather have a blacklist of sections that must not go after the dwarf sections rather than having a whitelist of sections that are allowed to go. (For example if you read ARMAsmPrinter::EmitEndOfAsmFile() there is another section called "Drectve" that is output after the debug info...


Repository:
  rL LLVM

https://reviews.llvm.org/D29315

Files:
  lib/MC/MCMachOStreamer.cpp
  test/MC/MachO/ARM/no-tls-assert.ll


Index: test/MC/MachO/ARM/no-tls-assert.ll
===================================================================
--- /dev/null
+++ test/MC/MachO/ARM/no-tls-assert.ll
@@ -0,0 +1,31 @@
+; RUN: llc -filetype=obj -o /dev/null %s
+; This should not trigger the "Creating regular section after DWARF" assert.
+target triple = "thumbv7-apple-ios9.0.0"
+
+ at b = external thread_local global i32
+define i32* @func(i32 %a) !dbg !9 {
+  ret i32* @b
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5, !6, !7}
+!llvm.ident = !{!8}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 5.0.0 (trunk 293523) (llvm/trunk 293525)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)
+!1 = !DIFile(filename: "r.ii", directory: "/Users/mbraun/Downloads")
+!2 = !{}
+!3 = !{i32 2, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{i32 1, !"min_enum_size", i32 4}
+!7 = !{i32 1, !"PIC Level", i32 2}
+!8 = !{!"clang version 5.0.0 (trunk 293523) (llvm/trunk 293525)"}
+!9 = distinct !DISubprogram(name: "func", scope: !1, file: !1, line: 4, type: !10, isLocal: false, isDefinition: true, scopeLine: 4, flags: DIFlagPrototyped, isOptimized: false, unit: !0, variables: !2)
+!10 = !DISubroutineType(types: !11)
+!11 = !{null, !12}
+!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!13 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 4, type: !12)
+!14 = !DIExpression()
+!15 = !DILocation(line: 4, column: 15, scope: !9)
+!16 = !DILocation(line: 4, column: 20, scope: !9)
+!17 = !DILocation(line: 4, column: 31, scope: !9)
Index: lib/MC/MCMachOStreamer.cpp
===================================================================
--- lib/MC/MCMachOStreamer.cpp
+++ lib/MC/MCMachOStreamer.cpp
@@ -142,7 +142,7 @@
   if (SegName == "__TEXT" && SecName == "__eh_frame")
     return true;
 
-  if (SegName == "__DATA" && SecName == "__nl_symbol_ptr")
+  if (SegName == "__DATA" && (SecName == "__nl_symbol_ptr" || SecName == "__thread_ptr"))
     return true;
 
   return false;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29315.86382.patch
Type: text/x-patch
Size: 2116 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170131/69aa54a4/attachment.bin>


More information about the llvm-commits mailing list