[PATCH] D102949: [AIX][AsmPrinter] Print Symbol in comments for TOC load

Jinsong Ji via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri May 21 15:07:31 PDT 2021


jsji created this revision.
jsji added reviewers: PowerPC, jasonliu, hubert.reinterpretcast, shchenz.
Herald added subscribers: kbarton, hiraditya, nemanjai.
jsji requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102949

Files:
  llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
  llvm/test/CodeGen/PowerPC/aix-overflow-toc.py


Index: llvm/test/CodeGen/PowerPC/aix-overflow-toc.py
===================================================================
--- llvm/test/CodeGen/PowerPC/aix-overflow-toc.py
+++ 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]
Index: llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
+++ llvm/lib/Target/PowerPC/PPCAsmPrinter.cpp
@@ -846,6 +846,10 @@
           "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 @@
     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;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102949.347134.patch
Type: text/x-patch
Size: 2551 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210521/fa115169/attachment.bin>


More information about the llvm-commits mailing list