[PATCH] D12108: [WinEH] Require token linkage in EH pad/ret signatures

Joseph Tremoulet via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 18 17:30:11 PDT 2015


JosephTremoulet added a comment.

Ok, if we can disallow undef that will certainly simplify this.

I'm not sure what to do about the llvm-as case, though.  I debugged into it, and it is indeed a forward reference.  What happens is we process this in exception.ll:

    catchret %cbv to label %exit
  ...
    %cbv = catchpad [i7 4] to label %bb unwind label %bb3

and then we go to construct the `CatchReturnInst` with this code in LLParser.cpp:

  bool LLParser::ParseCatchRet(Instruction *&Inst, PerFunctionState &PFS) {
    Value *CatchPad = nullptr;
  
    if (ParseValue(Type::getTokenTy(Context), CatchPad, PFS))
      return true;
  
    BasicBlock *BB;
    if (ParseToken(lltok::kw_to, "expected 'to' in catchret") ||
        ParseTypeAndBasicBlock(BB, PFS))
        return true;
  
    Inst = CatchReturnInst::Create(CatchPad, BB);

that call to `ParseValue` eventually winds up in this code in `PerFunctionState::GetVal`:

  // Otherwise, create a new forward reference for this value and remember it.
  Value *FwdVal;
  if (Ty->isLabelTy())
    FwdVal = BasicBlock::Create(F.getContext(), Name, &F);
  else
    FwdVal = new Argument(Ty, Name);

so we need a way to create a `CatchReturnInst` with an `Argument`.  Should I just `reinterpret_cast` the `Argument *` to a `CatchPadInst *` in LLParser?  Maybe tighten the accessor and the public Create method (and IRBuilder's method) but leave the private constructors typed as `Value *` , make `LLParser` a friend class, and have the parser call the private constructor directly?  The bitcode reader has the same issue btw (`BitcodeReader::parseFunctionBody` calls `geValue` which gets down into `BitcodeReaderValueList::getValueFwdRef` that creates an `Argument`).


http://reviews.llvm.org/D12108





More information about the llvm-commits mailing list