summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGBlocks.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2017-10-26 20:08:52 +0000
committerAdrian Prantl <aprantl@apple.com>2017-10-26 20:08:52 +0000
commit356347b58d18b5b7984fbc5487532f49c7e98237 (patch)
treeb563889edd0d291d255052af0d797611889742a8 /clang/lib/CodeGen/CGBlocks.cpp
parent86cf0856ae78c1d4e31a19b7fa0ab957379bee03 (diff)
downloadbcm5719-llvm-356347b58d18b5b7984fbc5487532f49c7e98237.tar.gz
bcm5719-llvm-356347b58d18b5b7984fbc5487532f49c7e98237.zip
Simplify codegen and debug info generation for block context parameters.
The exisiting code goes out of its way to put block parameters into an alloca only at -O0, and then describes the funciton argument with a dbg.declare, which is undocumented in the LLVM-CFE contract and does not actually behave as intended after LLVM r642022. This patch just generates the alloca unconditionally, the mem2reg pass will eliminate it at -O1 and up anyway and points the dbg.declare to the alloca as intended (which mem2reg will then correctly rewrite into a dbg.value). This reapplies r316684 with some dead code removed. rdar://problem/35043980 Differential Revision: https://reviews.llvm.org/D39305 llvm-svn: 316689
Diffstat (limited to 'clang/lib/CodeGen/CGBlocks.cpp')
-rw-r--r--clang/lib/CodeGen/CGBlocks.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp
index 2915dabe541..0bd9d7c506c 100644
--- a/clang/lib/CodeGen/CGBlocks.cpp
+++ b/clang/lib/CodeGen/CGBlocks.cpp
@@ -1293,20 +1293,17 @@ void CodeGenFunction::setBlockContextParameter(const ImplicitParamDecl *D,
llvm::Value *arg) {
assert(BlockInfo && "not emitting prologue of block invocation function?!");
- llvm::Value *localAddr = nullptr;
- if (CGM.getCodeGenOpts().OptimizationLevel == 0) {
- // Allocate a stack slot to let the debug info survive the RA.
- Address alloc = CreateMemTemp(D->getType(), D->getName() + ".addr");
- Builder.CreateStore(arg, alloc);
- localAddr = Builder.CreateLoad(alloc);
- }
-
+ // Allocate a stack slot like for any local variable to guarantee optimal
+ // debug info at -O0. The mem2reg pass will eliminate it when optimizing.
+ Address alloc = CreateMemTemp(D->getType(), D->getName() + ".addr");
+ Builder.CreateStore(arg, alloc);
if (CGDebugInfo *DI = getDebugInfo()) {
if (CGM.getCodeGenOpts().getDebugInfo() >=
codegenoptions::LimitedDebugInfo) {
DI->setLocation(D->getLocation());
- DI->EmitDeclareOfBlockLiteralArgVariable(*BlockInfo, arg, argNum,
- localAddr, Builder);
+ DI->EmitDeclareOfBlockLiteralArgVariable(
+ *BlockInfo, D->getName(), argNum,
+ cast<llvm::AllocaInst>(alloc.getPointer()), Builder);
}
}
OpenPOWER on IntegriCloud