[llvm] r237949 - IR / debug info: Add a DWOId field to DICompileUnit,
Adrian Prantl
aprantl at apple.com
Thu May 21 13:37:30 PDT 2015
Author: adrian
Date: Thu May 21 15:37:30 2015
New Revision: 237949
URL: http://llvm.org/viewvc/llvm-project?rev=237949&view=rev
Log:
IR / debug info: Add a DWOId field to DICompileUnit,
so DWARF skeleton CUs can be expression in IR. A skeleton CU is a
(typically empty) DW_TAG_compile_unit that has a DW_AT_(GNU)_dwo_name and
a DW_AT_(GNU)_dwo_id attribute. It is used to refer to external debug info.
This is a prerequisite for clang module debugging as discussed in
http://lists.cs.uiuc.edu/pipermail/cfe-dev/2014-November/040076.html.
In order to refer to external types stored in split DWARF (dwo) objects,
such as clang modules, we need to emit skeleton CUs, which identify the
dwarf object (i.e., the clang module) by filename (the SplitDebugFilename)
and a hash value, the dwo_id.
This patch only contains the IR changes. The idea is that a CUs with a
non-zero dwo_id field will be emitted together with a DW_AT_GNU_dwo_name
and DW_AT_GNU_dwo_id attribute.
http://reviews.llvm.org/D9488
rdar://problem/20091852
Added:
llvm/trunk/test/Bitcode/DICompileUnit-no-DWOId.ll
llvm/trunk/test/Bitcode/DICompileUnit-no-DWOId.ll.bc
Modified:
llvm/trunk/include/llvm/IR/DIBuilder.h
llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
llvm/trunk/lib/AsmParser/LLParser.cpp
llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/trunk/lib/IR/AsmWriter.cpp
llvm/trunk/lib/IR/DIBuilder.cpp
llvm/trunk/lib/IR/DebugInfoMetadata.cpp
llvm/trunk/lib/IR/LLVMContextImpl.h
llvm/trunk/test/Assembler/mdcompileunit.ll
llvm/trunk/unittests/IR/MetadataTest.cpp
Modified: llvm/trunk/include/llvm/IR/DIBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DIBuilder.h?rev=237949&r1=237948&r2=237949&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DIBuilder.h (original)
+++ llvm/trunk/include/llvm/IR/DIBuilder.h Thu May 21 15:37:30 2015
@@ -95,6 +95,7 @@ namespace llvm {
/// @param SplitName The name of the file that we'll split debug info out
/// into.
/// @param Kind The kind of debug information to generate.
+ /// @param DWOId The DWOId if this is a split skeleton compile unit.
/// @param EmitDebugInfo A boolean flag which indicates whether debug
/// information should be written to the final
/// output or not. When this is false, debug
@@ -104,12 +105,12 @@ namespace llvm {
/// source location information in the back end
/// without actually changing the output (e.g.,
/// when using optimization remarks).
- DICompileUnit *createCompileUnit(unsigned Lang, StringRef File,
- StringRef Dir, StringRef Producer,
- bool isOptimized, StringRef Flags,
- unsigned RV, StringRef SplitName = "",
- DebugEmissionKind Kind = FullDebug,
- bool EmitDebugInfo = true);
+ DICompileUnit *
+ createCompileUnit(unsigned Lang, StringRef File, StringRef Dir,
+ StringRef Producer, bool isOptimized, StringRef Flags,
+ unsigned RV, StringRef SplitName = StringRef(),
+ DebugEmissionKind Kind = FullDebug, uint64_t DWOId = 0,
+ bool EmitDebugInfo = true);
/// createFile - Create a file descriptor to hold debugging information
/// for a file.
Modified: llvm/trunk/include/llvm/IR/DebugInfoMetadata.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DebugInfoMetadata.h?rev=237949&r1=237948&r2=237949&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DebugInfoMetadata.h (original)
+++ llvm/trunk/include/llvm/IR/DebugInfoMetadata.h Thu May 21 15:37:30 2015
@@ -971,13 +971,15 @@ class DICompileUnit : public DIScope {
bool IsOptimized;
unsigned RuntimeVersion;
unsigned EmissionKind;
+ uint64_t DWOId;
DICompileUnit(LLVMContext &C, StorageType Storage, unsigned SourceLanguage,
bool IsOptimized, unsigned RuntimeVersion,
- unsigned EmissionKind, ArrayRef<Metadata *> Ops)
+ unsigned EmissionKind, uint64_t DWOId, ArrayRef<Metadata *> Ops)
: DIScope(C, DICompileUnitKind, Storage, dwarf::DW_TAG_compile_unit, Ops),
SourceLanguage(SourceLanguage), IsOptimized(IsOptimized),
- RuntimeVersion(RuntimeVersion), EmissionKind(EmissionKind) {}
+ RuntimeVersion(RuntimeVersion), EmissionKind(EmissionKind),
+ DWOId(DWOId) {}
~DICompileUnit() = default;
static DICompileUnit *
@@ -987,14 +989,15 @@ class DICompileUnit : public DIScope {
unsigned EmissionKind, DICompositeTypeArray EnumTypes,
DITypeArray RetainedTypes, DISubprogramArray Subprograms,
DIGlobalVariableArray GlobalVariables,
- DIImportedEntityArray ImportedEntities, StorageType Storage,
- bool ShouldCreate = true) {
- return getImpl(
- Context, SourceLanguage, File, getCanonicalMDString(Context, Producer),
- IsOptimized, getCanonicalMDString(Context, Flags), RuntimeVersion,
- getCanonicalMDString(Context, SplitDebugFilename), EmissionKind,
- EnumTypes.get(), RetainedTypes.get(), Subprograms.get(),
- GlobalVariables.get(), ImportedEntities.get(), Storage, ShouldCreate);
+ DIImportedEntityArray ImportedEntities, uint64_t DWOId,
+ StorageType Storage, bool ShouldCreate = true) {
+ return getImpl(Context, SourceLanguage, File,
+ getCanonicalMDString(Context, Producer), IsOptimized,
+ getCanonicalMDString(Context, Flags), RuntimeVersion,
+ getCanonicalMDString(Context, SplitDebugFilename),
+ EmissionKind, EnumTypes.get(), RetainedTypes.get(),
+ Subprograms.get(), GlobalVariables.get(),
+ ImportedEntities.get(), DWOId, Storage, ShouldCreate);
}
static DICompileUnit *
getImpl(LLVMContext &Context, unsigned SourceLanguage, Metadata *File,
@@ -1002,7 +1005,7 @@ class DICompileUnit : public DIScope {
unsigned RuntimeVersion, MDString *SplitDebugFilename,
unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes,
Metadata *Subprograms, Metadata *GlobalVariables,
- Metadata *ImportedEntities, StorageType Storage,
+ Metadata *ImportedEntities, uint64_t DWOId, StorageType Storage,
bool ShouldCreate = true);
TempDICompileUnit cloneImpl() const {
@@ -1010,7 +1013,7 @@ class DICompileUnit : public DIScope {
getContext(), getSourceLanguage(), getFile(), getProducer(),
isOptimized(), getFlags(), getRuntimeVersion(), getSplitDebugFilename(),
getEmissionKind(), getEnumTypes(), getRetainedTypes(), getSubprograms(),
- getGlobalVariables(), getImportedEntities());
+ getGlobalVariables(), getImportedEntities(), DWOId);
}
public:
@@ -1021,22 +1024,21 @@ public:
DICompositeTypeArray EnumTypes, DITypeArray RetainedTypes,
DISubprogramArray Subprograms,
DIGlobalVariableArray GlobalVariables,
- DIImportedEntityArray ImportedEntities),
+ DIImportedEntityArray ImportedEntities, uint64_t DWOId),
(SourceLanguage, File, Producer, IsOptimized, Flags,
RuntimeVersion, SplitDebugFilename, EmissionKind,
EnumTypes, RetainedTypes, Subprograms, GlobalVariables,
- ImportedEntities))
- DEFINE_MDNODE_GET(DICompileUnit,
- (unsigned SourceLanguage, Metadata *File,
- MDString *Producer, bool IsOptimized, MDString *Flags,
- unsigned RuntimeVersion, MDString *SplitDebugFilename,
- unsigned EmissionKind, Metadata *EnumTypes,
- Metadata *RetainedTypes, Metadata *Subprograms,
- Metadata *GlobalVariables, Metadata *ImportedEntities),
- (SourceLanguage, File, Producer, IsOptimized, Flags,
- RuntimeVersion, SplitDebugFilename, EmissionKind,
- EnumTypes, RetainedTypes, Subprograms, GlobalVariables,
- ImportedEntities))
+ ImportedEntities, DWOId))
+ DEFINE_MDNODE_GET(
+ DICompileUnit,
+ (unsigned SourceLanguage, Metadata *File, MDString *Producer,
+ bool IsOptimized, MDString *Flags, unsigned RuntimeVersion,
+ MDString *SplitDebugFilename, unsigned EmissionKind, Metadata *EnumTypes,
+ Metadata *RetainedTypes, Metadata *Subprograms,
+ Metadata *GlobalVariables, Metadata *ImportedEntities, uint64_t DWOId),
+ (SourceLanguage, File, Producer, IsOptimized, Flags, RuntimeVersion,
+ SplitDebugFilename, EmissionKind, EnumTypes, RetainedTypes, Subprograms,
+ GlobalVariables, ImportedEntities, DWOId))
TempDICompileUnit clone() const { return cloneImpl(); }
@@ -1062,6 +1064,7 @@ public:
DIImportedEntityArray getImportedEntities() const {
return cast_or_null<MDTuple>(getRawImportedEntities());
}
+ unsigned getDWOId() const { return DWOId; }
MDString *getRawProducer() const { return getOperandAs<MDString>(1); }
MDString *getRawFlags() const { return getOperandAs<MDString>(2); }
Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=237949&r1=237948&r2=237949&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Thu May 21 15:37:30 2015
@@ -3547,7 +3547,7 @@ bool LLParser::ParseDIFile(MDNode *&Resu
/// isOptimized: true, flags: "-O2", runtimeVersion: 1,
/// splitDebugFilename: "abc.debug", emissionKind: 1,
/// enums: !1, retainedTypes: !2, subprograms: !3,
-/// globals: !4, imports: !5)
+/// globals: !4, imports: !5, dwoId: 0x0abcd)
bool LLParser::ParseDICompileUnit(MDNode *&Result, bool IsDistinct) {
#define VISIT_MD_FIELDS(OPTIONAL, REQUIRED) \
REQUIRED(language, DwarfLangField, ); \
@@ -3562,7 +3562,8 @@ bool LLParser::ParseDICompileUnit(MDNode
OPTIONAL(retainedTypes, MDField, ); \
OPTIONAL(subprograms, MDField, ); \
OPTIONAL(globals, MDField, ); \
- OPTIONAL(imports, MDField, );
+ OPTIONAL(imports, MDField, ); \
+ OPTIONAL(dwoId, MDUnsignedField, );
PARSE_MD_FIELDS();
#undef VISIT_MD_FIELDS
@@ -3571,7 +3572,7 @@ bool LLParser::ParseDICompileUnit(MDNode
isOptimized.Val, flags.Val, runtimeVersion.Val,
splitDebugFilename.Val, emissionKind.Val, enums.Val,
retainedTypes.Val, subprograms.Val, globals.Val,
- imports.Val));
+ imports.Val, dwoId.Val));
return false;
}
Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=237949&r1=237948&r2=237949&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Thu May 21 15:37:30 2015
@@ -1844,7 +1844,7 @@ std::error_code BitcodeReader::ParseMeta
break;
}
case bitc::METADATA_COMPILE_UNIT: {
- if (Record.size() != 14)
+ if (Record.size() < 14 || Record.size() > 15)
return Error("Invalid record");
MDValueList.AssignValue(
@@ -1855,7 +1855,8 @@ std::error_code BitcodeReader::ParseMeta
getMDString(Record[7]), Record[8],
getMDOrNull(Record[9]), getMDOrNull(Record[10]),
getMDOrNull(Record[11]), getMDOrNull(Record[12]),
- getMDOrNull(Record[13]))),
+ getMDOrNull(Record[13]),
+ Record.size() == 14 ? 0 : Record[14])),
NextMDValueNo++);
break;
}
Modified: llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=237949&r1=237948&r2=237949&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Thu May 21 15:37:30 2015
@@ -949,6 +949,7 @@ static void WriteDICompileUnit(const DIC
Record.push_back(VE.getMetadataOrNullID(N->getSubprograms().get()));
Record.push_back(VE.getMetadataOrNullID(N->getGlobalVariables().get()));
Record.push_back(VE.getMetadataOrNullID(N->getImportedEntities().get()));
+ Record.push_back(N->getDWOId());
Stream.EmitRecord(bitc::METADATA_COMPILE_UNIT, Record, Abbrev);
Record.clear();
Modified: llvm/trunk/lib/IR/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/AsmWriter.cpp?rev=237949&r1=237948&r2=237949&view=diff
==============================================================================
--- llvm/trunk/lib/IR/AsmWriter.cpp (original)
+++ llvm/trunk/lib/IR/AsmWriter.cpp Thu May 21 15:37:30 2015
@@ -1624,6 +1624,7 @@ static void writeDICompileUnit(raw_ostre
Printer.printMetadata("subprograms", N->getRawSubprograms());
Printer.printMetadata("globals", N->getRawGlobalVariables());
Printer.printMetadata("imports", N->getRawImportedEntities());
+ Printer.printInt("dwoId", N->getDWOId());
Out << ")";
}
Modified: llvm/trunk/lib/IR/DIBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DIBuilder.cpp?rev=237949&r1=237948&r2=237949&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DIBuilder.cpp (original)
+++ llvm/trunk/lib/IR/DIBuilder.cpp Thu May 21 15:37:30 2015
@@ -125,7 +125,7 @@ static DIScope *getNonCompileUnitScope(D
DICompileUnit *DIBuilder::createCompileUnit(
unsigned Lang, StringRef Filename, StringRef Directory, StringRef Producer,
bool isOptimized, StringRef Flags, unsigned RunTimeVer, StringRef SplitName,
- DebugEmissionKind Kind, bool EmitDebugInfo) {
+ DebugEmissionKind Kind, uint64_t DWOId, bool EmitDebugInfo) {
assert(((Lang <= dwarf::DW_LANG_Fortran08 && Lang >= dwarf::DW_LANG_C89) ||
(Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) &&
@@ -147,7 +147,7 @@ DICompileUnit *DIBuilder::createCompileU
VMContext, Lang, DIFile::get(VMContext, Filename, Directory), Producer,
isOptimized, Flags, RunTimeVer, SplitName, Kind, TempEnumTypes.get(),
TempRetainTypes.get(), TempSubprograms.get(), TempGVs.get(),
- TempImportedModules.get());
+ TempImportedModules.get(), DWOId);
// Create a named metadata so that it is easier to find cu in a module.
// Note that we only generate this when the caller wants to actually
Modified: llvm/trunk/lib/IR/DebugInfoMetadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DebugInfoMetadata.cpp?rev=237949&r1=237948&r2=237949&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DebugInfoMetadata.cpp (original)
+++ llvm/trunk/lib/IR/DebugInfoMetadata.cpp Thu May 21 15:37:30 2015
@@ -311,7 +311,8 @@ DICompileUnit *DICompileUnit::getImpl(
unsigned RuntimeVersion, MDString *SplitDebugFilename,
unsigned EmissionKind, Metadata *EnumTypes, Metadata *RetainedTypes,
Metadata *Subprograms, Metadata *GlobalVariables,
- Metadata *ImportedEntities, StorageType Storage, bool ShouldCreate) {
+ Metadata *ImportedEntities, uint64_t DWOId,
+ StorageType Storage, bool ShouldCreate) {
assert(isCanonical(Producer) && "Expected canonical MDString");
assert(isCanonical(Flags) && "Expected canonical MDString");
assert(isCanonical(SplitDebugFilename) && "Expected canonical MDString");
@@ -319,13 +320,13 @@ DICompileUnit *DICompileUnit::getImpl(
DICompileUnit,
(SourceLanguage, File, getString(Producer), IsOptimized, getString(Flags),
RuntimeVersion, getString(SplitDebugFilename), EmissionKind, EnumTypes,
- RetainedTypes, Subprograms, GlobalVariables, ImportedEntities));
+ RetainedTypes, Subprograms, GlobalVariables, ImportedEntities, DWOId));
Metadata *Ops[] = {File, Producer, Flags, SplitDebugFilename, EnumTypes,
RetainedTypes, Subprograms, GlobalVariables,
ImportedEntities};
DEFINE_GETIMPL_STORE(
DICompileUnit,
- (SourceLanguage, IsOptimized, RuntimeVersion, EmissionKind), Ops);
+ (SourceLanguage, IsOptimized, RuntimeVersion, EmissionKind, DWOId), Ops);
}
DISubprogram *DILocalScope::getSubprogram() const {
Modified: llvm/trunk/lib/IR/LLVMContextImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LLVMContextImpl.h?rev=237949&r1=237948&r2=237949&view=diff
==============================================================================
--- llvm/trunk/lib/IR/LLVMContextImpl.h (original)
+++ llvm/trunk/lib/IR/LLVMContextImpl.h Thu May 21 15:37:30 2015
@@ -472,19 +472,20 @@ template <> struct MDNodeKeyImpl<DICompi
Metadata *Subprograms;
Metadata *GlobalVariables;
Metadata *ImportedEntities;
+ uint64_t DWOId;
MDNodeKeyImpl(unsigned SourceLanguage, Metadata *File, StringRef Producer,
bool IsOptimized, StringRef Flags, unsigned RuntimeVersion,
StringRef SplitDebugFilename, unsigned EmissionKind,
Metadata *EnumTypes, Metadata *RetainedTypes,
Metadata *Subprograms, Metadata *GlobalVariables,
- Metadata *ImportedEntities)
+ Metadata *ImportedEntities, uint64_t DWOId)
: SourceLanguage(SourceLanguage), File(File), Producer(Producer),
IsOptimized(IsOptimized), Flags(Flags), RuntimeVersion(RuntimeVersion),
SplitDebugFilename(SplitDebugFilename), EmissionKind(EmissionKind),
EnumTypes(EnumTypes), RetainedTypes(RetainedTypes),
Subprograms(Subprograms), GlobalVariables(GlobalVariables),
- ImportedEntities(ImportedEntities) {}
+ ImportedEntities(ImportedEntities), DWOId(DWOId) {}
MDNodeKeyImpl(const DICompileUnit *N)
: SourceLanguage(N->getSourceLanguage()), File(N->getRawFile()),
Producer(N->getProducer()), IsOptimized(N->isOptimized()),
@@ -494,7 +495,7 @@ template <> struct MDNodeKeyImpl<DICompi
RetainedTypes(N->getRawRetainedTypes()),
Subprograms(N->getRawSubprograms()),
GlobalVariables(N->getRawGlobalVariables()),
- ImportedEntities(N->getRawImportedEntities()) {}
+ ImportedEntities(N->getRawImportedEntities()), DWOId(N->getDWOId()) {}
bool isKeyOf(const DICompileUnit *RHS) const {
return SourceLanguage == RHS->getSourceLanguage() &&
@@ -507,13 +508,14 @@ template <> struct MDNodeKeyImpl<DICompi
RetainedTypes == RHS->getRawRetainedTypes() &&
Subprograms == RHS->getRawSubprograms() &&
GlobalVariables == RHS->getRawGlobalVariables() &&
- ImportedEntities == RHS->getRawImportedEntities();
+ ImportedEntities == RHS->getRawImportedEntities() &&
+ DWOId == RHS->getDWOId();
}
unsigned getHashValue() const {
return hash_combine(SourceLanguage, File, Producer, IsOptimized, Flags,
RuntimeVersion, SplitDebugFilename, EmissionKind,
EnumTypes, RetainedTypes, Subprograms, GlobalVariables,
- ImportedEntities);
+ ImportedEntities, DWOId);
}
};
Modified: llvm/trunk/test/Assembler/mdcompileunit.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/mdcompileunit.ll?rev=237949&r1=237948&r2=237949&view=diff
==============================================================================
--- llvm/trunk/test/Assembler/mdcompileunit.ll (original)
+++ llvm/trunk/test/Assembler/mdcompileunit.ll Thu May 21 15:37:30 2015
@@ -12,17 +12,17 @@
!5 = distinct !{}
!6 = distinct !{}
-; CHECK: !7 = !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: true, flags: "-O2", runtimeVersion: 2, splitDebugFilename: "abc.debug", emissionKind: 3, enums: !2, retainedTypes: !3, subprograms: !4, globals: !5, imports: !6)
+; CHECK: !7 = !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: true, flags: "-O2", runtimeVersion: 2, splitDebugFilename: "abc.debug", emissionKind: 3, enums: !2, retainedTypes: !3, subprograms: !4, globals: !5, imports: !6, dwoId: 42)
!7 = !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang",
isOptimized: true, flags: "-O2", runtimeVersion: 2,
splitDebugFilename: "abc.debug", emissionKind: 3,
enums: !2, retainedTypes: !3, subprograms: !4,
- globals: !5, imports: !6)
+ globals: !5, imports: !6, dwoId: 42)
!8 = !DICompileUnit(language: 12, file: !1, producer: "clang",
isOptimized: true, flags: "-O2", runtimeVersion: 2,
splitDebugFilename: "abc.debug", emissionKind: 3,
enums: !2, retainedTypes: !3, subprograms: !4,
- globals: !5, imports: !6)
+ globals: !5, imports: !6, dwoId: 42)
; CHECK: !8 = !DICompileUnit(language: DW_LANG_C99, file: !1, isOptimized: false, runtimeVersion: 0, emissionKind: 0)
!9 = !DICompileUnit(language: 12, file: !1, producer: "",
Added: llvm/trunk/test/Bitcode/DICompileUnit-no-DWOId.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/DICompileUnit-no-DWOId.ll?rev=237949&view=auto
==============================================================================
--- llvm/trunk/test/Bitcode/DICompileUnit-no-DWOId.ll (added)
+++ llvm/trunk/test/Bitcode/DICompileUnit-no-DWOId.ll Thu May 21 15:37:30 2015
@@ -0,0 +1,9 @@
+; The input uses the older (r236428) form without a dwoId field. This should
+; default to 0, which is not displayed at all in the textual representation.
+;
+; RUN: llvm-dis %s.bc -o - | FileCheck %s
+; CHECK: !DICompileUnit
+; CHECK-NOT: dwoId:
+!named = !{!0}
+!0 = !DICompileUnit(language: 12, file: !1)
+!1 = !DIFile(filename: "path/to/file", directory: "/path/to/dir")
Added: llvm/trunk/test/Bitcode/DICompileUnit-no-DWOId.ll.bc
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/DICompileUnit-no-DWOId.ll.bc?rev=237949&view=auto
==============================================================================
Binary files llvm/trunk/test/Bitcode/DICompileUnit-no-DWOId.ll.bc (added) and llvm/trunk/test/Bitcode/DICompileUnit-no-DWOId.ll.bc Thu May 21 15:37:30 2015 differ
Modified: llvm/trunk/unittests/IR/MetadataTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/MetadataTest.cpp?rev=237949&r1=237948&r2=237949&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/MetadataTest.cpp (original)
+++ llvm/trunk/unittests/IR/MetadataTest.cpp Thu May 21 15:37:30 2015
@@ -1294,10 +1294,11 @@ TEST_F(DICompileUnitTest, get) {
MDTuple *Subprograms = getTuple();
MDTuple *GlobalVariables = getTuple();
MDTuple *ImportedEntities = getTuple();
+ uint64_t DWOId = 0xc0ffee;
auto *N = DICompileUnit::get(
Context, SourceLanguage, File, Producer, IsOptimized, Flags,
RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes,
- RetainedTypes, Subprograms, GlobalVariables, ImportedEntities);
+ RetainedTypes, Subprograms, GlobalVariables, ImportedEntities, DWOId);
EXPECT_EQ(dwarf::DW_TAG_compile_unit, N->getTag());
EXPECT_EQ(SourceLanguage, N->getSourceLanguage());
@@ -1313,74 +1314,83 @@ TEST_F(DICompileUnitTest, get) {
EXPECT_EQ(Subprograms, N->getSubprograms().get());
EXPECT_EQ(GlobalVariables, N->getGlobalVariables().get());
EXPECT_EQ(ImportedEntities, N->getImportedEntities().get());
+ EXPECT_EQ(DWOId, N->getDWOId());
EXPECT_EQ(N, DICompileUnit::get(Context, SourceLanguage, File, Producer,
IsOptimized, Flags, RuntimeVersion,
SplitDebugFilename, EmissionKind, EnumTypes,
RetainedTypes, Subprograms, GlobalVariables,
- ImportedEntities));
+ ImportedEntities, DWOId));
EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage + 1, File, Producer,
IsOptimized, Flags, RuntimeVersion,
SplitDebugFilename, EmissionKind, EnumTypes,
RetainedTypes, Subprograms, GlobalVariables,
- ImportedEntities));
+ ImportedEntities, DWOId));
EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, getFile(), Producer,
IsOptimized, Flags, RuntimeVersion,
SplitDebugFilename, EmissionKind, EnumTypes,
RetainedTypes, Subprograms, GlobalVariables,
- ImportedEntities));
+ ImportedEntities, DWOId));
EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, File, "other",
IsOptimized, Flags, RuntimeVersion,
SplitDebugFilename, EmissionKind, EnumTypes,
RetainedTypes, Subprograms, GlobalVariables,
- ImportedEntities));
+ ImportedEntities, DWOId));
EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, File, Producer,
!IsOptimized, Flags, RuntimeVersion,
SplitDebugFilename, EmissionKind, EnumTypes,
RetainedTypes, Subprograms, GlobalVariables,
- ImportedEntities));
+ ImportedEntities, DWOId));
EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, File, Producer,
IsOptimized, "other", RuntimeVersion,
SplitDebugFilename, EmissionKind, EnumTypes,
RetainedTypes, Subprograms, GlobalVariables,
- ImportedEntities));
+ ImportedEntities, DWOId));
EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, File, Producer,
IsOptimized, Flags, RuntimeVersion + 1,
SplitDebugFilename, EmissionKind, EnumTypes,
RetainedTypes, Subprograms, GlobalVariables,
- ImportedEntities));
- EXPECT_NE(N,
- DICompileUnit::get(Context, SourceLanguage, File, Producer,
- IsOptimized, Flags, RuntimeVersion, "other",
- EmissionKind, EnumTypes, RetainedTypes,
- Subprograms, GlobalVariables, ImportedEntities));
+ ImportedEntities, DWOId));
+ EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, File, Producer,
+ IsOptimized, Flags, RuntimeVersion, "other",
+ EmissionKind, EnumTypes, RetainedTypes,
+ Subprograms, GlobalVariables,
+ ImportedEntities, DWOId));
EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, File, Producer,
IsOptimized, Flags, RuntimeVersion,
SplitDebugFilename, EmissionKind + 1,
EnumTypes, RetainedTypes, Subprograms,
- GlobalVariables, ImportedEntities));
+ GlobalVariables, ImportedEntities, DWOId));
EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, File, Producer,
IsOptimized, Flags, RuntimeVersion,
SplitDebugFilename, EmissionKind, getTuple(),
RetainedTypes, Subprograms, GlobalVariables,
- ImportedEntities));
- EXPECT_NE(N, DICompileUnit::get(
- Context, SourceLanguage, File, Producer, IsOptimized, Flags,
- RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes,
- getTuple(), Subprograms, GlobalVariables, ImportedEntities));
+ ImportedEntities, DWOId));
+ EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, File, Producer,
+ IsOptimized, Flags, RuntimeVersion,
+ SplitDebugFilename, EmissionKind, EnumTypes,
+ getTuple(), Subprograms, GlobalVariables,
+ ImportedEntities, DWOId));
EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, File, Producer,
IsOptimized, Flags, RuntimeVersion,
SplitDebugFilename, EmissionKind, EnumTypes,
RetainedTypes, getTuple(), GlobalVariables,
- ImportedEntities));
- EXPECT_NE(N, DICompileUnit::get(
- Context, SourceLanguage, File, Producer, IsOptimized, Flags,
- RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes,
- RetainedTypes, Subprograms, getTuple(), ImportedEntities));
- EXPECT_NE(N, DICompileUnit::get(
- Context, SourceLanguage, File, Producer, IsOptimized, Flags,
- RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes,
- RetainedTypes, Subprograms, GlobalVariables, getTuple()));
+ ImportedEntities, DWOId));
+ EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, File, Producer,
+ IsOptimized, Flags, RuntimeVersion,
+ SplitDebugFilename, EmissionKind, EnumTypes,
+ RetainedTypes, Subprograms, getTuple(),
+ ImportedEntities, DWOId));
+ EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, File, Producer,
+ IsOptimized, Flags, RuntimeVersion,
+ SplitDebugFilename, EmissionKind, EnumTypes,
+ RetainedTypes, Subprograms, GlobalVariables,
+ getTuple(), DWOId));
+ EXPECT_NE(N, DICompileUnit::get(Context, SourceLanguage, File, Producer,
+ IsOptimized, Flags, RuntimeVersion,
+ SplitDebugFilename, EmissionKind, EnumTypes,
+ RetainedTypes, Subprograms, GlobalVariables,
+ ImportedEntities, DWOId + 1));
TempDICompileUnit Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));
@@ -1398,10 +1408,11 @@ TEST_F(DICompileUnitTest, replaceArrays)
MDTuple *EnumTypes = MDTuple::getDistinct(Context, None);
MDTuple *RetainedTypes = MDTuple::getDistinct(Context, None);
MDTuple *ImportedEntities = MDTuple::getDistinct(Context, None);
+ uint64_t DWOId = 0xc0ffee;
auto *N = DICompileUnit::get(
Context, SourceLanguage, File, Producer, IsOptimized, Flags,
RuntimeVersion, SplitDebugFilename, EmissionKind, EnumTypes,
- RetainedTypes, nullptr, nullptr, ImportedEntities);
+ RetainedTypes, nullptr, nullptr, ImportedEntities, DWOId);
auto *Subprograms = MDTuple::getDistinct(Context, None);
EXPECT_EQ(nullptr, N->getSubprograms().get());
More information about the llvm-commits
mailing list