summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target
diff options
context:
space:
mode:
authorJonas Paulsson <paulsson@linux.vnet.ibm.com>2019-12-17 13:13:16 -0800
committerJonas Paulsson <paulsson@linux.vnet.ibm.com>2019-12-19 09:06:18 -0800
commit6be15788951b44b2516f503bb7feb555364c6e5a (patch)
tree478dae920b46fec4f4ebcb3455a7646130b96763 /llvm/lib/Target
parent63e2aa5658bd8a4905ae5a85f9046250a5e16a86 (diff)
downloadbcm5719-llvm-6be15788951b44b2516f503bb7feb555364c6e5a.tar.gz
bcm5719-llvm-6be15788951b44b2516f503bb7feb555364c6e5a.zip
[SystemZ] Recognize mrecord-mcount in backend
Emit the __mcount_loc section for all fentry calls. Review: Ulrich Weigand https://reviews.llvm.org/D71629
Diffstat (limited to 'llvm/lib/Target')
-rw-r--r--llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp12
-rw-r--r--llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp9
2 files changed, 18 insertions, 3 deletions
diff --git a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
index 34f7bc99a0d..1a7f1779075 100644
--- a/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZAsmPrinter.cpp
@@ -16,11 +16,13 @@
#include "SystemZConstantPoolValue.h"
#include "SystemZMCInstLower.h"
#include "TargetInfo/SystemZTargetInfo.h"
+#include "llvm/BinaryFormat/ELF.h"
#include "llvm/CodeGen/MachineModuleInfoImpls.h"
#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
#include "llvm/IR/Mangler.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCInstBuilder.h"
+#include "llvm/MC/MCSectionELF.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/Support/TargetRegistry.h"
@@ -553,6 +555,16 @@ static unsigned EmitNop(MCContext &OutContext, MCStreamer &OutStreamer,
void SystemZAsmPrinter::LowerFENTRY_CALL(const MachineInstr &MI,
SystemZMCInstLower &Lower) {
MCContext &Ctx = MF->getContext();
+ if (MF->getFunction().hasFnAttribute("mrecord-mcount")) {
+ MCSymbol *DotSym = OutContext.createTempSymbol();
+ OutStreamer->PushSection();
+ OutStreamer->SwitchSection(
+ Ctx.getELFSection("__mcount_loc", ELF::SHT_PROGBITS, ELF::SHF_ALLOC));
+ OutStreamer->EmitSymbolValue(DotSym, 8);
+ OutStreamer->PopSection();
+ OutStreamer->EmitLabel(DotSym);
+ }
+
if (MF->getFunction().hasFnAttribute("mnop-mcount")) {
EmitNop(Ctx, *OutStreamer, 6, getSubtargetInfo());
return;
diff --git a/llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp b/llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
index 0bcbce68a5f..74d66516321 100644
--- a/llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
+++ b/llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
@@ -347,9 +347,12 @@ public:
bool runOnMachineFunction(MachineFunction &MF) override {
const Function &F = MF.getFunction();
- if (F.hasFnAttribute("mnop-mcount") &&
- F.getFnAttribute("fentry-call").getValueAsString() != "true")
- report_fatal_error("mnop-mcount only supported with fentry-call");
+ if (F.getFnAttribute("fentry-call").getValueAsString() != "true") {
+ if (F.hasFnAttribute("mnop-mcount"))
+ report_fatal_error("mnop-mcount only supported with fentry-call");
+ if (F.hasFnAttribute("mrecord-mcount"))
+ report_fatal_error("mrecord-mcount only supported with fentry-call");
+ }
Subtarget = &MF.getSubtarget<SystemZSubtarget>();
return SelectionDAGISel::runOnMachineFunction(MF);
OpenPOWER on IntegriCloud