diff options
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp | 54 |
1 files changed, 30 insertions, 24 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp index 32a4f60df097..85c6eca5775e 100644 --- a/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp @@ -192,10 +192,8 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf, MF->getFrameInfo().CreateVariableSizedObject( Alignment <= StackAlign ? Align(1) : Alignment, AI); } - } - - // Look for inline asm that clobbers the SP register. - if (auto *Call = dyn_cast<CallBase>(&I)) { + } else if (auto *Call = dyn_cast<CallBase>(&I)) { + // Look for inline asm that clobbers the SP register. if (Call->isInlineAsm()) { Register SP = TLI->getStackPointerRegisterToSaveRestore(); const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo(); @@ -214,21 +212,20 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf, } } } - } - - // Look for calls to the @llvm.va_start intrinsic. We can omit some - // prologue boilerplate for variadic functions that don't examine their - // arguments. - if (const auto *II = dyn_cast<IntrinsicInst>(&I)) { - if (II->getIntrinsicID() == Intrinsic::vastart) - MF->getFrameInfo().setHasVAStart(true); - } + // Look for calls to the @llvm.va_start intrinsic. We can omit some + // prologue boilerplate for variadic functions that don't examine their + // arguments. + if (const auto *II = dyn_cast<IntrinsicInst>(&I)) { + if (II->getIntrinsicID() == Intrinsic::vastart) + MF->getFrameInfo().setHasVAStart(true); + } - // If we have a musttail call in a variadic function, we need to ensure we - // forward implicit register parameters. - if (const auto *CI = dyn_cast<CallInst>(&I)) { - if (CI->isMustTailCall() && Fn->isVarArg()) - MF->getFrameInfo().setHasMustTailInVarArgFunc(true); + // If we have a musttail call in a variadic function, we need to ensure + // we forward implicit register parameters. + if (const auto *CI = dyn_cast<CallInst>(&I)) { + if (CI->isMustTailCall() && Fn->isVarArg()) + MF->getFrameInfo().setHasMustTailInVarArgFunc(true); + } } // Mark values used outside their block as exported, by allocating @@ -333,14 +330,23 @@ void FunctionLoweringInfo::set(const Function &fn, MachineFunction &mf, else if (Personality == EHPersonality::Wasm_CXX) { WasmEHFuncInfo &EHInfo = *MF->getWasmEHFuncInfo(); - // Map all BB references in the WinEH data to MBBs. - DenseMap<BBOrMBB, BBOrMBB> NewMap; - for (auto &KV : EHInfo.EHPadUnwindMap) { + // Map all BB references in the Wasm EH data to MBBs. + DenseMap<BBOrMBB, BBOrMBB> SrcToUnwindDest; + for (auto &KV : EHInfo.SrcToUnwindDest) { const auto *Src = KV.first.get<const BasicBlock *>(); - const auto *Dst = KV.second.get<const BasicBlock *>(); - NewMap[MBBMap[Src]] = MBBMap[Dst]; + const auto *Dest = KV.second.get<const BasicBlock *>(); + SrcToUnwindDest[MBBMap[Src]] = MBBMap[Dest]; + } + EHInfo.SrcToUnwindDest = std::move(SrcToUnwindDest); + DenseMap<BBOrMBB, SmallPtrSet<BBOrMBB, 4>> UnwindDestToSrcs; + for (auto &KV : EHInfo.UnwindDestToSrcs) { + const auto *Dest = KV.first.get<const BasicBlock *>(); + UnwindDestToSrcs[MBBMap[Dest]] = SmallPtrSet<BBOrMBB, 4>(); + for (const auto P : KV.second) + UnwindDestToSrcs[MBBMap[Dest]].insert( + MBBMap[P.get<const BasicBlock *>()]); } - EHInfo.EHPadUnwindMap = std::move(NewMap); + EHInfo.UnwindDestToSrcs = std::move(UnwindDestToSrcs); } } |
