[llvm] r372950 - [SystemZ] Recognize mnop-mcount in backend

Jonas Paulsson via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 26 01:38:07 PDT 2019


Author: jonpa
Date: Thu Sep 26 01:38:07 2019
New Revision: 372950

URL: http://llvm.org/viewvc/llvm-project?rev=372950&view=rev
Log:
[SystemZ]  Recognize mnop-mcount in backend

With -pg -mfentry -mnop-mcount, a nop is emitted instead of the call to
fentry.

Review: Ulrich Weigand
https://reviews.llvm.org/D67765

Added:
    llvm/trunk/test/CodeGen/SystemZ/mnop-mcount-01.ll
    llvm/trunk/test/CodeGen/SystemZ/mnop-mcount-02.ll
Modified:
    llvm/trunk/lib/Target/SystemZ/SystemZAsmPrinter.cpp
    llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp

Modified: llvm/trunk/lib/Target/SystemZ/SystemZAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZAsmPrinter.cpp?rev=372950&r1=372949&r2=372950&view=diff
==============================================================================
--- llvm/trunk/lib/Target/SystemZ/SystemZAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/SystemZ/SystemZAsmPrinter.cpp Thu Sep 26 01:38:07 2019
@@ -553,6 +553,12 @@ static unsigned EmitNop(MCContext &OutCo
 void SystemZAsmPrinter::LowerFENTRY_CALL(const MachineInstr &MI,
                                          SystemZMCInstLower &Lower) {
   MCContext &Ctx = MF->getContext();
+  if (MF->getFunction().getFnAttribute("mnop-mcount")
+                       .getValueAsString() == "true") {
+    EmitNop(Ctx, *OutStreamer, 6, getSubtargetInfo());
+    return;
+  }
+
   MCSymbol *fentry = Ctx.getOrCreateSymbol("__fentry__");
   const MCSymbolRefExpr *Op =
       MCSymbolRefExpr::create(fentry, MCSymbolRefExpr::VK_PLT, Ctx);

Modified: llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp?rev=372950&r1=372949&r2=372950&view=diff
==============================================================================
--- llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp Thu Sep 26 01:38:07 2019
@@ -346,6 +346,11 @@ public:
       : SelectionDAGISel(TM, OptLevel) {}
 
   bool runOnMachineFunction(MachineFunction &MF) override {
+    const Function &F = MF.getFunction();
+    if (F.getFnAttribute("mnop-mcount").getValueAsString() == "true" &&
+        F.getFnAttribute("fentry-call").getValueAsString() != "true")
+      report_fatal_error("mnop-mcount only supported with fentry-call");
+
     Subtarget = &MF.getSubtarget<SystemZSubtarget>();
     return SelectionDAGISel::runOnMachineFunction(MF);
   }

Added: llvm/trunk/test/CodeGen/SystemZ/mnop-mcount-01.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/SystemZ/mnop-mcount-01.ll?rev=372950&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/SystemZ/mnop-mcount-01.ll (added)
+++ llvm/trunk/test/CodeGen/SystemZ/mnop-mcount-01.ll Thu Sep 26 01:38:07 2019
@@ -0,0 +1,26 @@
+; RUN: llc %s -mtriple=s390x-linux-gnu -mcpu=z10 -o - -verify-machineinstrs \
+; RUN:   | FileCheck %s
+
+define void @test1() #0 {
+entry:
+  ret void
+
+; CHECK-LABEL: @test1
+; CHECK: brasl %r0, __fentry__
+; CHECK-NOT: brcl 0, .Ltmp0
+; CHECK: br %r14
+}
+
+define void @test2() #1 {
+entry:
+  ret void
+
+; CHECK-LABEL: @test2
+; CHECK-NOT: brasl %r0, __fentry__
+; CHECK: brcl 0, .Ltmp0
+; CHECK: br %r14
+}
+
+attributes #0 = { "fentry-call"="true" }
+attributes #1 = { "fentry-call"="true" "mnop-mcount"="true" }
+

Added: llvm/trunk/test/CodeGen/SystemZ/mnop-mcount-02.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/SystemZ/mnop-mcount-02.ll?rev=372950&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/SystemZ/mnop-mcount-02.ll (added)
+++ llvm/trunk/test/CodeGen/SystemZ/mnop-mcount-02.ll Thu Sep 26 01:38:07 2019
@@ -0,0 +1,11 @@
+; RUN: not llc %s -mtriple=s390x-linux-gnu -o - 2>&1 | FileCheck %s
+;
+; CHECK: LLVM ERROR: mnop-mcount only supported with fentry-call
+
+define void @test1() #0 {
+entry:
+  ret void
+}
+
+attributes #0 = { "instrument-function-entry-inlined"="mcount" "mnop-mcount"="true" }
+




More information about the llvm-commits mailing list