-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[XCOFF] Ensure .file is emitted before any .info pseudo-ops #71577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@llvm/pr-subscribers-debuginfo Author: None (stephenpeckham) ChangesWhen generating the assembly code for AIX/XCOFF, the .file pseudo-op needs to be emitted first, before any csects are generated. Otherwise, information such as the embedded command line will be associated with part of the object file rather than the entire object file. Full diff: https://github.com/llvm/llvm-project/pull/71577.diff 5 Files Affected:
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index 71bee8cce65126b..8637d0658c2c905 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -443,7 +443,12 @@ bool AsmPrinter::doInitialization(Module &M) {
const_cast<TargetLoweringObjectFile &>(getObjFileLowering())
.getModuleMetadata(M);
- OutStreamer->initSections(false, *TM.getMCSubtargetInfo());
+ // On AIX, we delay emitting any section information until
+ // after emitting the .file pseudo-op. This allows additional
+ // information (such as the embedded command line) to be associated
+ // with all sections in the object file rather than a single section.
+ if (!TM.getTargetTriple().isOSBinFormatXCOFF())
+ OutStreamer->initSections(false, *TM.getMCSubtargetInfo());
// Emit the version-min deployment target directive if needed.
//
@@ -489,8 +494,11 @@ bool AsmPrinter::doInitialization(Module &M) {
// On AIX, emit bytes for llvm.commandline metadata after .file so that the
// C_INFO symbol is preserved if any csect is kept by the linker.
- if (TM.getTargetTriple().isOSBinFormatXCOFF())
+ if (TM.getTargetTriple().isOSBinFormatXCOFF()) {
emitModuleCommandLines(M);
+ // Now we can generate section information
+ OutStreamer->initSections(false, *TM.getMCSubtargetInfo());
+ }
GCModuleInfo *MI = getAnalysisIfAvailable<GCModuleInfo>();
assert(MI && "AsmPrinter didn't require GCModuleInfo?");
diff --git a/llvm/test/CodeGen/PowerPC/aix-xcoff-data.ll b/llvm/test/CodeGen/PowerPC/aix-xcoff-data.ll
index 49135499386701d..e84f0b138d25bdd 100644
--- a/llvm/test/CodeGen/PowerPC/aix-xcoff-data.ll
+++ b/llvm/test/CodeGen/PowerPC/aix-xcoff-data.ll
@@ -45,8 +45,8 @@
; CHECK-NOT: .toc
-; CHECK: .csect [PR],5
-; CHECK-NEXT: .file
+; CHECK: .file
+; CHECK-NEXT: .csect [PR],5
; CHECK: .csect .data[RW],5
; CHECK-NEXT: .globl ivar
diff --git a/llvm/test/DebugInfo/XCOFF/empty.ll b/llvm/test/DebugInfo/XCOFF/empty.ll
index 3cb4be26cf04e26..90edc6a6224dd7e 100644
--- a/llvm/test/DebugInfo/XCOFF/empty.ll
+++ b/llvm/test/DebugInfo/XCOFF/empty.ll
@@ -35,8 +35,8 @@ entry:
!11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
!12 = !DILocation(line: 3, column: 3, scope: !8)
-; ASM32: .csect [PR],5
-; ASM32-NEXT: .file "1.c"
+; ASM32: .file "1.c"
+; ASM32-NEXT: .csect [PR],5
; ASM32-NEXT: .globl main[DS] # -- Begin function main
; ASM32-NEXT: .globl .main
; ASM32-NEXT: .align 2
@@ -236,8 +236,8 @@ entry:
; ASM32-NEXT: .byte 1
; ASM32-NEXT: L..debug_line_end0:
-; ASM64: .csect [PR],5
-; ASM64-NEXT: .file "1.c"
+; ASM64: .file "1.c"
+; ASM64-NEXT: .csect [PR],5
; ASM64-NEXT: .globl main[DS] # -- Begin function main
; ASM64-NEXT: .globl .main
; ASM64-NEXT: .align 2
diff --git a/llvm/test/DebugInfo/XCOFF/explicit-section.ll b/llvm/test/DebugInfo/XCOFF/explicit-section.ll
index 5008721795a4100..452c650c6f7f692 100644
--- a/llvm/test/DebugInfo/XCOFF/explicit-section.ll
+++ b/llvm/test/DebugInfo/XCOFF/explicit-section.ll
@@ -42,8 +42,8 @@ entry:
!15 = !DILocation(line: 3, column: 10, scope: !14)
!16 = !DILocation(line: 3, column: 3, scope: !14)
-; CHECK: .csect [PR],5
-; CHECK-NEXT: .file "2.c"
+; CHECK: .file "2.c"
+; CHECK-NEXT: .csect [PR],5
; CHECK-NEXT: .globl bar[DS] # -- Begin function bar
; CHECK-NEXT: .globl .bar
; CHECK-NEXT: .align 2
diff --git a/llvm/test/DebugInfo/XCOFF/function-sections.ll b/llvm/test/DebugInfo/XCOFF/function-sections.ll
index 9f4f55623c7de8c..ef3100483e654a9 100644
--- a/llvm/test/DebugInfo/XCOFF/function-sections.ll
+++ b/llvm/test/DebugInfo/XCOFF/function-sections.ll
@@ -37,8 +37,8 @@ entry:
!13 = distinct !DISubprogram(name: "bar", scope: !1, file: !1, line: 6, type: !9, scopeLine: 7, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
!14 = !DILocation(line: 8, column: 3, scope: !13)
-; CHECK: .csect [PR],5
-; CHECK-NEXT: .file "1.c"
+; CHECK: .file "1.c"
+; CHECK-NEXT: .csect [PR],5
; CHECK-NEXT: .csect .foo[PR],5
; CHECK-NEXT: .globl foo[DS] # -- Begin function foo
; CHECK-NEXT: .globl .foo[PR]
|
jakeegan
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM with a nit
| ; CHECK: .csect [PR],5 | ||
| ; CHECK-NEXT: .file "1.c" | ||
| ; CHECK: .file "1.c" | ||
| ; CHECK-NEXT: .csect [PR],5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Indent the lines more consistently in the tests
When generating the assembly code for AIX/XCOFF, the .file pseudo-op needs to be emitted first, before any csects are generated. Otherwise, information such as the embedded command line will be associated with part of the object file rather than the entire object file.
When generating the assembly code for AIX/XCOFF, the .file pseudo-op needs to be emitted first, before any csects are generated. Otherwise, information such as the embedded command line will be associated with part of the object file rather than the entire object file.