diff --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp --- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -34,6 +34,7 @@ #include "llvm/BinaryFormat/ELF.h" #include "llvm/CodeGen/AsmPrinter.h" #include "llvm/CodeGen/MachineBasicBlock.h" +#include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineInstr.h" @@ -266,6 +267,8 @@ bool doFinalization(Module &M) override; void emitTTypeReference(const GlobalValue *GV, unsigned Encoding) override; + + MCSymbol *GetCPISymbol(unsigned CPID) const override; }; } // end anonymous namespace @@ -2805,6 +2808,39 @@ OutStreamer->emitIntValue(0, GetSizeOfEncodedValue(Encoding)); } +// GetCPISymbol - Return the symbol for the specified constant pool entry. +MCSymbol *PPCAIXAsmPrinter::GetCPISymbol(unsigned CPID) const { + // Append hex string of the constant value at the end of the symbol for + // verbosity. + const MachineConstantPoolEntry &CPE = + MF->getConstantPool()->getConstants()[CPID]; + if (!CPE.isMachineConstantPoolEntry()) { + const Constant *C = CPE.Val.ConstVal; + APInt Rep; + bool Valid = false; + if (const ConstantInt *CI = dyn_cast(C)) { + Rep = CI->getValue(); + Valid = true; + } + if (const ConstantFP *CFP = dyn_cast(C)) { + Rep = CFP->getValueAPF().bitcastToAPInt(); + Valid = true; + } + if (Valid) { + const DataLayout &DL = getDataLayout(); + const uint64_t *RawData = Rep.getRawData(); + SmallString<32> HexRep("0x"); + for (unsigned I = 0; I < Rep.getNumWords(); ++I) + HexRep += utohexstr(RawData[I]); + return OutContext.getOrCreateSymbol(Twine(DL.getPrivateGlobalPrefix()) + + "CPI" + Twine(getFunctionNumber()) + + "_" + Twine(CPID) + "_" + HexRep); + } + } + + return AsmPrinter::GetCPISymbol(CPID); +} + // Return a pass that prints the PPC assembly code for a MachineFunction to the // given output stream. static AsmPrinter * diff --git a/llvm/test/CodeGen/PowerPC/aix-constant-align.ll b/llvm/test/CodeGen/PowerPC/aix-constant-align.ll --- a/llvm/test/CodeGen/PowerPC/aix-constant-align.ll +++ b/llvm/test/CodeGen/PowerPC/aix-constant-align.ll @@ -19,7 +19,7 @@ ; CHECK: .csect .rodata.8[RO],3 ; CHECK-NEXT: .align 3 -; CHECK-NEXT: L..CPI0_0: +; CHECK-NEXT: L..CPI0_0_0x400921F9F01B866E: ; CHECK32-NEXT: .vbyte 4, 1074340345 ; CHECK32-NEXT: .vbyte 4, 4028335726 ; CHECK64-NEXT: .vbyte 8, 0x400921f9f01b866e @@ -27,7 +27,7 @@ ; CHECK: .csect .rodata[RO],2 ; CHECK-NEXT: .align 2 -; CHECK-NEXT: L..CPI1_0: +; CHECK-NEXT: L..CPI1_0_0x40490FD0: ; CHECK-NEXT: .vbyte 4, 0x40490fd0 ; CHECK: .csect NOT_PI[RO],3 diff --git a/llvm/test/CodeGen/PowerPC/aix-lower-constant-pool-index.ll b/llvm/test/CodeGen/PowerPC/aix-lower-constant-pool-index.ll --- a/llvm/test/CodeGen/PowerPC/aix-lower-constant-pool-index.ll +++ b/llvm/test/CodeGen/PowerPC/aix-lower-constant-pool-index.ll @@ -47,7 +47,7 @@ ; 32SMALL-ASM: .csect .rodata[RO],2 ; 32SMALL-ASM: .align 2 -; 32SMALL-ASM: L..CPI0_0: +; 32SMALL-ASM: L..CPI0_0_0x40B00000: ; 32SMALL-ASM: .vbyte 4, 0x40b00000 ; 32SMALL-ASM: .test_float: ; 32SMALL-ASM: lwz [[REG1:[0-9]+]], L..C0(2) @@ -56,7 +56,7 @@ ; 32LARGE-ASM: .csect .rodata[RO],2 ; 32LARGE-ASM: .align 2 -; 32LARGE-ASM: L..CPI0_0: +; 32LARGE-ASM: L..CPI0_0_0x40B00000: ; 32LARGE-ASM: .vbyte 4, 0x40b00000 ; 32LARGE-ASM: .test_float: ; 32LARGE-ASM: addis [[REG1:[0-9]+]], L..C0@u(2) @@ -66,7 +66,7 @@ ; 64SMALL-ASM: .csect .rodata[RO],2 ; 64SMALL-ASM: .align 2 -; 64SMALL-ASM: L..CPI0_0: +; 64SMALL-ASM: L..CPI0_0_0x40B00000: ; 64SMALL-ASM: .vbyte 4, 0x40b00000 ; 64SMALL-ASM: .test_float: ; 64SMALL-ASM: ld [[REG1:[0-9]+]], L..C0(2) @@ -75,7 +75,7 @@ ; 64LARGE-ASM: .csect .rodata[RO],2 ; 64LARGE-ASM: .align 2 -; 64LARGE-ASM: L..CPI0_0: +; 64LARGE-ASM: L..CPI0_0_0x40B00000: ; 64LARGE-ASM: .vbyte 4, 0x40b00000 ; 64LARGE-ASM: .test_float: ; 64LARGE-ASM: addis [[REG1:[0-9]+]], L..C0@u(2) @@ -84,7 +84,7 @@ ; 64LARGE-ASM: blr ; SMALL-ASM: .toc -; SMALL-ASM: .tc L..CPI0_0[TC],L..CPI0_0 +; SMALL-ASM: .tc L..CPI0_0_0x40B00000[TC],L..CPI0_0_0x40B00000 ; LARGE-ASM: .toc -; LARGE-ASM: .tc L..CPI0_0[TE],L..CPI0_0 +; LARGE-ASM: .tc L..CPI0_0_0x40B00000[TE],L..CPI0_0_0x40B00000