[llvm] r256965 - [WinEH] Remove calculateCatchReturnSuccessorColors

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 6 17:07:49 PST 2016


David Majnemer via llvm-commits <llvm-commits at lists.llvm.org> writes:
> Author: majnemer
> Date: Wed Jan  6 13:26:30 2016
> New Revision: 256965
>
> URL: http://llvm.org/viewvc/llvm-project?rev=256965&view=rev
> Log:
> [WinEH] Remove calculateCatchReturnSuccessorColors
>
> The functionality that calculateCatchReturnSuccessorColors provides was
> once non-trivial: it was a computation layered on top of funclet
> coloring.
>
> These days, LLVM IR directly encodes what
> calculateCatchReturnSuccessorColors computed, obsoleting the need for
> it.
>
> No functionality change is intended.
>
> Modified:
>     llvm/trunk/include/llvm/CodeGen/WinEHFuncInfo.h
>     llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
>     llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
>     llvm/trunk/lib/CodeGen/WinEHPrepare.cpp
>
> Modified: llvm/trunk/include/llvm/CodeGen/WinEHFuncInfo.h
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/WinEHFuncInfo.h?rev=256965&r1=256964&r2=256965&view=diff
> ==============================================================================
>
> --- llvm/trunk/include/llvm/CodeGen/WinEHFuncInfo.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/WinEHFuncInfo.h Wed Jan  6 13:26:30 2016
> @@ -93,8 +93,6 @@ struct WinEHFuncInfo {
>    DenseMap<const Instruction *, int> EHPadStateMap;
>    DenseMap<const FuncletPadInst *, int> FuncletBaseStateMap;
>    DenseMap<const InvokeInst *, int> InvokeStateMap;
> -  DenseMap<const CatchReturnInst *, const BasicBlock *>
> -      CatchRetSuccessorColorMap;
>    DenseMap<MCSymbol *, std::pair<int, MCSymbol *>> LabelToStateMap;
>    SmallVector<CxxUnwindMapEntry, 4> CxxUnwindMap;
>    SmallVector<WinEHTryBlockMapEntry, 4> TryBlockMap;
> @@ -125,8 +123,5 @@ void calculateSEHStateNumbers(const Func
>                                WinEHFuncInfo &FuncInfo);
>  
>  void calculateClrEHStateNumbers(const Function *Fn, WinEHFuncInfo &FuncInfo);
> -
> -void calculateCatchReturnSuccessorColors(const Function *Fn,
> -                                         WinEHFuncInfo &FuncInfo);
>  }
>  #endif // LLVM_CODEGEN_WINEHFUNCINFO_H
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp?rev=256965&r1=256964&r2=256965&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp Wed Jan  6 13:26:30 2016
> @@ -271,6 +271,8 @@ void FunctionLoweringInfo::set(const Fun
>      }
>    }
>  
> +  WinEHFuncInfo &EHInfo = *MF->getWinEHFuncInfo();
> +
>    // Mark landing pad blocks.
>    SmallVector<const LandingPadInst *, 4> LPads;
>    for (BB = Fn->begin(); BB != EB; ++BB) {
> @@ -289,7 +291,6 @@ void FunctionLoweringInfo::set(const Fun
>      return;
>  
>    // Calculate state numbers if we haven't already.
> -  WinEHFuncInfo &EHInfo = *MF->getWinEHFuncInfo();

Why are you moving this call before the early return? Ubsan complains
that we're binding a nullptr to a reference now, since
MF->getWinEHFuncInfo() will be null when !isFuncletEHPersonality(...)

>    if (Personality == EHPersonality::MSVC_CXX)
>      calculateWinCXXEHStateNumbers(&fn, EHInfo);
>    else if (isAsynchronousEHPersonality(Personality))
> @@ -297,8 +298,6 @@ void FunctionLoweringInfo::set(const Fun
>    else if (Personality == EHPersonality::CoreCLR)
>      calculateClrEHStateNumbers(&fn, EHInfo);
>  
> -  calculateCatchReturnSuccessorColors(&fn, EHInfo);
> -
>    // Map all BB references in the WinEH data to MBBs.
>    for (WinEHTryBlockMapEntry &TBME : EHInfo.TryBlockMap) {
>      for (WinEHHandlerType &H : TBME.HandlerArray) {
>
> Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp?rev=256965&r1=256964&r2=256965&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (original)
> +++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp Wed Jan  6 13:26:30 2016
> @@ -1205,8 +1205,13 @@ void SelectionDAGBuilder::visitCatchRet(
>    // Figure out the funclet membership for the catchret's successor.
>    // This will be used by the FuncletLayout pass to determine how to order the
>    // BB's.
> -  WinEHFuncInfo *EHInfo = DAG.getMachineFunction().getWinEHFuncInfo();
> -  const BasicBlock *SuccessorColor = EHInfo->CatchRetSuccessorColorMap[&I];
> +  // A 'catchret' returns to the outer scope's color.
> +  Value *ParentPad = I.getParentPad();
> +  const BasicBlock *SuccessorColor;
> +  if (isa<ConstantTokenNone>(ParentPad))
> +    SuccessorColor = &FuncInfo.Fn->getEntryBlock();
> +  else
> +    SuccessorColor = cast<Instruction>(ParentPad)->getParent();
>    assert(SuccessorColor && "No parent funclet for catchret!");
>    MachineBasicBlock *SuccessorColorMBB = FuncInfo.MBBMap[SuccessorColor];
>    assert(SuccessorColorMBB && "No MBB for SuccessorColor!");
>
> Modified: llvm/trunk/lib/CodeGen/WinEHPrepare.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/WinEHPrepare.cpp?rev=256965&r1=256964&r2=256965&view=diff
> ==============================================================================
> --- llvm/trunk/lib/CodeGen/WinEHPrepare.cpp (original)
> +++ llvm/trunk/lib/CodeGen/WinEHPrepare.cpp Wed Jan  6 13:26:30 2016
> @@ -664,24 +664,6 @@ void WinEHPrepare::colorFunclets(Functio
>    }
>  }
>  
> -void llvm::calculateCatchReturnSuccessorColors(const Function *Fn,
> -                                               WinEHFuncInfo &FuncInfo) {
> -  for (const BasicBlock &BB : *Fn) {
> -    const auto *CatchRet = dyn_cast<CatchReturnInst>(BB.getTerminator());
> -    if (!CatchRet)
> -      continue;
> -    // A 'catchret' returns to the outer scope's color.
> -    Value *ParentPad = CatchRet->getParentPad();
> -    const BasicBlock *Color;
> -    if (isa<ConstantTokenNone>(ParentPad))
> -      Color = &Fn->getEntryBlock();
> -    else
> -      Color = cast<Instruction>(ParentPad)->getParent();
> -    // Record the catchret successor's funclet membership.
> -    FuncInfo.CatchRetSuccessorColorMap[CatchRet] = Color;
> -  }
> -}
> -
>  void WinEHPrepare::demotePHIsOnFunclets(Function &F) {
>    // Strip PHI nodes off of EH pads.
>    SmallVector<PHINode *, 16> PHINodes;
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits


More information about the llvm-commits mailing list