@@ -4749,32 +4749,20 @@ void CodeGenFunction::EmitOMPTaskBasedDirective(
4749
4749
if (CGF.CGM .getCodeGenOpts ().hasReducedDebugInfo ())
4750
4750
(void )DI->EmitDeclareOfAutoVariable (SharedVar, ContextValue,
4751
4751
CGF.Builder , false );
4752
+ llvm::Instruction &Last = CGF.Builder .GetInsertBlock ()->back ();
4752
4753
// Get the call dbg.declare instruction we just created and update
4753
4754
// 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)) {
4756
4756
SmallVector<uint64_t , 8 > Ops;
4757
4757
// Add offset to the base address if non zero.
4758
4758
if (Offset) {
4759
4759
Ops.push_back (llvm::dwarf::DW_OP_plus_uconst);
4760
4760
Ops.push_back (Offset);
4761
4761
}
4762
4762
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));
4778
4766
}
4779
4767
}
4780
4768
}
0 commit comments