[ARM] Rejig MVE load store tests. NFC
[llvm-core.git] / lib / CodeGen / FEntryInserter.cpp
bloba122f490884eee6489f5293dd830067138e44d7a
1 //===-- FEntryInsertion.cpp - Patchable prologues for LLVM -------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file edits function bodies to insert fentry calls.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/CodeGen/MachineFunction.h"
14 #include "llvm/CodeGen/MachineFunctionPass.h"
15 #include "llvm/CodeGen/MachineInstrBuilder.h"
16 #include "llvm/CodeGen/Passes.h"
17 #include "llvm/CodeGen/TargetFrameLowering.h"
18 #include "llvm/CodeGen/TargetInstrInfo.h"
19 #include "llvm/CodeGen/TargetSubtargetInfo.h"
20 #include "llvm/IR/Function.h"
21 #include "llvm/IR/Module.h"
23 using namespace llvm;
25 namespace {
26 struct FEntryInserter : public MachineFunctionPass {
27 static char ID; // Pass identification, replacement for typeid
28 FEntryInserter() : MachineFunctionPass(ID) {
29 initializeFEntryInserterPass(*PassRegistry::getPassRegistry());
32 bool runOnMachineFunction(MachineFunction &F) override;
36 bool FEntryInserter::runOnMachineFunction(MachineFunction &MF) {
37 const std::string FEntryName =
38 MF.getFunction().getFnAttribute("fentry-call").getValueAsString();
39 if (FEntryName != "true")
40 return false;
42 auto &FirstMBB = *MF.begin();
43 auto *TII = MF.getSubtarget().getInstrInfo();
44 BuildMI(FirstMBB, FirstMBB.begin(), DebugLoc(),
45 TII->get(TargetOpcode::FENTRY_CALL));
46 return true;
49 char FEntryInserter::ID = 0;
50 char &llvm::FEntryInserterID = FEntryInserter::ID;
51 INITIALIZE_PASS(FEntryInserter, "fentry-insert", "Insert fentry calls", false,
52 false)