Revert " [LoongArch][ISel] Check the number of sign bits in `PatGprGpr_32` (#107432)"
[llvm-project.git] / llvm / lib / CodeGen / FEntryInserter.cpp
blob68304dd41db04a4fba52090b72f93960a77c72e4
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/TargetInstrInfo.h"
17 #include "llvm/CodeGen/TargetSubtargetInfo.h"
18 #include "llvm/IR/Function.h"
19 #include "llvm/InitializePasses.h"
21 using namespace llvm;
23 namespace {
24 struct FEntryInserter : public MachineFunctionPass {
25 static char ID; // Pass identification, replacement for typeid
26 FEntryInserter() : MachineFunctionPass(ID) {
27 initializeFEntryInserterPass(*PassRegistry::getPassRegistry());
30 bool runOnMachineFunction(MachineFunction &F) override;
34 bool FEntryInserter::runOnMachineFunction(MachineFunction &MF) {
35 const std::string FEntryName = std::string(
36 MF.getFunction().getFnAttribute("fentry-call").getValueAsString());
37 if (FEntryName != "true")
38 return false;
40 auto &FirstMBB = *MF.begin();
41 auto *TII = MF.getSubtarget().getInstrInfo();
42 BuildMI(FirstMBB, FirstMBB.begin(), DebugLoc(),
43 TII->get(TargetOpcode::FENTRY_CALL));
44 return true;
47 char FEntryInserter::ID = 0;
48 char &llvm::FEntryInserterID = FEntryInserter::ID;
49 INITIALIZE_PASS(FEntryInserter, "fentry-insert", "Insert fentry calls", false,
50 false)