//=--- RegUsageInfoPropagate.cpp - Register Usage Informartion Propagation --=// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// /// /// This pass is required to take advantage of the interprocedural register /// allocation infrastructure. /// /// This pass iterates through MachineInstrs in a given MachineFunction and at /// each callsite queries RegisterUsageInfo for RegMask (calculated based on /// actual register allocation) of the callee function, if the RegMask detail /// is available then this pass will update the RegMask of the call instruction. /// This updated RegMask will be used by the register allocator while allocating /// the current MachineFunction. /// //===----------------------------------------------------------------------===// #include "llvm/CodeGen/MachineBasicBlock.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFunctionPass.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/Passes.h" #include "llvm/CodeGen/RegisterUsageInfo.h" #include "llvm/IR/Module.h" #include "llvm/Pass.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" usingnamespacellvm; #define DEBUG_TYPE … #define RUIP_NAME … namespace { class RegUsageInfoPropagation : public MachineFunctionPass { … }; } // end of anonymous namespace INITIALIZE_PASS_BEGIN(RegUsageInfoPropagation, "reg-usage-propagation", RUIP_NAME, false, false) INITIALIZE_PASS_DEPENDENCY(PhysicalRegisterUsageInfo) INITIALIZE_PASS_END(RegUsageInfoPropagation, "reg-usage-propagation", RUIP_NAME, false, false) char RegUsageInfoPropagation::ID = …; // Assumes call instructions have a single reference to a function. static const Function *findCalledFunction(const Module &M, const MachineInstr &MI) { … } bool RegUsageInfoPropagation::runOnMachineFunction(MachineFunction &MF) { … } FunctionPass *llvm::createRegUsageInfoPropPass() { … }