[SEH] Implement filter capturing in CodeGen
While capturing filters aren't very common, we'd like to outline __finally blocks in the frontend to simplify -O0 EH preparation and reduce code size. Finally blocks are usually have captures, and this is the first step towards that. Currently we don't support capturing 'this' or VLAs. Reviewers: majnemer Differential Revision: http://reviews.llvm.org/D8825 llvm-svn: 234261
This commit is contained in:
@@ -279,6 +279,20 @@ void CodeGenFunction::FinishFunction(SourceLocation EndLoc) {
|
||||
Builder.ClearInsertionPoint();
|
||||
}
|
||||
|
||||
// If some of our locals escaped, insert a call to llvm.frameescape in the
|
||||
// entry block.
|
||||
if (!EscapedLocals.empty()) {
|
||||
// Invert the map from local to index into a simple vector. There should be
|
||||
// no holes.
|
||||
SmallVector<llvm::Value *, 4> EscapeArgs;
|
||||
EscapeArgs.resize(EscapedLocals.size());
|
||||
for (auto &Pair : EscapedLocals)
|
||||
EscapeArgs[Pair.second] = Pair.first;
|
||||
llvm::Function *FrameEscapeFn = llvm::Intrinsic::getDeclaration(
|
||||
&CGM.getModule(), llvm::Intrinsic::frameescape);
|
||||
CGBuilderTy(AllocaInsertPt).CreateCall(FrameEscapeFn, EscapeArgs);
|
||||
}
|
||||
|
||||
// Remove the AllocaInsertPt instruction, which is just a convenience for us.
|
||||
llvm::Instruction *Ptr = AllocaInsertPt;
|
||||
AllocaInsertPt = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user