diff options
author | Reid Kleckner <rnk@google.com> | 2015-09-16 20:16:27 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2015-09-16 20:16:27 +0000 |
commit | b005d281c36c09eda1b85db59e2c183ed5defca5 (patch) | |
tree | 8263838e6c8079eceaccb60c61aa8c393205aa95 /llvm/lib/CodeGen/WinEHPrepare.cpp | |
parent | 10aa77032de43681231e81ee3f2e7d232b16dc9c (diff) | |
download | llvm-b005d281c36c09eda1b85db59e2c183ed5defca5.zip llvm-b005d281c36c09eda1b85db59e2c183ed5defca5.tar.gz llvm-b005d281c36c09eda1b85db59e2c183ed5defca5.tar.bz2 |
[WinEH] Pull Adjectives and CatchObj out of the catchpad arg list
Clang now passes the adjectives as an argument to catchpad.
Getting the CatchObj working is simply a matter of threading another
static alloca through codegen, first as an alloca, then as a frame
index, and finally as a frame offset.
llvm-svn: 247844
Diffstat (limited to 'llvm/lib/CodeGen/WinEHPrepare.cpp')
-rw-r--r-- | llvm/lib/CodeGen/WinEHPrepare.cpp | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/llvm/lib/CodeGen/WinEHPrepare.cpp b/llvm/lib/CodeGen/WinEHPrepare.cpp index 8ba6f5e..fefb444 100644 --- a/llvm/lib/CodeGen/WinEHPrepare.cpp +++ b/llvm/lib/CodeGen/WinEHPrepare.cpp @@ -2622,22 +2622,17 @@ static void addTryBlockMapEntry(WinEHFuncInfo &FuncInfo, int TryLow, for (const CatchPadInst *CPI : Handlers) { WinEHHandlerType HT; Constant *TypeInfo = cast<Constant>(CPI->getArgOperand(0)); - if (TypeInfo->isNullValue()) { - HT.Adjectives = 0x40; + if (TypeInfo->isNullValue()) HT.TypeDescriptor = nullptr; - } else { - auto *GV = cast<GlobalVariable>(TypeInfo->stripPointerCasts()); - // Selectors are always pointers to GlobalVariables with 'struct' type. - // The struct has two fields, adjectives and a type descriptor. - auto *CS = cast<ConstantStruct>(GV->getInitializer()); - HT.Adjectives = - cast<ConstantInt>(CS->getAggregateElement(0U))->getZExtValue(); - HT.TypeDescriptor = - cast<GlobalVariable>(CS->getAggregateElement(1)->stripPointerCasts()); - } + else + HT.TypeDescriptor = cast<GlobalVariable>(TypeInfo->stripPointerCasts()); + HT.Adjectives = cast<ConstantInt>(CPI->getArgOperand(1))->getZExtValue(); HT.Handler = CPI->getNormalDest(); - // FIXME: Pass CPI->getArgOperand(1). - HT.CatchObjRecoverIdx = -1; + HT.CatchObjRecoverIdx = -2; + if (isa<ConstantPointerNull>(CPI->getArgOperand(2))) + HT.CatchObj.Alloca = nullptr; + else + HT.CatchObj.Alloca = cast<AllocaInst>(CPI->getArgOperand(2)); TBME.HandlerArray.push_back(HT); } FuncInfo.TryBlockMap.push_back(TBME); @@ -2713,6 +2708,7 @@ void WinEHNumbering::createTryBlockMapEntry(int TryLow, int TryHigh, } HT.Handler = cast<Function>(CH->getHandlerBlockOrFunc()); HT.CatchObjRecoverIdx = CH->getExceptionVarIndex(); + HT.CatchObj.Alloca = nullptr; TBME.HandlerArray.push_back(HT); } FuncInfo.TryBlockMap.push_back(TBME); |