Revert "Simplify codegen and debug info generation for block context parameters."
This reverts commit r316684 while investigating buildbot breakage.
llvm-svn: 316686
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 3e4acd2..a73e4a9 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -3694,9 +3694,9 @@
}
void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block,
- StringRef Name,
+ llvm::Value *Arg,
unsigned ArgNo,
- llvm::AllocaInst *Alloca,
+ llvm::Value *LocalAddr,
CGBuilderTy &Builder) {
assert(DebugKind >= codegenoptions::LimitedDebugInfo);
ASTContext &C = CGM.getContext();
@@ -3828,11 +3828,19 @@
// Create the descriptor for the parameter.
auto *debugVar = DBuilder.createParameterVariable(
- scope, Name, ArgNo, tunit, line, type,
+ scope, Arg->getName(), ArgNo, tunit, line, type,
CGM.getLangOpts().Optimize, flags);
+ if (LocalAddr) {
+ // Insert an llvm.dbg.value into the current block.
+ DBuilder.insertDbgValueIntrinsic(
+ LocalAddr, debugVar, DBuilder.createExpression(),
+ llvm::DebugLoc::get(line, column, scope, CurInlinedAt),
+ Builder.GetInsertBlock());
+ }
+
// Insert an llvm.dbg.declare into the current block.
- DBuilder.insertDeclare(Alloca, debugVar, DBuilder.createExpression(),
+ DBuilder.insertDeclare(Arg, debugVar, DBuilder.createExpression(),
llvm::DebugLoc::get(line, column, scope, CurInlinedAt),
Builder.GetInsertBlock());
}