Skip to content

Commit

Permalink
[OpenCL] Use DW_LANG_OpenCL language tag for OpenCL C
Browse files Browse the repository at this point in the history
Note regarding C++ for OpenCL:

   When compiling C++ for OpenCL, DW_LANG_C_plus_plus* is emitted.

   There is no DWARF language code defined for C++ for OpenCL as of yet,
   but DWARF issue 210514.1 has been raised to request one.

   In the mean time, continuing to emit DW_LANG_C_plus_plus* for C++ for
   OpenCL allows the potential to distinguish between C++ for OpenCL and
   OpenCL C in !DICompileUnit nodes, whereas using DW_LANG_OpenCL for
   C++ for OpenCL would prevent this.

   This change therefore leaves C++ for OpenCL as-is.

Reviewed By: shchenz, Anastasia

Differential Revision: https://reviews.llvm.org/D104118
  • Loading branch information
StuartDBrady committed Jun 25, 2021
1 parent 968980e commit e47027d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
3 changes: 3 additions & 0 deletions clang/lib/CodeGen/CGDebugInfo.cpp
Expand Up @@ -578,6 +578,9 @@ void CGDebugInfo::CreateCompileUnit() {
LangTag = llvm::dwarf::DW_LANG_C_plus_plus;
} else if (LO.ObjC) {
LangTag = llvm::dwarf::DW_LANG_ObjC;
} else if (LO.OpenCL && (!CGM.getCodeGenOpts().DebugStrictDwarf ||
CGM.getCodeGenOpts().DwarfVersion >= 5)) {
LangTag = llvm::dwarf::DW_LANG_OpenCL;
} else if (LO.RenderScript) {
LangTag = llvm::dwarf::DW_LANG_GOOGLE_RenderScript;
} else if (LO.C99) {
Expand Down
17 changes: 17 additions & 0 deletions clang/test/CodeGenOpenCL/debug-info-programming-language.cl
@@ -0,0 +1,17 @@
// RUN: %clang_cc1 -dwarf-version=5 -emit-llvm -triple %itanium_abi_triple %s -o - \
// RUN: -x cl -O0 -disable-llvm-passes -debug-info-kind=limited \
// RUN: | FileCheck --check-prefix=CHECK-OPENCL %s
// RUN: %clang_cc1 -dwarf-version=3 -emit-llvm -triple %itanium_abi_triple %s -o - \
// RUN: -x cl -O0 -disable-llvm-passes -debug-info-kind=limited \
// RUN: | FileCheck --check-prefix=CHECK-OPENCL %s
// RUN: %clang_cc1 -dwarf-version=3 -gstrict-dwarf -emit-llvm -triple %itanium_abi_triple %s -o - \
// RUN: -x cl -O0 -disable-llvm-passes -debug-info-kind=limited \
// RUN: | FileCheck --check-prefix=CHECK-C99 %s
// RUN: %clang_cc1 -dwarf-version=5 -gstrict-dwarf -emit-llvm -triple %itanium_abi_triple %s -o - \
// RUN: -x cl -O0 -disable-llvm-passes -debug-info-kind=limited \
// RUN: | FileCheck --check-prefix=CHECK-OPENCL %s

kernel void empty() {}

// CHECK-OPENCL: distinct !DICompileUnit(language: DW_LANG_OpenCL,
// CHECK-C99: distinct !DICompileUnit(language: DW_LANG_C99,

0 comments on commit e47027d

Please sign in to comment.