[llvm] r289702 - [DebugInfo] Changed DIBuilder::createCompileUnit() to take DIFile instead of FileName and Directory.
Amjad Aboud via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 14 12:24:55 PST 2016
Author: aaboud
Date: Wed Dec 14 14:24:54 2016
New Revision: 289702
URL: http://llvm.org/viewvc/llvm-project?rev=289702&view=rev
Log:
[DebugInfo] Changed DIBuilder::createCompileUnit() to take DIFile instead of FileName and Directory.
This way it will be easier to expand DIFile (e.g., to contain checksum) without the need to modify the createCompileUnit() API.
Reviewers: llvm-commits, rnk
Differential Revision: https://reviews.llvm.org/D27762
Modified:
llvm/trunk/include/llvm/IR/DIBuilder.h
llvm/trunk/lib/IR/DIBuilder.cpp
llvm/trunk/unittests/IR/IRBuilderTest.cpp
llvm/trunk/unittests/IR/VerifierTest.cpp
llvm/trunk/unittests/Transforms/Utils/Cloning.cpp
Modified: llvm/trunk/include/llvm/IR/DIBuilder.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/DIBuilder.h?rev=289702&r1=289701&r2=289702&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/DIBuilder.h (original)
+++ llvm/trunk/include/llvm/IR/DIBuilder.h Wed Dec 14 14:24:54 2016
@@ -83,8 +83,7 @@ namespace llvm {
/// A CompileUnit provides an anchor for all debugging
/// information generated during this instance of compilation.
/// \param Lang Source programming language, eg. dwarf::DW_LANG_C99
- /// \param File File name
- /// \param Dir Directory
+ /// \param File File info.
/// \param Producer Identify the producer of debugging information
/// and code. Usually this is a compiler
/// version string.
@@ -101,9 +100,9 @@ namespace llvm {
/// \param Kind The kind of debug information to generate.
/// \param DWOId The DWOId if this is a split skeleton compile unit.
DICompileUnit *
- createCompileUnit(unsigned Lang, StringRef File, StringRef Dir,
- StringRef Producer, bool isOptimized, StringRef Flags,
- unsigned RV, StringRef SplitName = StringRef(),
+ createCompileUnit(unsigned Lang, DIFile *File, StringRef Producer,
+ bool isOptimized, StringRef Flags, unsigned RV,
+ StringRef SplitName = StringRef(),
DICompileUnit::DebugEmissionKind Kind =
DICompileUnit::DebugEmissionKind::FullDebug,
uint64_t DWOId = 0, bool SplitDebugInlining = true);
Modified: llvm/trunk/lib/IR/DIBuilder.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/DIBuilder.cpp?rev=289702&r1=289701&r2=289702&view=diff
==============================================================================
--- llvm/trunk/lib/IR/DIBuilder.cpp (original)
+++ llvm/trunk/lib/IR/DIBuilder.cpp Wed Dec 14 14:24:54 2016
@@ -109,22 +109,20 @@ static DIScope *getNonCompileUnitScope(D
}
DICompileUnit *DIBuilder::createCompileUnit(
- unsigned Lang, StringRef Filename, StringRef Directory, StringRef Producer,
- bool isOptimized, StringRef Flags, unsigned RunTimeVer, StringRef SplitName,
+ unsigned Lang, DIFile *File, StringRef Producer, bool isOptimized,
+ StringRef Flags, unsigned RunTimeVer, StringRef SplitName,
DICompileUnit::DebugEmissionKind Kind, uint64_t DWOId,
bool SplitDebugInlining) {
assert(((Lang <= dwarf::DW_LANG_Fortran08 && Lang >= dwarf::DW_LANG_C89) ||
(Lang <= dwarf::DW_LANG_hi_user && Lang >= dwarf::DW_LANG_lo_user)) &&
"Invalid Language tag");
- assert(!Filename.empty() &&
- "Unable to create compile unit without filename");
assert(!CUNode && "Can only make one compile unit per DIBuilder instance");
CUNode = DICompileUnit::getDistinct(
- VMContext, Lang, DIFile::get(VMContext, Filename, Directory), Producer,
- isOptimized, Flags, RunTimeVer, SplitName, Kind, nullptr, nullptr,
- nullptr, nullptr, nullptr, DWOId, SplitDebugInlining);
+ VMContext, Lang, File, Producer, isOptimized, Flags, RunTimeVer,
+ SplitName, Kind, nullptr, nullptr, nullptr, nullptr, nullptr, DWOId,
+ SplitDebugInlining);
// Create a named metadata so that it is easier to find cu in a module.
NamedMDNode *NMD = M.getOrInsertNamedMetadata("llvm.dbg.cu");
Modified: llvm/trunk/unittests/IR/IRBuilderTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/IRBuilderTest.cpp?rev=289702&r1=289701&r2=289702&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/IRBuilderTest.cpp (original)
+++ llvm/trunk/unittests/IR/IRBuilderTest.cpp Wed Dec 14 14:24:54 2016
@@ -340,8 +340,9 @@ TEST_F(IRBuilderTest, DIBuilder) {
IRBuilder<> Builder(BB);
DIBuilder DIB(*M);
auto File = DIB.createFile("F.CBL", "/");
- auto CU = DIB.createCompileUnit(dwarf::DW_LANG_Cobol74, "F.CBL", "/",
- "llvm-cobol74", true, "", 0);
+ auto CU = DIB.createCompileUnit(dwarf::DW_LANG_Cobol74,
+ DIB.createFile("F.CBL", "/"), "llvm-cobol74",
+ true, "", 0);
auto Type = DIB.createSubroutineType(DIB.getOrCreateTypeArray(None));
auto SP = DIB.createFunction(CU, "foo", "", File, 1, Type, false, true, 1,
DINode::FlagZero, true);
@@ -392,8 +393,9 @@ TEST_F(IRBuilderTest, DebugLoc) {
DIBuilder DIB(*M);
auto File = DIB.createFile("tmp.cpp", "/");
- auto CU = DIB.createCompileUnit(dwarf::DW_LANG_C_plus_plus_11, "tmp.cpp", "/",
- "", true, "", 0);
+ auto CU = DIB.createCompileUnit(dwarf::DW_LANG_C_plus_plus_11,
+ DIB.createFile("tmp.cpp", "/"), "", true, "",
+ 0);
auto SPType = DIB.createSubroutineType(DIB.getOrCreateTypeArray(None));
auto SP =
DIB.createFunction(CU, "foo", "foo", File, 1, SPType, false, true, 1);
@@ -422,8 +424,9 @@ TEST_F(IRBuilderTest, DebugLoc) {
TEST_F(IRBuilderTest, DIImportedEntity) {
IRBuilder<> Builder(BB);
DIBuilder DIB(*M);
- auto CU = DIB.createCompileUnit(dwarf::DW_LANG_Cobol74, "F.CBL", "/",
- "llvm-cobol74", true, "", 0);
+ auto CU = DIB.createCompileUnit(dwarf::DW_LANG_Cobol74,
+ DIB.createFile("F.CBL", "/"), "llvm-cobol74",
+ true, "", 0);
DIB.createImportedDeclaration(CU, nullptr, 1);
DIB.createImportedDeclaration(CU, nullptr, 1);
DIB.createImportedModule(CU, (DIImportedEntity *)nullptr, 2);
Modified: llvm/trunk/unittests/IR/VerifierTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/VerifierTest.cpp?rev=289702&r1=289701&r2=289702&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/VerifierTest.cpp (original)
+++ llvm/trunk/unittests/IR/VerifierTest.cpp Wed Dec 14 14:24:54 2016
@@ -154,8 +154,8 @@ TEST(VerifierTest, StripInvalidDebugInfo
LLVMContext C;
Module M("M", C);
DIBuilder DIB(M);
- DIB.createCompileUnit(dwarf::DW_LANG_C89, "broken.c", "/", "unittest",
- false, "", 0);
+ DIB.createCompileUnit(dwarf::DW_LANG_C89, DIB.createFile("broken.c", "/"),
+ "unittest", false, "", 0);
DIB.finalize();
EXPECT_FALSE(verifyModule(M));
@@ -176,7 +176,8 @@ TEST(VerifierTest, StripInvalidDebugInfo
LLVMContext C;
Module M("M", C);
DIBuilder DIB(M);
- auto *CU = DIB.createCompileUnit(dwarf::DW_LANG_C89, "broken.c", "/",
+ auto *CU = DIB.createCompileUnit(dwarf::DW_LANG_C89,
+ DIB.createFile("broken.c", "/"),
"unittest", false, "", 0);
new GlobalVariable(M, Type::getInt8Ty(C), false,
GlobalValue::ExternalLinkage, nullptr, "g");
@@ -208,7 +209,7 @@ TEST(VerifierTest, StripInvalidDebugInfo
LLVMContext C;
Module M("M", C);
DIBuilder DIB(M);
- DIB.createCompileUnit(dwarf::DW_LANG_C89, "broken.c", "/",
+ DIB.createCompileUnit(dwarf::DW_LANG_C89, DIB.createFile("broken.c", "/"),
"unittest", false, "", 0);
DIB.finalize();
EXPECT_FALSE(verifyModule(M));
Modified: llvm/trunk/unittests/Transforms/Utils/Cloning.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/Transforms/Utils/Cloning.cpp?rev=289702&r1=289701&r2=289702&view=diff
==============================================================================
--- llvm/trunk/unittests/Transforms/Utils/Cloning.cpp (original)
+++ llvm/trunk/unittests/Transforms/Utils/Cloning.cpp Wed Dec 14 14:24:54 2016
@@ -231,9 +231,10 @@ protected:
DITypeRefArray ParamTypes = DBuilder.getOrCreateTypeArray(None);
DISubroutineType *FuncType =
DBuilder.createSubroutineType(ParamTypes);
- auto *CU =
- DBuilder.createCompileUnit(dwarf::DW_LANG_C99, "filename.c",
- "/file/dir", "CloneFunc", false, "", 0);
+ auto *CU = DBuilder.createCompileUnit(dwarf::DW_LANG_C99,
+ DBuilder.createFile("filename.c",
+ "/file/dir"),
+ "CloneFunc", false, "", 0);
auto *Subprogram =
DBuilder.createFunction(CU, "f", "f", File, 4, FuncType, true, true, 3,
@@ -268,7 +269,8 @@ protected:
// Create another, empty, compile unit
DIBuilder DBuilder2(*M);
DBuilder2.createCompileUnit(dwarf::DW_LANG_C99,
- "extra.c", "/file/dir", "CloneFunc", false, "", 0);
+ DBuilder.createFile("extra.c", "/file/dir"),
+ "CloneFunc", false, "", 0);
DBuilder2.finalize();
}
@@ -422,9 +424,10 @@ protected:
auto *File = DBuilder.createFile("filename.c", "/file/dir/");
DITypeRefArray ParamTypes = DBuilder.getOrCreateTypeArray(None);
DISubroutineType *DFuncType = DBuilder.createSubroutineType(ParamTypes);
- auto *CU =
- DBuilder.createCompileUnit(dwarf::DW_LANG_C99, "filename.c",
- "/file/dir", "CloneModule", false, "", 0);
+ auto *CU = DBuilder.createCompileUnit(dwarf::DW_LANG_C99,
+ DBuilder.createFile("filename.c",
+ "/file/dir"),
+ "CloneModule", false, "", 0);
// Function DI
auto *Subprogram =
DBuilder.createFunction(CU, "f", "f", File, 4, DFuncType, true, true, 3,
More information about the llvm-commits
mailing list