[ORC] Add std::tuple support to SimplePackedSerialization.
[llvm-project.git] / llvm / lib / CodeGen / FEntryInserter.cpp
blobc2194929e2e7f0d4092800dae7db7e659ce97f48
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"
22 #include "llvm/InitializePasses.h"
24 using namespace llvm;
26 namespace {
27 struct FEntryInserter : public MachineFunctionPass {
28 static char ID; // Pass identification, replacement for typeid
29 FEntryInserter() : MachineFunctionPass(ID) {
30 initializeFEntryInserterPass(*PassRegistry::getPassRegistry());
33 bool runOnMachineFunction(MachineFunction &F) override;
37 bool FEntryInserter::runOnMachineFunction(MachineFunction &MF) {
38 const std::string FEntryName = std::string(
39 MF.getFunction().getFnAttribute("fentry-call").getValueAsString());
40 if (FEntryName != "true")
41 return false;
43 auto &FirstMBB = *MF.begin();
44 auto *TII = MF.getSubtarget().getInstrInfo();
45 BuildMI(FirstMBB, FirstMBB.begin(), DebugLoc(),
46 TII->get(TargetOpcode::FENTRY_CALL));
47 return true;
50 char FEntryInserter::ID = 0;
51 char &llvm::FEntryInserterID = FEntryInserter::ID;
52 INITIALIZE_PASS(FEntryInserter, "fentry-insert", "Insert fentry calls", false,
53 false)