r352421 - [OPENMP][NVPTX]Emit service debug variable for NVPTX.

Alexey Bataev via cfe-commits cfe-commits at lists.llvm.org
Mon Jan 28 12:03:02 PST 2019


Author: abataev
Date: Mon Jan 28 12:03:02 2019
New Revision: 352421

URL: http://llvm.org/viewvc/llvm-project?rev=352421&view=rev
Log:
[OPENMP][NVPTX]Emit service debug variable for NVPTX.

In case of the empty module, the ptxas tool may emit error message about
empty debug info sections. This patch fixes this bug.

Modified:
    cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
    cfe/trunk/test/OpenMP/nvptx_target_firstprivate_codegen.cpp

Modified: cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp?rev=352421&r1=352420&r2=352421&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp Mon Jan 28 12:03:02 2019
@@ -4494,6 +4494,20 @@ static std::pair<unsigned, unsigned> get
 }
 
 void CGOpenMPRuntimeNVPTX::clear() {
+  if (CGDebugInfo *DI = CGM.getModuleDebugInfo())
+    if (CGM.getCodeGenOpts().getDebugInfo() >=
+        codegenoptions::LimitedDebugInfo) {
+      ASTContext &C = CGM.getContext();
+      auto *VD = VarDecl::Create(
+          C, C.getTranslationUnitDecl(), SourceLocation(), SourceLocation(),
+          &C.Idents.get("_$_"), C.IntTy, /*TInfo=*/nullptr, SC_Static);
+      auto *Var = cast<llvm::GlobalVariable>(
+          CGM.CreateRuntimeVariable(CGM.IntTy, "_$_"));
+      Var->setInitializer(llvm::ConstantInt::getNullValue(CGM.IntTy));
+      Var->setLinkage(llvm::GlobalVariable::CommonLinkage);
+      CGM.addCompilerUsedGlobal(Var);
+      DI->EmitGlobalVariable(Var, VD);
+    }
   if (!GlobalizedRecords.empty()) {
     ASTContext &C = CGM.getContext();
     llvm::SmallVector<const GlobalPtrSizeRecsTy *, 4> GlobalRecs;

Modified: cfe/trunk/test/OpenMP/nvptx_target_firstprivate_codegen.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nvptx_target_firstprivate_codegen.cpp?rev=352421&r1=352420&r2=352421&view=diff
==============================================================================
--- cfe/trunk/test/OpenMP/nvptx_target_firstprivate_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/nvptx_target_firstprivate_codegen.cpp Mon Jan 28 12:03:02 2019
@@ -16,6 +16,7 @@ struct TT {
 // TCHECK:  [[TT:%.+]] = type { i64, i8 }
 // TCHECK:  [[S1:%.+]] = type { double }
 
+// TCHECK: @{{.*}}_$_{{.*}} = common global i32 0, !dbg !{{[0-9]+}}
 int foo(int n, double *ptr) {
   int a = 0;
   short aa = 0;




More information about the cfe-commits mailing list