Index: clang/lib/CodeGen/CGDebugInfo.cpp =================================================================== --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -613,17 +613,21 @@ SDK = *It; } + llvm::DICompileUnit::DebugNameTableKind NameTableKind = + static_cast( + CGOpts.DebugNameTable); + if (CGM.getTarget().getTriple().isNVPTX()) + NameTableKind = llvm::DICompileUnit::DebugNameTableKind::None; + else if (CGM.getTarget().getTriple().isOSBinFormatMachO()) + NameTableKind = llvm::DICompileUnit::DebugNameTableKind::Apple; + // Create new compile unit. TheCU = DBuilder.createCompileUnit( LangTag, CUFile, CGOpts.EmitVersionIdentMetadata ? Producer : "", LO.Optimize || CGOpts.PrepareForLTO || CGOpts.PrepareForThinLTO, CGOpts.DwarfDebugFlags, RuntimeVers, CGOpts.SplitDwarfFile, EmissionKind, DwoId, CGOpts.SplitDwarfInlining, CGOpts.DebugInfoForProfiling, - CGM.getTarget().getTriple().isNVPTX() - ? llvm::DICompileUnit::DebugNameTableKind::None - : static_cast( - CGOpts.DebugNameTable), - CGOpts.DebugRangesBaseAddress, remapDIPath(Sysroot), SDK); + NameTableKind, CGOpts.DebugRangesBaseAddress, remapDIPath(Sysroot), SDK); } llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) { Index: clang/test/CodeGen/debug-info-names.c =================================================================== --- clang/test/CodeGen/debug-info-names.c +++ clang/test/CodeGen/debug-info-names.c @@ -1,10 +1,12 @@ // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - | FileCheck %s // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - -gpubnames | FileCheck --check-prefix=DEFAULT %s // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - -ggnu-pubnames | FileCheck --check-prefix=GNU %s +// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited %s -o - -gapplenames | FileCheck --check-prefix=APPLE %s // CHECK: !DICompileUnit({{.*}}, nameTableKind: None // DEFAULT-NOT: !DICompileUnit({{.*}}, nameTableKind: // GNU: !DICompileUnit({{.*}}, nameTableKind: GNU +// APPLE: !DICompileUnit({{.*}}, nameTableKind: Apple void f1() { } Index: llvm/include/llvm/IR/DebugInfoMetadata.h =================================================================== --- llvm/include/llvm/IR/DebugInfoMetadata.h +++ llvm/include/llvm/IR/DebugInfoMetadata.h @@ -1361,7 +1361,8 @@ enum class DebugNameTableKind : unsigned { Default = 0, GNU = 1, - None = 2, + Apple = 2, + None = 3, LastDebugNameTableKind = None }; Index: llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp =================================================================== --- llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp +++ llvm/lib/CodeGen/AsmPrinter/AccelTable.cpp @@ -550,9 +550,13 @@ SmallVector CUIndex(CUs.size()); int Count = 0; for (const auto &CU : enumerate(CUs)) { - if (CU.value()->getCUNode()->getNameTableKind() != - DICompileUnit::DebugNameTableKind::Default) + switch (CU.value()->getCUNode()->getNameTableKind()) { + case DICompileUnit::DebugNameTableKind::Default: + case DICompileUnit::DebugNameTableKind::Apple: + break; + default: continue; + } CUIndex[CU.index()] = Count++; assert(CU.index() == CU.value()->getUniqueID()); const DwarfCompileUnit *MainCU = Index: llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp =================================================================== --- llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp +++ llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp @@ -1383,6 +1383,8 @@ // generated for things like Gold's gdb_index generation. case DICompileUnit::DebugNameTableKind::GNU: return true; + case DICompileUnit::DebugNameTableKind::Apple: + return false; case DICompileUnit::DebugNameTableKind::Default: return DD->tuneForGDB() && !includeMinimalInlineScopes() && !CUNode->isDebugDirectivesOnly() && Index: llvm/lib/IR/DebugInfoMetadata.cpp =================================================================== --- llvm/lib/IR/DebugInfoMetadata.cpp +++ llvm/lib/IR/DebugInfoMetadata.cpp @@ -798,6 +798,7 @@ return StringSwitch>(Str) .Case("Default", DebugNameTableKind::Default) .Case("GNU", DebugNameTableKind::GNU) + .Case("Apple", DebugNameTableKind::Apple) .Case("None", DebugNameTableKind::None) .Default(None); } @@ -822,6 +823,8 @@ return nullptr; case DebugNameTableKind::GNU: return "GNU"; + case DebugNameTableKind::Apple: + return "Apple"; case DebugNameTableKind::None: return "None"; }