forked from OSchip/llvm-project
[OpenMP][FIX] Emit debug declares only if debug info is available
The `EmitDeclareOfAutoVariable` introduced in D114504 and D115510 has a precondition that cannot be violated. It is unclear if we should call it directly given the sparse usage in clang but for now we should at least not crash if the debug info kind is too low. Fixes #52938. Differential Revision: https://reviews.llvm.org/D116865
This commit is contained in:
parent
6c745e04fa
commit
37639b72a1
|
@ -4460,8 +4460,9 @@ void CodeGenFunction::EmitOMPTaskBasedDirective(
|
|||
CGF.getContext().getASTRecordLayout(CaptureRecord);
|
||||
unsigned Offset =
|
||||
Layout.getFieldOffset(It->second->getFieldIndex()) / CharWidth;
|
||||
(void)DI->EmitDeclareOfAutoVariable(SharedVar, ContextValue,
|
||||
CGF.Builder, false);
|
||||
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.
|
||||
|
@ -4560,8 +4561,10 @@ void CodeGenFunction::EmitOMPTaskBasedDirective(
|
|||
CGF.getContext().getDeclAlign(Pair.first));
|
||||
Scope.addPrivate(Pair.first, [Replacement]() { return Replacement; });
|
||||
if (auto *DI = CGF.getDebugInfo())
|
||||
DI->EmitDeclareOfAutoVariable(Pair.first, Pair.second.getPointer(),
|
||||
CGF.Builder, /*UsePointerValue*/ true);
|
||||
if (CGF.CGM.getCodeGenOpts().hasReducedDebugInfo())
|
||||
(void)DI->EmitDeclareOfAutoVariable(
|
||||
Pair.first, Pair.second.getPointer(), CGF.Builder,
|
||||
/*UsePointerValue*/ true);
|
||||
}
|
||||
// Adjust mapping for internal locals by mapping actual memory instead of
|
||||
// a pointer to this memory.
|
||||
|
|
|
@ -4,6 +4,9 @@
|
|||
// REQUIRES: x86_64-linux
|
||||
|
||||
// RUN: %clang_cc1 -debug-info-kind=constructor -x c -verify -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm %s -o - | FileCheck %s
|
||||
// RUN: %clang_cc1 -debug-info-kind=line-directives-only -x c -verify -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm %s -o - | FileCheck %s --check-prefix=NEG
|
||||
// RUN: %clang_cc1 -debug-info-kind=line-tables-only -x c -verify -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm %s -o - | FileCheck %s --check-prefix=NEG
|
||||
// RUN: %clang_cc1 -debug-info-kind=limited -x c -verify -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm %s -o - | FileCheck %s
|
||||
// expected-no-diagnostics
|
||||
|
||||
// CHECK: define internal i32 @.omp_task_entry.
|
||||
|
@ -11,6 +14,7 @@
|
|||
// CHECK: call void @llvm.dbg.declare(metadata i32** %.priv.ptr.addr.i, metadata [[PRIV1:![0-9]+]], metadata !DIExpression(DW_OP_deref))
|
||||
// CHECK: call void @llvm.dbg.declare(metadata i32** %.priv.ptr.addr1.i, metadata [[PRIV2:![0-9]+]], metadata !DIExpression(DW_OP_deref))
|
||||
// CHECK: call void @llvm.dbg.declare(metadata i32** %.firstpriv.ptr.addr.i, metadata [[FPRIV:![0-9]+]], metadata !DIExpression(DW_OP_deref))
|
||||
// NEG-NOT: call void @llvm.dbg.declare
|
||||
|
||||
// CHECK: [[PRIV1]] = !DILocalVariable(name: "priv1"
|
||||
// CHECK: [[PRIV2]] = !DILocalVariable(name: "priv2"
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
|
||||
// RUN: %clang_cc1 -debug-info-kind=constructor -DSHARED -x c -verify -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
|
||||
// RUN: %clang_cc1 -debug-info-kind=constructor -x c -verify -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm %s -o - | FileCheck %s --check-prefix=NEG
|
||||
// RUN: %clang_cc1 -debug-info-kind=line-directives-only -DSHARED -x c -verify -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm %s -o - | FileCheck %s --check-prefix=NEG
|
||||
// RUN: %clang_cc1 -debug-info-kind=line-tables-only -DSHARED -x c -verify -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm %s -o - | FileCheck %s --check-prefix=NEG
|
||||
// RUN: %clang_cc1 -debug-info-kind=limited -DSHARED -x c -verify -triple x86_64-pc-linux-gnu -fopenmp -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK
|
||||
// expected-no-diagnostics
|
||||
|
||||
// CHECK-LABEL: define internal i32 @.omp_task_entry.
|
||||
|
|
Loading…
Reference in New Issue