[clang] [RemoveDIs] Update Clang front end to handle DbgRecords (PR #84756)
https://github.com/OCHyams closed https://github.com/llvm/llvm-project/pull/84756 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RemoveDIs] Update Clang front end to handle DbgRecords (PR #84756)
https://github.com/SLTozer approved this pull request. It's been a bit without any comments, probably safe now to land this. https://github.com/llvm/llvm-project/pull/84756 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RemoveDIs] Update Clang front end to handle DbgRecords (PR #84756)
OCHyams wrote: > Maybe wants someone with more frontend knowledge to chime in, but all SGTM. @adrian-prantl are you able to suggest anyone that might be able to take a look at this (part of this touches some Objective-C code+test) - we're not overly familiar with front end code. https://github.com/llvm/llvm-project/pull/84756 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RemoveDIs] Update Clang front end to handle DbgRecords (PR #84756)
https://github.com/OCHyams updated https://github.com/llvm/llvm-project/pull/84756 >From 8b37020a48b8145ad9d7deb288b9f8a3ee3a9a9b Mon Sep 17 00:00:00 2001 From: Orlando Cazalet-Hyams Date: Sat, 9 Mar 2024 13:10:05 + Subject: [PATCH 1/3] clang: insertbefore non-debug for removeDIs stability fixes debug-info-blocks.m in both modes --- clang/lib/CodeGen/CGBlocks.cpp | 5 - clang/test/CodeGenObjC/debug-info-blocks.m | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index 0cbace7b7f7bbd..768b786c6426df 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -1540,7 +1540,10 @@ llvm::Function *CodeGenFunction::GenerateBlockFunction( llvm::BasicBlock *resume = Builder.GetInsertBlock(); // Go back to the entry. - ++entry_ptr; + if (entry_ptr->getNextNonDebugInstruction()) +entry_ptr = entry_ptr->getNextNonDebugInstruction()->getIterator(); + else +entry_ptr = entry->end(); Builder.SetInsertPoint(entry, entry_ptr); // Emit debug information for all the DeclRefExprs. diff --git a/clang/test/CodeGenObjC/debug-info-blocks.m b/clang/test/CodeGenObjC/debug-info-blocks.m index 14b29f222fbe8e..59171da016da1e 100644 --- a/clang/test/CodeGenObjC/debug-info-blocks.m +++ b/clang/test/CodeGenObjC/debug-info-blocks.m @@ -5,8 +5,8 @@ // CHECK: define {{.*}}_block_invoke // CHECK: store ptr %.block_descriptor, ptr %[[ALLOCA:block.addr]], align -// CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %[[ALLOCA]], metadata ![[SELF:[0-9]+]], metadata !{{.*}}) // CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %d, metadata ![[D:[0-9]+]], metadata !{{.*}}) +// CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %[[ALLOCA]], metadata ![[SELF:[0-9]+]], metadata !{{.*}}) // Test that we do emit scope info for the helper functions, and that the // parameters to these functions are marked as artificial (so the debugger >From efabe4b06f38aaf3aed8cf02c97f566652ba5f15 Mon Sep 17 00:00:00 2001 From: Orlando Cazalet-Hyams Date: Sat, 9 Mar 2024 13:40:30 + Subject: [PATCH 2/3] openmp update DbgRecords Fixed OpenMP/debug_task_shared.c --- clang/lib/CodeGen/CGStmtOpenMP.cpp | 22 +- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 3fbd2e03eb61df..5c6a3b8e001730 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -4746,10 +4746,10 @@ void CodeGenFunction::EmitOMPTaskBasedDirective( if (CGF.CGM.getCodeGenOpts().hasReducedDebugInfo()) (void)DI->EmitDeclareOfAutoVariable(SharedVar, ContextValue, CGF.Builder, false); - llvm::Instruction &Last = CGF.Builder.GetInsertBlock()->back(); // Get the call dbg.declare instruction we just created and update // its DIExpression to add offset to base address. - if (auto DDI = dyn_cast(&Last)) { + auto UpdateExpr = [](llvm::LLVMContext &Ctx, auto *DDI, + unsigned Offset) { SmallVector Ops; // Add offset to the base address if non zero. if (Offset) { @@ -4757,9 +4757,21 @@ void CodeGenFunction::EmitOMPTaskBasedDirective( Ops.push_back(Offset); } Ops.push_back(llvm::dwarf::DW_OP_deref); -auto &Ctx = DDI->getContext(); -llvm::DIExpression *DIExpr = llvm::DIExpression::get(Ctx, Ops); -Last.setOperand(2, llvm::MetadataAsValue::get(Ctx, DIExpr)); +DDI->setExpression(llvm::DIExpression::get(Ctx, Ops)); + }; + llvm::Instruction &Last = CGF.Builder.GetInsertBlock()->back(); + if (auto DDI = dyn_cast(&Last)) +UpdateExpr(DDI->getContext(), DDI, Offset); + // If we're emitting using the new debug info format into a block + // without a terminator, the record will be "trailing". + assert(!Last.isTerminator() && "unexpected terminator"); + if (auto *Marker = + CGF.Builder.GetInsertBlock()->getTrailingDPValues()) { +for (llvm::DPValue &DPV : llvm::reverse( + llvm::DPValue::filter(Marker->getDbgValueRange( { + UpdateExpr(Last.getContext(), &DPV, Offset); + break; +} } } } >From 79fc0ea1a68c623c1207509ab00f3bd8a6c16961 Mon Sep 17 00:00:00 2001 From: Orlando Cazalet-Hyams Date: Mon, 11 Mar 2024 12:07:32 + Subject: [PATCH 3/3] rename variable --- clang/lib/CodeGen/CGStmtOpenMP.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 5c6a3b8e001730..20c80b6bc235e4 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/
[clang] [RemoveDIs] Update Clang front end to handle DbgRecords (PR #84756)
@@ -4746,20 +4746,32 @@ void CodeGenFunction::EmitOMPTaskBasedDirective( if (CGF.CGM.getCodeGenOpts().hasReducedDebugInfo()) (void)DI->EmitDeclareOfAutoVariable(SharedVar, ContextValue, CGF.Builder, false); - llvm::Instruction &Last = CGF.Builder.GetInsertBlock()->back(); // Get the call dbg.declare instruction we just created and update // its DIExpression to add offset to base address. - if (auto DDI = dyn_cast(&Last)) { + auto UpdateExpr = [](llvm::LLVMContext &Ctx, auto *DDI, SLTozer wrote: Super nit, but in situations like this I prefer to change things like `DDI` to `Declare`; subjective, so non-blocking. https://github.com/llvm/llvm-project/pull/84756 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RemoveDIs] Update Clang front end to handle DbgRecords (PR #84756)
https://github.com/SLTozer commented: Maybe wants someone with more frontend knowledge to chime in, but all SGTM. https://github.com/llvm/llvm-project/pull/84756 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RemoveDIs] Update Clang front end to handle DbgRecords (PR #84756)
https://github.com/SLTozer edited https://github.com/llvm/llvm-project/pull/84756 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RemoveDIs] Update Clang front end to handle DbgRecords (PR #84756)
github-actions[bot] wrote: :warning: C/C++ code formatter, clang-format found issues in your code. :warning: You can test this locally with the following command: ``bash git-clang-format --diff e77f5fe889909df3508fd929f2636a0ac211877a efabe4b06f38aaf3aed8cf02c97f566652ba5f15 -- clang/lib/CodeGen/CGBlocks.cpp clang/lib/CodeGen/CGStmtOpenMP.cpp `` View the diff from clang-format here. ``diff diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index 768b786c64..ad0b50d799 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -1542,7 +1542,7 @@ llvm::Function *CodeGenFunction::GenerateBlockFunction( // Go back to the entry. if (entry_ptr->getNextNonDebugInstruction()) entry_ptr = entry_ptr->getNextNonDebugInstruction()->getIterator(); - else + else entry_ptr = entry->end(); Builder.SetInsertPoint(entry, entry_ptr); `` https://github.com/llvm/llvm-project/pull/84756 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RemoveDIs] Update Clang front end to handle DbgRecords (PR #84756)
llvmbot wrote: @llvm/pr-subscribers-clang-codegen Author: Orlando Cazalet-Hyams (OCHyams) Changes This patch fixes problems that pop up when clang emits DbgRecords instead of debug intrinsics. Note: this doesn't mean clang is emitting DbgRecords yet, because the modules it creates are still always in the old debug mode. That will come in a future patch. Depends on #84739 --- Full diff: https://github.com/llvm/llvm-project/pull/84756.diff 3 Files Affected: - (modified) clang/lib/CodeGen/CGBlocks.cpp (+4-1) - (modified) clang/lib/CodeGen/CGStmtOpenMP.cpp (+17-5) - (modified) clang/test/CodeGenObjC/debug-info-blocks.m (+1-1) ``diff diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index 0cbace7b7f7bbd..768b786c6426df 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -1540,7 +1540,10 @@ llvm::Function *CodeGenFunction::GenerateBlockFunction( llvm::BasicBlock *resume = Builder.GetInsertBlock(); // Go back to the entry. - ++entry_ptr; + if (entry_ptr->getNextNonDebugInstruction()) +entry_ptr = entry_ptr->getNextNonDebugInstruction()->getIterator(); + else +entry_ptr = entry->end(); Builder.SetInsertPoint(entry, entry_ptr); // Emit debug information for all the DeclRefExprs. diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 3fbd2e03eb61df..5c6a3b8e001730 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -4746,10 +4746,10 @@ void CodeGenFunction::EmitOMPTaskBasedDirective( if (CGF.CGM.getCodeGenOpts().hasReducedDebugInfo()) (void)DI->EmitDeclareOfAutoVariable(SharedVar, ContextValue, CGF.Builder, false); - llvm::Instruction &Last = CGF.Builder.GetInsertBlock()->back(); // Get the call dbg.declare instruction we just created and update // its DIExpression to add offset to base address. - if (auto DDI = dyn_cast(&Last)) { + auto UpdateExpr = [](llvm::LLVMContext &Ctx, auto *DDI, + unsigned Offset) { SmallVector Ops; // Add offset to the base address if non zero. if (Offset) { @@ -4757,9 +4757,21 @@ void CodeGenFunction::EmitOMPTaskBasedDirective( Ops.push_back(Offset); } Ops.push_back(llvm::dwarf::DW_OP_deref); -auto &Ctx = DDI->getContext(); -llvm::DIExpression *DIExpr = llvm::DIExpression::get(Ctx, Ops); -Last.setOperand(2, llvm::MetadataAsValue::get(Ctx, DIExpr)); +DDI->setExpression(llvm::DIExpression::get(Ctx, Ops)); + }; + llvm::Instruction &Last = CGF.Builder.GetInsertBlock()->back(); + if (auto DDI = dyn_cast(&Last)) +UpdateExpr(DDI->getContext(), DDI, Offset); + // If we're emitting using the new debug info format into a block + // without a terminator, the record will be "trailing". + assert(!Last.isTerminator() && "unexpected terminator"); + if (auto *Marker = + CGF.Builder.GetInsertBlock()->getTrailingDPValues()) { +for (llvm::DPValue &DPV : llvm::reverse( + llvm::DPValue::filter(Marker->getDbgValueRange( { + UpdateExpr(Last.getContext(), &DPV, Offset); + break; +} } } } diff --git a/clang/test/CodeGenObjC/debug-info-blocks.m b/clang/test/CodeGenObjC/debug-info-blocks.m index 14b29f222fbe8e..59171da016da1e 100644 --- a/clang/test/CodeGenObjC/debug-info-blocks.m +++ b/clang/test/CodeGenObjC/debug-info-blocks.m @@ -5,8 +5,8 @@ // CHECK: define {{.*}}_block_invoke // CHECK: store ptr %.block_descriptor, ptr %[[ALLOCA:block.addr]], align -// CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %[[ALLOCA]], metadata ![[SELF:[0-9]+]], metadata !{{.*}}) // CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %d, metadata ![[D:[0-9]+]], metadata !{{.*}}) +// CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %[[ALLOCA]], metadata ![[SELF:[0-9]+]], metadata !{{.*}}) // Test that we do emit scope info for the helper functions, and that the // parameters to these functions are marked as artificial (so the debugger `` https://github.com/llvm/llvm-project/pull/84756 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RemoveDIs] Update Clang front end to handle DbgRecords (PR #84756)
llvmbot wrote: @llvm/pr-subscribers-clang Author: Orlando Cazalet-Hyams (OCHyams) Changes This patch fixes problems that pop up when clang emits DbgRecords instead of debug intrinsics. Note: this doesn't mean clang is emitting DbgRecords yet, because the modules it creates are still always in the old debug mode. That will come in a future patch. Depends on #84739 --- Full diff: https://github.com/llvm/llvm-project/pull/84756.diff 3 Files Affected: - (modified) clang/lib/CodeGen/CGBlocks.cpp (+4-1) - (modified) clang/lib/CodeGen/CGStmtOpenMP.cpp (+17-5) - (modified) clang/test/CodeGenObjC/debug-info-blocks.m (+1-1) ``diff diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index 0cbace7b7f7bbd..768b786c6426df 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -1540,7 +1540,10 @@ llvm::Function *CodeGenFunction::GenerateBlockFunction( llvm::BasicBlock *resume = Builder.GetInsertBlock(); // Go back to the entry. - ++entry_ptr; + if (entry_ptr->getNextNonDebugInstruction()) +entry_ptr = entry_ptr->getNextNonDebugInstruction()->getIterator(); + else +entry_ptr = entry->end(); Builder.SetInsertPoint(entry, entry_ptr); // Emit debug information for all the DeclRefExprs. diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 3fbd2e03eb61df..5c6a3b8e001730 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -4746,10 +4746,10 @@ void CodeGenFunction::EmitOMPTaskBasedDirective( if (CGF.CGM.getCodeGenOpts().hasReducedDebugInfo()) (void)DI->EmitDeclareOfAutoVariable(SharedVar, ContextValue, CGF.Builder, false); - llvm::Instruction &Last = CGF.Builder.GetInsertBlock()->back(); // Get the call dbg.declare instruction we just created and update // its DIExpression to add offset to base address. - if (auto DDI = dyn_cast(&Last)) { + auto UpdateExpr = [](llvm::LLVMContext &Ctx, auto *DDI, + unsigned Offset) { SmallVector Ops; // Add offset to the base address if non zero. if (Offset) { @@ -4757,9 +4757,21 @@ void CodeGenFunction::EmitOMPTaskBasedDirective( Ops.push_back(Offset); } Ops.push_back(llvm::dwarf::DW_OP_deref); -auto &Ctx = DDI->getContext(); -llvm::DIExpression *DIExpr = llvm::DIExpression::get(Ctx, Ops); -Last.setOperand(2, llvm::MetadataAsValue::get(Ctx, DIExpr)); +DDI->setExpression(llvm::DIExpression::get(Ctx, Ops)); + }; + llvm::Instruction &Last = CGF.Builder.GetInsertBlock()->back(); + if (auto DDI = dyn_cast(&Last)) +UpdateExpr(DDI->getContext(), DDI, Offset); + // If we're emitting using the new debug info format into a block + // without a terminator, the record will be "trailing". + assert(!Last.isTerminator() && "unexpected terminator"); + if (auto *Marker = + CGF.Builder.GetInsertBlock()->getTrailingDPValues()) { +for (llvm::DPValue &DPV : llvm::reverse( + llvm::DPValue::filter(Marker->getDbgValueRange( { + UpdateExpr(Last.getContext(), &DPV, Offset); + break; +} } } } diff --git a/clang/test/CodeGenObjC/debug-info-blocks.m b/clang/test/CodeGenObjC/debug-info-blocks.m index 14b29f222fbe8e..59171da016da1e 100644 --- a/clang/test/CodeGenObjC/debug-info-blocks.m +++ b/clang/test/CodeGenObjC/debug-info-blocks.m @@ -5,8 +5,8 @@ // CHECK: define {{.*}}_block_invoke // CHECK: store ptr %.block_descriptor, ptr %[[ALLOCA:block.addr]], align -// CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %[[ALLOCA]], metadata ![[SELF:[0-9]+]], metadata !{{.*}}) // CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %d, metadata ![[D:[0-9]+]], metadata !{{.*}}) +// CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %[[ALLOCA]], metadata ![[SELF:[0-9]+]], metadata !{{.*}}) // Test that we do emit scope info for the helper functions, and that the // parameters to these functions are marked as artificial (so the debugger `` https://github.com/llvm/llvm-project/pull/84756 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RemoveDIs] Update Clang front end to handle DbgRecords (PR #84756)
https://github.com/OCHyams edited https://github.com/llvm/llvm-project/pull/84756 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang] [RemoveDIs] Update Clang front end to handle DbgRecords (PR #84756)
https://github.com/OCHyams created https://github.com/llvm/llvm-project/pull/84756 This patch fixes problems that pop up when clang emits DbgRecords instead of debug intrinsics. Note: this doesn't mean clang is emitting DbgRecords yet, because the modules it creates are still always in the old debug mode. That will come in a future patch. >From 8b37020a48b8145ad9d7deb288b9f8a3ee3a9a9b Mon Sep 17 00:00:00 2001 From: Orlando Cazalet-Hyams Date: Sat, 9 Mar 2024 13:10:05 + Subject: [PATCH 1/2] clang: insertbefore non-debug for removeDIs stability fixes debug-info-blocks.m in both modes --- clang/lib/CodeGen/CGBlocks.cpp | 5 - clang/test/CodeGenObjC/debug-info-blocks.m | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index 0cbace7b7f7bbd..768b786c6426df 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -1540,7 +1540,10 @@ llvm::Function *CodeGenFunction::GenerateBlockFunction( llvm::BasicBlock *resume = Builder.GetInsertBlock(); // Go back to the entry. - ++entry_ptr; + if (entry_ptr->getNextNonDebugInstruction()) +entry_ptr = entry_ptr->getNextNonDebugInstruction()->getIterator(); + else +entry_ptr = entry->end(); Builder.SetInsertPoint(entry, entry_ptr); // Emit debug information for all the DeclRefExprs. diff --git a/clang/test/CodeGenObjC/debug-info-blocks.m b/clang/test/CodeGenObjC/debug-info-blocks.m index 14b29f222fbe8e..59171da016da1e 100644 --- a/clang/test/CodeGenObjC/debug-info-blocks.m +++ b/clang/test/CodeGenObjC/debug-info-blocks.m @@ -5,8 +5,8 @@ // CHECK: define {{.*}}_block_invoke // CHECK: store ptr %.block_descriptor, ptr %[[ALLOCA:block.addr]], align -// CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %[[ALLOCA]], metadata ![[SELF:[0-9]+]], metadata !{{.*}}) // CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %d, metadata ![[D:[0-9]+]], metadata !{{.*}}) +// CHECK-NEXT: call void @llvm.dbg.declare(metadata ptr %[[ALLOCA]], metadata ![[SELF:[0-9]+]], metadata !{{.*}}) // Test that we do emit scope info for the helper functions, and that the // parameters to these functions are marked as artificial (so the debugger >From efabe4b06f38aaf3aed8cf02c97f566652ba5f15 Mon Sep 17 00:00:00 2001 From: Orlando Cazalet-Hyams Date: Sat, 9 Mar 2024 13:40:30 + Subject: [PATCH 2/2] openmp update DbgRecords Fixed OpenMP/debug_task_shared.c --- clang/lib/CodeGen/CGStmtOpenMP.cpp | 22 +- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp index 3fbd2e03eb61df..5c6a3b8e001730 100644 --- a/clang/lib/CodeGen/CGStmtOpenMP.cpp +++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp @@ -4746,10 +4746,10 @@ void CodeGenFunction::EmitOMPTaskBasedDirective( if (CGF.CGM.getCodeGenOpts().hasReducedDebugInfo()) (void)DI->EmitDeclareOfAutoVariable(SharedVar, ContextValue, CGF.Builder, false); - llvm::Instruction &Last = CGF.Builder.GetInsertBlock()->back(); // Get the call dbg.declare instruction we just created and update // its DIExpression to add offset to base address. - if (auto DDI = dyn_cast(&Last)) { + auto UpdateExpr = [](llvm::LLVMContext &Ctx, auto *DDI, + unsigned Offset) { SmallVector Ops; // Add offset to the base address if non zero. if (Offset) { @@ -4757,9 +4757,21 @@ void CodeGenFunction::EmitOMPTaskBasedDirective( Ops.push_back(Offset); } Ops.push_back(llvm::dwarf::DW_OP_deref); -auto &Ctx = DDI->getContext(); -llvm::DIExpression *DIExpr = llvm::DIExpression::get(Ctx, Ops); -Last.setOperand(2, llvm::MetadataAsValue::get(Ctx, DIExpr)); +DDI->setExpression(llvm::DIExpression::get(Ctx, Ops)); + }; + llvm::Instruction &Last = CGF.Builder.GetInsertBlock()->back(); + if (auto DDI = dyn_cast(&Last)) +UpdateExpr(DDI->getContext(), DDI, Offset); + // If we're emitting using the new debug info format into a block + // without a terminator, the record will be "trailing". + assert(!Last.isTerminator() && "unexpected terminator"); + if (auto *Marker = + CGF.Builder.GetInsertBlock()->getTrailingDPValues()) { +for (llvm::DPValue &DPV : llvm::reverse( + llvm::DPValue::filter(Marker->getDbgValueRange( { + UpdateExpr(Last.getContext(), &DPV, Offset); + break; +} } } } ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits