Skip to content

Commit 92122b0

Browse files
committed
Revert "[RemoveDIs] Update Clang front end to handle DbgRecords (#84756)"
This reverts commit 6f60ad7. Buildbots: https://lab.llvm.org/buildbot/#/builders/196/builds/47206
1 parent 3e4170a commit 92122b0

File tree

3 files changed

+7
-22
lines changed

3 files changed

+7
-22
lines changed

clang/lib/CodeGen/CGBlocks.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1540,10 +1540,7 @@ llvm::Function *CodeGenFunction::GenerateBlockFunction(
15401540
llvm::BasicBlock *resume = Builder.GetInsertBlock();
15411541

15421542
// Go back to the entry.
1543-
if (entry_ptr->getNextNonDebugInstruction())
1544-
entry_ptr = entry_ptr->getNextNonDebugInstruction()->getIterator();
1545-
else
1546-
entry_ptr = entry->end();
1543+
++entry_ptr;
15471544
Builder.SetInsertPoint(entry, entry_ptr);
15481545

15491546
// Emit debug information for all the DeclRefExprs.

clang/lib/CodeGen/CGStmtOpenMP.cpp

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4749,32 +4749,20 @@ void CodeGenFunction::EmitOMPTaskBasedDirective(
47494749
if (CGF.CGM.getCodeGenOpts().hasReducedDebugInfo())
47504750
(void)DI->EmitDeclareOfAutoVariable(SharedVar, ContextValue,
47514751
CGF.Builder, false);
4752+
llvm::Instruction &Last = CGF.Builder.GetInsertBlock()->back();
47524753
// Get the call dbg.declare instruction we just created and update
47534754
// its DIExpression to add offset to base address.
4754-
auto UpdateExpr = [](llvm::LLVMContext &Ctx, auto *Declare,
4755-
unsigned Offset) {
4755+
if (auto DDI = dyn_cast<llvm::DbgVariableIntrinsic>(&Last)) {
47564756
SmallVector<uint64_t, 8> Ops;
47574757
// Add offset to the base address if non zero.
47584758
if (Offset) {
47594759
Ops.push_back(llvm::dwarf::DW_OP_plus_uconst);
47604760
Ops.push_back(Offset);
47614761
}
47624762
Ops.push_back(llvm::dwarf::DW_OP_deref);
4763-
Declare->setExpression(llvm::DIExpression::get(Ctx, Ops));
4764-
};
4765-
llvm::Instruction &Last = CGF.Builder.GetInsertBlock()->back();
4766-
if (auto DDI = dyn_cast<llvm::DbgVariableIntrinsic>(&Last))
4767-
UpdateExpr(DDI->getContext(), DDI, Offset);
4768-
// If we're emitting using the new debug info format into a block
4769-
// without a terminator, the record will be "trailing".
4770-
assert(!Last.isTerminator() && "unexpected terminator");
4771-
if (auto *Marker =
4772-
CGF.Builder.GetInsertBlock()->getTrailingDPValues()) {
4773-
for (llvm::DPValue &DPV : llvm::reverse(
4774-
llvm::DPValue::filter(Marker->getDbgValueRange()))) {
4775-
UpdateExpr(Last.getContext(), &DPV, Offset);
4776-
break;
4777-
}
4763+
auto &Ctx = DDI->getContext();
4764+
llvm::DIExpression *DIExpr = llvm::DIExpression::get(Ctx, Ops);
4765+
Last.setOperand(2, llvm::MetadataAsValue::get(Ctx, DIExpr));
47784766
}
47794767
}
47804768
}

clang/test/CodeGenObjC/debug-info-blocks.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55

66
// CHECK: define {{.*}}_block_invoke
77
// CHECK: store ptr %.block_descriptor, ptr %[[ALLOCA:block.addr]], align
8-
// CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %d, metadata ![[D:[0-9]+]], metadata !{{.*}})
98
// CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %[[ALLOCA]], metadata ![[SELF:[0-9]+]], metadata !{{.*}})
9+
// CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %d, metadata ![[D:[0-9]+]], metadata !{{.*}})
1010

1111
// Test that we do emit scope info for the helper functions, and that the
1212
// parameters to these functions are marked as artificial (so the debugger

0 commit comments

Comments
 (0)