[llvm] [RISCV] Emit lpad for function with returns-twice attribute (PR #170520)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 3 10:02:02 PST 2025
================
@@ -100,5 +110,21 @@ bool RISCVIndirectBranchTracking::runOnMachineFunction(MachineFunction &MF) {
}
}
+ // Check for calls to functions with ReturnsTwice attribute and insert
+ // LPAD after such calls
+ for (MachineBasicBlock &MBB : MF) {
+ for (MachineBasicBlock::iterator I = MBB.begin(); I != MBB.end(); ++I) {
+ if (I->isCall() && I->getNumOperands() > 0) {
+ if (IsCallReturnTwice(I->getOperand(0))) {
+ auto NextI = std::next(I);
+ BuildMI(MBB, NextI, MBB.findDebugLoc(NextI), TII->get(RISCV::AUIPC),
----------------
topperc wrote:
Can we use `emitLpad` here by making it take a `MachineBasicBlock::iterator` instead of a MachineBasicBlock?
https://github.com/llvm/llvm-project/pull/170520
More information about the llvm-commits
mailing list