[PowerPC] omit location attribute for TLS variable on AIX
authorChen Zheng <czhengsz@cn.ibm.com>
Thu, 21 Jul 2022 10:22:50 +0000 (06:22 -0400)
committerChen Zheng <czhengsz@cn.ibm.com>
Fri, 12 Aug 2022 04:54:48 +0000 (00:54 -0400)
TLS debug on AIX is not ready for now.
The location generated in no-integrated-as mode is wrong and
in integrated-as mode causes AIX linker error.

Reviewed By: Esme

Differential Revision: https://reviews.llvm.org/D130245

llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/test/CodeGen/PowerPC/tls-debug-aix.ll [new file with mode: 0644]

index b114f42..5859937 100644 (file)
@@ -2469,6 +2469,13 @@ void TargetLoweringObjectFileXCOFF::Initialize(MCContext &Ctx,
   PersonalityEncoding = 0;
   LSDAEncoding = 0;
   CallSiteEncoding = dwarf::DW_EH_PE_udata4;
+
+  // AIX debug for thread local location is not ready. And for integrated as
+  // mode, the relocatable address for the thread local variable will cause
+  // linker error. So disable the location attribute generation for thread local
+  // variables for now.
+  // FIXME: when TLS debug on AIX is ready, remove this setting.
+  SupportDebugThreadLocalLocation = false;
 }
 
 MCSection *TargetLoweringObjectFileXCOFF::getStaticCtorSection(
diff --git a/llvm/test/CodeGen/PowerPC/tls-debug-aix.ll b/llvm/test/CodeGen/PowerPC/tls-debug-aix.ll
new file mode 100644 (file)
index 0000000..edcf2f0
--- /dev/null
@@ -0,0 +1,54 @@
+; RUN: llc -mtriple powerpc-ibm-aix-xcoff < %s | FileCheck %s --check-prefix=ASM
+; RUN: llc -mtriple powerpc64-ibm-aix-xcoff < %s | FileCheck %s --check-prefix=ASM
+; RUN: llc -mtriple powerpc-ibm-aix-xcoff -filetype=obj < %s | \
+; RUN:   llvm-dwarfdump -i - | FileCheck %s --check-prefix=OBJ
+; RUN: llc -mtriple powerpc64-ibm-aix-xcoff -filetype=obj < %s | \
+; RUN:   llvm-dwarfdump -i - | FileCheck %s --check-prefix=OBJ
+
+; ASM:         .dwsect 0x10000
+; ASM-NEXT:    .dwinfo:
+; ASM:         .byte{{.*}}DW_TAG_variable
+; ASM-NOT:     .byte{{.*}}DW_AT_location
+; ASM-NOT:     .vbyte{{.*}}i[TL]
+; ASM:         .byte{{.*}}DW_TAG_
+
+; OBJ:        DW_TAG_variable
+; OBJ-NEXT:     DW_AT_name{{.*}}("i")
+; OBJ-NEXT:     DW_AT_type
+; OBJ-NEXT:     DW_AT_external
+; OBJ-NEXT:     DW_AT_decl_file
+; OBJ-NEXT:     DW_AT_decl_line
+; OBJ-NOT:      DW_AT_location{{.*}}DW_OP_form_tls_address
+; OBJ:        DW_TAG_
+
+@i = thread_local global i32 20, align 4, !dbg !0
+
+define i32 @foo() !dbg !12 {
+entry:
+  %retval = alloca i32, align 4
+  store i32 0, i32* %retval, align 4
+  %0 = load i32, i32* @i, align 4, !dbg !16
+  ret i32 %0, !dbg !16
+}
+
+!llvm.dbg.cu = !{!2}
+!llvm.module.flags = !{!6, !7, !8, !9, !10}
+!llvm.ident = !{!11}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = distinct !DIGlobalVariable(name: "i", scope: !2, file: !3, line: 2, type: !5, isLocal: false, isDefinition: true)
+!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "IBM Open XL C/C++ for AIX", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)
+!3 = !DIFile(filename: "t.c", directory: ".")
+!4 = !{!0}
+!5 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!6 = !{i32 7, !"Dwarf Version", i32 3}
+!7 = !{i32 2, !"Debug Info Version", i32 3}
+!8 = !{i32 1, !"wchar_size", i32 2}
+!9 = !{i32 7, !"PIC Level", i32 2}
+!10 = !{i32 7, !"frame-pointer", i32 2}
+!11 = !{!"IBM Open XL C/C++ for AIX"}
+!12 = distinct !DISubprogram(name: "foo", scope: !3, file: !3, line: 3, type: !13, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !15)
+!13 = !DISubroutineType(types: !14)
+!14 = !{!5}
+!15 = !{}
+!16 = !DILocation(line: 4, scope: !12)