[AIX][AsmPrinter] Print Symbol in comments for TOC load

We are using TOCEntry symbols like `LC..0` in TOC loads,
this is hard to read , at least requiring an additional step to figure
out the loaded symbols.

We should print out the name in comments.

Reviewed By: #powerpc, shchenz

Differential Revision: https://reviews.llvm.org/D102949
This commit is contained in:
Jinsong Ji 2021-05-25 16:19:11 +00:00
parent 57250f2f3c
commit 882e4cbd74
4 changed files with 25 additions and 17 deletions

View File

@ -846,6 +846,10 @@ void PPCAsmPrinter::emitInstruction(const MachineInstr *MI) {
"This pseudo should only be selected for 32-bit small code model.");
Exp = getTOCEntryLoadingExprForXCOFF(MOSymbol, Exp, VK);
TmpInst.getOperand(1) = MCOperand::createExpr(Exp);
// Print MO for better readability
if (isVerbose())
OutStreamer->GetCommentOS() << MO << '\n';
EmitToStreamer(*OutStreamer, TmpInst);
return;
}
@ -912,6 +916,10 @@ void PPCAsmPrinter::emitInstruction(const MachineInstr *MI) {
const MCExpr *Exp = MCSymbolRefExpr::create(TOCEntry, VKExpr, OutContext);
TmpInst.getOperand(1) = MCOperand::createExpr(
IsAIX ? getTOCEntryLoadingExprForXCOFF(MOSymbol, Exp, VK) : Exp);
// Print MO for better readability
if (isVerbose() && IsAIX)
OutStreamer->GetCommentOS() << MO << '\n';
EmitToStreamer(*OutStreamer, TmpInst);
return;
}

View File

@ -28,27 +28,27 @@ print("ret void")
print("}")
# 32-bit assembly check
# ASM32: lwz 4, L..C0(2)
# ASM32: lwz 4, L..C1(2)
# ASM32: lwz 4, L..C0(2) # @a0
# ASM32: lwz 4, L..C1(2) # @a1
# ASM32: lwz 4, L..C8191(2)
# ASM32: lwz 4, L..C8192-65536(2)
# ASM32: lwz 4, L..C8193-65536(2)
# ASM32: lwz 4, L..C8191(2) # @a8191
# ASM32: lwz 4, L..C8192-65536(2) # @a8192
# ASM32: lwz 4, L..C8193-65536(2) # @a8193
# ASM32: lwz 4, L..C12288-65536(2)
# ASM32: lwz 4, L..C12289-65536(2)
# ASM32: lwz 4, L..C12288-65536(2) # @a12288
# ASM32: lwz 4, L..C12289-65536(2) # @a12289
# 64-bit assembly check
# ASM64: ld 4, L..C0(2)
# ASM64: ld 4, L..C1(2)
# ASM64: ld 4, L..C0(2) # @a0
# ASM64: ld 4, L..C1(2) # @a1
# ASM64: ld 4, L..C4095(2)
# ASM64: ld 4, L..C4096-65536(2)
# ASM64: ld 4, L..C4097-65536(2)
# ASM64: ld 4, L..C4095(2) # @a4095
# ASM64: ld 4, L..C4096-65536(2) # @a4096
# ASM64: ld 4, L..C4097-65536(2) # @a4097
# ASM64: ld 4, L..C12287-65536(2)
# ASM64: ld 4, L..C12288-131072(2)
# ASM64: ld 4, L..C12289-131072(2)
# ASM64: ld 4, L..C12287-65536(2) # @a12287
# ASM64: ld 4, L..C12288-131072(2) # @a12288
# ASM64: ld 4, L..C12289-131072(2) # @a12289
# DIS32: 0: 80 82 00 00 lwz 4, 0(2)
# DIS32: 00000002: R_TOC (idx: 24591) a0[TC]

View File

@ -164,7 +164,7 @@ attributes #0 = { noredzone nounwind ssp uwtable "frame-pointer"="all" }
; AIX: # %bb.0:
; AIX-NEXT: stw 31, -4(1)
; AIX-NEXT: stwu 1, -48(1)
; AIX-NEXT: lwz 4, L..C0(2)
; AIX-NEXT: lwz 4, L..C0(2) # @x
; AIX-NEXT: mr 31, 1
; AIX-NEXT: li 3, 0
; AIX-NEXT: stw 3, 40(31)

View File

@ -142,7 +142,7 @@ define dso_local i32 @main() #0 {
; AIX: # %bb.0:
; AIX-NEXT: stw 31, -4(1)
; AIX-NEXT: stwu 1, -48(1)
; AIX-NEXT: lwz 4, L..C0(2)
; AIX-NEXT: lwz 4, L..C0(2) # @x
; AIX-NEXT: mr 31, 1
; AIX-NEXT: li 3, 0
; AIX-NEXT: stw 3, 40(31)