[PATCH] D71629: [SystemZ]  Recognize mrecord-mcount in backend
    Ulrich Weigand via Phabricator via llvm-commits 
    llvm-commits at lists.llvm.org
       
    Tue Dec 17 23:40:09 PST 2019
    
    
  
uweigand added inline comments.
================
Comment at: llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp:565
   if (MF->getFunction().getFnAttribute("mnop-mcount")
                        .getValueAsString() == "true") {
     EmitNop(Ctx, *OutStreamer, 6, getSubtargetInfo());
----------------
For consistency, we should really remove the "true" from the "mnop-mcount" attribute as well.  (That should be a separate patch.)
================
Comment at: llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp:575
 
-  MCSymbol *fentry = Ctx.getOrCreateSymbol("__fentry__");
-  const MCSymbolRefExpr *Op =
-      MCSymbolRefExpr::create(fentry, MCSymbolRefExpr::VK_PLT, Ctx);
-  OutStreamer->EmitInstruction(MCInstBuilder(SystemZ::BRASL)
-                       .addReg(SystemZ::R0D).addExpr(Op), getSubtargetInfo());
+  if (RecordMCount) {
+    OutStreamer->SwitchSection(
----------------
There's no reason to split the code up this way.  You might as well do everything in the block above.
================
Comment at: llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp:578
+        Ctx.getELFSection("__mcount_loc", ELF::SHT_PROGBITS, ELF::SHF_ALLOC));
+    OutStreamer->EmitIntValue(0x1b, 8);
+    OutStreamer->SwitchSection(OutStreamer->getPreviousSection().first);
----------------
This is wrong, you need to emit a reference to the "DotSym" above.
I guess GCC uses the GAS unnamed label feature "1b" -- this is not the hex value 0x1b, but a backward reference to the immediately preceding instance of the "1:" label.
================
Comment at: llvm/test/CodeGen/SystemZ/mrecord-mcount-01.ll:12
+; CHECK: .section __mcount_loc,"a", at progbits
+; CHECK: .quad 27
+; CHECK: .text
----------------
So instead of ".quad 27" this should read ".quad .Ltmp0".
CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71629/new/
https://reviews.llvm.org/D71629
    
    
More information about the llvm-commits
mailing list