Index: lib/Target/SystemZ/SystemZAsmPrinter.cpp =================================================================== --- lib/Target/SystemZ/SystemZAsmPrinter.cpp +++ lib/Target/SystemZ/SystemZAsmPrinter.cpp @@ -210,6 +210,12 @@ break; case SystemZ::CallBRASL: + if (MF->getFunction().getFnAttribute("mnop-mcount") + .getValueAsString() == "true" && + MI->getOperand(0).isGlobal() && + MI->getOperand(0).getGlobal()->getName().str().compare("mcount") == 0) + report_fatal_error("-mnop-mcount only supported for fentry"); + LoweredMI = MCInstBuilder(SystemZ::BRASL) .addReg(SystemZ::R14D) .addExpr(Lower.getExpr(MI->getOperand(0), MCSymbolRefExpr::VK_PLT)); @@ -553,6 +559,12 @@ 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); Index: test/CodeGen/SystemZ/mnop-mcount-01.ll =================================================================== --- /dev/null +++ test/CodeGen/SystemZ/mnop-mcount-01.ll @@ -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" } + Index: test/CodeGen/SystemZ/mnop-mcount-02.ll =================================================================== --- /dev/null +++ test/CodeGen/SystemZ/mnop-mcount-02.ll @@ -0,0 +1,11 @@ +; RUN: not llc %s -mtriple=s390x-linux-gnu -o - 2>&1 | FileCheck %s +; +; CHECK: LLVM ERROR: -mnop-mcount only supported for fentry + +define void @test1() #0 { +entry: + ret void +} + +attributes #0 = { "instrument-function-entry-inlined"="mcount" "mnop-mcount"="true" } +