[Openmp-commits] [PATCH] D116865: [OpenMP][FIX] Emit debug declares only if debug info is available

Johannes Doerfert via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Sat Jan 8 16:13:42 PST 2022


This revision was automatically updated to reflect the committed changes.
Closed by commit rG37639b72a17b: [OpenMP][FIX] Emit debug declares only if debug info is available (authored by jdoerfert).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D116865/new/

https://reviews.llvm.org/D116865

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/debug_private.c
  clang/test/OpenMP/debug_task_shared.c


Index: clang/test/OpenMP/debug_task_shared.c
===================================================================
--- clang/test/OpenMP/debug_task_shared.c
+++ clang/test/OpenMP/debug_task_shared.c
@@ -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.
Index: clang/test/OpenMP/debug_private.c
===================================================================
--- clang/test/OpenMP/debug_private.c
+++ clang/test/OpenMP/debug_private.c
@@ -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"
Index: clang/lib/CodeGen/CGStmtOpenMP.cpp
===================================================================
--- clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -4460,8 +4460,9 @@
               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 @@
                             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.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D116865.398383.patch
Type: text/x-patch
Size: 4269 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20220109/468502bf/attachment.bin>


More information about the Openmp-commits mailing list