[llvm] 1ea1e05 - [AIX] Make sure to use QualNames for external global objects
David Tenty via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 5 12:22:58 PST 2019
Author: David Tenty
Date: 2019-12-05T15:22:53-05:00
New Revision: 1ea1e053f6a10955a5aa8f5a8007544a846766e5
URL: https://github.com/llvm/llvm-project/commit/1ea1e053f6a10955a5aa8f5a8007544a846766e5
DIFF: https://github.com/llvm/llvm-project/commit/1ea1e053f6a10955a5aa8f5a8007544a846766e5.diff
LOG: [AIX] Make sure to use QualNames for external global objects
Summary: Previously we only handled the case where the csect hadn't been set up yet, so we'd hit an assert later on.
Reviewers: jasonliu, DiggerLin, stevewan
Reviewed By: jasonliu
Subscribers: hubert.reinterpretcast, wuzish, nemanjai, hiraditya, kbarton, jsji, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D71032
Added:
Modified:
llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
llvm/test/CodeGen/PowerPC/aix-xcoff-toc.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
index 9b8fb4ddd311..db2352b74e16 100644
--- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -1883,18 +1883,20 @@ PPCAIXAsmPrinter::getMCSymbolForTOCPseudoMO(const MachineOperand &MO) {
// declaration of a function, then XSym is an external referenced symbol.
// Hence we may need to explictly create a MCSectionXCOFF for it so that we
// can return its symbol later.
- if (GO->isDeclaration() && !XSym->hasContainingCsect()) {
- // Make sure the storage class is set.
- const XCOFF::StorageClass SC =
- TargetLoweringObjectFileXCOFF::getStorageClassForGlobal(GO);
- XSym->setStorageClass(SC);
-
- MCSectionXCOFF *Csect = OutStreamer->getContext().getXCOFFSection(
- XSym->getName(), isa<Function>(GO) ? XCOFF::XMC_DS : XCOFF::XMC_UA,
- XCOFF::XTY_ER, SC, SectionKind::getMetadata());
- XSym->setContainingCsect(Csect);
-
- return Csect->getQualNameSymbol();
+ if (GO->isDeclaration()) {
+ if (!XSym->hasContainingCsect()) {
+ // Make sure the storage class is set.
+ const XCOFF::StorageClass SC =
+ TargetLoweringObjectFileXCOFF::getStorageClassForGlobal(GO);
+ XSym->setStorageClass(SC);
+
+ MCSectionXCOFF *Csect = OutStreamer->getContext().getXCOFFSection(
+ XSym->getName(), isa<Function>(GO) ? XCOFF::XMC_DS : XCOFF::XMC_UA,
+ XCOFF::XTY_ER, SC, SectionKind::getMetadata());
+ XSym->setContainingCsect(Csect);
+ }
+
+ return XSym->getContainingCsect()->getQualNameSymbol();
}
// Handle initialized global variables.
diff --git a/llvm/test/CodeGen/PowerPC/aix-xcoff-toc.ll b/llvm/test/CodeGen/PowerPC/aix-xcoff-toc.ll
index 57f97064b5c9..89498833b4e4 100644
--- a/llvm/test/CodeGen/PowerPC/aix-xcoff-toc.ll
+++ b/llvm/test/CodeGen/PowerPC/aix-xcoff-toc.ll
@@ -28,6 +28,14 @@ define void @bar() {
ret void
}
+; We initialize a csect when we first reference an external global, so make sure we don't run into problems when we see it again.
+define void @bar2() {
+ store i32 0, i32* @a, align 4
+ store i64 0, i64* @b, align 8
+ store i16 0, i16* @c, align 2
+ ret void
+}
+
; CHECK-NOT: .comm a
; CHECK-NOT: .lcomm a
; CHECK-NOT: .comm b
@@ -55,7 +63,7 @@ define void @bar() {
; SYM: File: {{.*}}aix-xcoff-toc.ll.tmp.o
; SYM: Symbol {{[{][[:space:]] *}}Index: [[#INDX:]]{{[[:space:]] *}}Name: TOC
-; SYM-NEXT: Value (RelocatableAddress): 0x54
+; SYM-NEXT: Value (RelocatableAddress): 0x8C
; SYM-NEXT: Section: .data
; SYM-NEXT: Type: 0x0
; SYM-NEXT: StorageClass: C_HIDEXT (0x6B)
@@ -75,7 +83,7 @@ define void @bar() {
; SYM-NEXT: Symbol {
; SYM-NEXT: Index: [[#INDX+2]]
; SYM-NEXT: Name: a
-; SYM-NEXT: Value (RelocatableAddress): 0x54
+; SYM-NEXT: Value (RelocatableAddress): 0x8C
; SYM-NEXT: Section: .data
; SYM-NEXT: Type: 0x0
; SYM-NEXT: StorageClass: C_HIDEXT (0x6B)
@@ -95,7 +103,7 @@ define void @bar() {
; SYM-NEXT: Symbol {
; SYM-NEXT: Index: [[#INDX+4]]
; SYM-NEXT: Name: b
-; SYM-NEXT: Value (RelocatableAddress): 0x58
+; SYM-NEXT: Value (RelocatableAddress): 0x90
; SYM-NEXT: Section: .data
; SYM-NEXT: Type: 0x0
; SYM-NEXT: StorageClass: C_HIDEXT (0x6B)
@@ -115,7 +123,7 @@ define void @bar() {
; SYM-NEXT: Symbol {
; SYM-NEXT: Index: [[#INDX+6]]
; SYM-NEXT: Name: c
-; SYM-NEXT: Value (RelocatableAddress): 0x5C
+; SYM-NEXT: Value (RelocatableAddress): 0x94
; SYM-NEXT: Section: .data
; SYM-NEXT: Type: 0x0
; SYM-NEXT: StorageClass: C_HIDEXT (0x6B)
@@ -135,7 +143,7 @@ define void @bar() {
; SYM-NEXT: Symbol {
; SYM-NEXT: Index: [[#INDX+8]]
; SYM-NEXT: Name: globa
-; SYM-NEXT: Value (RelocatableAddress): 0x60
+; SYM-NEXT: Value (RelocatableAddress): 0x98
; SYM-NEXT: Section: .data
; SYM-NEXT: Type: 0x0
; SYM-NEXT: StorageClass: C_HIDEXT (0x6B)
@@ -155,7 +163,7 @@ define void @bar() {
; SYM-NEXT: Symbol {
; SYM-NEXT: Index: [[#INDX+10]]
; SYM-NEXT: Name: ptr
-; SYM-NEXT: Value (RelocatableAddress): 0x64
+; SYM-NEXT: Value (RelocatableAddress): 0x9C
; SYM-NEXT: Section: .data
; SYM-NEXT: Type: 0x0
; SYM-NEXT: StorageClass: C_HIDEXT (0x6B)
@@ -175,7 +183,7 @@ define void @bar() {
; SYM-NEXT: Symbol {
; SYM-NEXT: Index: [[#INDX+12]]
; SYM-NEXT: Name: bar
-; SYM-NEXT: Value (RelocatableAddress): 0x68
+; SYM-NEXT: Value (RelocatableAddress): 0xA0
; SYM-NEXT: Section: .data
; SYM-NEXT: Type: 0x0
; SYM-NEXT: StorageClass: C_HIDEXT (0x6B)
@@ -195,7 +203,7 @@ define void @bar() {
; SYM-NEXT: Symbol {
; SYM-NEXT: Index: [[#INDX+14]]
; SYM-NEXT: Name: foo
-; SYM-NEXT: Value (RelocatableAddress): 0x6C
+; SYM-NEXT: Value (RelocatableAddress): 0xA4
; SYM-NEXT: Section: .data
; SYM-NEXT: Type: 0x0
; SYM-NEXT: StorageClass: C_HIDEXT (0x6B)
More information about the llvm-commits
mailing list