From: Alexey Bataev Date: Mon, 28 Jan 2019 20:03:02 +0000 (+0000) Subject: [OPENMP][NVPTX]Emit service debug variable for NVPTX. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=00c3372fa3b073da0902153b72024df9075217c2;p=clang [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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@352421 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp b/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp index c1233044cd..788fa83ea0 100644 --- a/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp +++ b/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp @@ -4494,6 +4494,20 @@ static std::pair getSMsBlocksPerSM(CodeGenModule &CGM) { } 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( + 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 GlobalRecs; diff --git a/test/OpenMP/nvptx_target_firstprivate_codegen.cpp b/test/OpenMP/nvptx_target_firstprivate_codegen.cpp index 53b0f75885..8ffc08294a 100644 --- a/test/OpenMP/nvptx_target_firstprivate_codegen.cpp +++ b/test/OpenMP/nvptx_target_firstprivate_codegen.cpp @@ -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;