[llvm] 882e4cb - [AIX][AsmPrinter] Print Symbol in comments for TOC load

Jinsong Ji via llvm-commits llvm-commits at lists.llvm.org
Tue May 25 09:37:49 PDT 2021


Author: Jinsong Ji
Date: 2021-05-25T16:37:40Z
New Revision: 882e4cbd7477995f580058ddd5dfe68a947527b6

URL: https://github.com/llvm/llvm-project/commit/882e4cbd7477995f580058ddd5dfe68a947527b6
DIFF: https://github.com/llvm/llvm-project/commit/882e4cbd7477995f580058ddd5dfe68a947527b6.diff

LOG: [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

Added: 
    

Modified: 
    llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
    llvm/test/CodeGen/PowerPC/aix-overflow-toc.py
    llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll.generated.expected
    llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll.nogenerated.expected

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
index d71b1187e5348..ffb5bc903f857 100644
--- a/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ b/llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -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;
   }

diff  --git a/llvm/test/CodeGen/PowerPC/aix-overflow-toc.py b/llvm/test/CodeGen/PowerPC/aix-overflow-toc.py
index d2b5a3a3cb045..026c80105e1a1 100644
--- a/llvm/test/CodeGen/PowerPC/aix-overflow-toc.py
+++ b/llvm/test/CodeGen/PowerPC/aix-overflow-toc.py
@@ -28,27 +28,27 @@
 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]

diff  --git a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll.generated.expected b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll.generated.expected
index 1fca598d23fe4..72e0e87b95935 100644
--- a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll.generated.expected
+++ b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll.generated.expected
@@ -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)

diff  --git a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll.nogenerated.expected b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll.nogenerated.expected
index 13512d401a7f0..f104800f74044 100644
--- a/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll.nogenerated.expected
+++ b/llvm/test/tools/UpdateTestChecks/update_llc_test_checks/Inputs/ppc_generated_funcs.ll.nogenerated.expected
@@ -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)


        


More information about the llvm-commits mailing list