diff options
author | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-19 04:55:25 +0000 |
---|---|---|
committer | Duncan P. N. Exon Smith <dexonsmith@apple.com> | 2016-04-19 04:55:25 +0000 |
commit | ed8fdb2a0e9503abbac7c0927d2915cd8bac03d2 (patch) | |
tree | ada4253e3e564ec1531ca53c5eab3b9fb329f485 | |
parent | 51a9bd2e110f43eb9df14e1daffd89fd0332b9f0 (diff) | |
download | bcm5719-llvm-ed8fdb2a0e9503abbac7c0927d2915cd8bac03d2.tar.gz bcm5719-llvm-ed8fdb2a0e9503abbac7c0927d2915cd8bac03d2.zip |
IR: Rename API for enabling ODR uniquing of DITypes, NFC
As per David's review, rename everything in the new API for ODR type
uniquing of debug info.
ensureDITypeMap => enableDebugTypeODRUniquing
destroyDITypeMap => disableDebugTypeODRUniquing
hasDITypeMap => isODRUniquingDebugTypes
llvm-svn: 266713
-rw-r--r-- | llvm/include/llvm/IR/LLVMContext.h | 16 | ||||
-rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/IR/LLVMContext.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/LTO/LTOCodeGenerator.cpp | 2 | ||||
-rw-r--r-- | llvm/tools/gold/gold-plugin.cpp | 4 | ||||
-rw-r--r-- | llvm/tools/llvm-link/llvm-link.cpp | 2 | ||||
-rw-r--r-- | llvm/unittests/IR/LLVMContextTest.cpp | 30 |
8 files changed, 34 insertions, 34 deletions
diff --git a/llvm/include/llvm/IR/LLVMContext.h b/llvm/include/llvm/IR/LLVMContext.h index 34541995c4c..2b0dfaf5598 100644 --- a/llvm/include/llvm/IR/LLVMContext.h +++ b/llvm/include/llvm/IR/LLVMContext.h @@ -115,22 +115,22 @@ public: /// especially in release mode. void setDiscardValueNames(bool Discard); - /// Whether there is a string map for uniquing debug info types with + /// Whether there is a string map for uniquing debug info /// identifiers across the context. Off by default. - bool hasDITypeMap() const; - void ensureDITypeMap(); - void destroyDITypeMap(); + bool isODRUniquingDebugTypes() const; + void enableDebugTypeODRUniquing(); + void disableDebugTypeODRUniquing(); /// Get or insert the DIType mapped to the given string. /// /// Returns the address of the current \a DIType pointer mapped to \c S, /// inserting a mapping to \c nullptr if \c S was not previously mapped. /// This method has no effect (and returns \c nullptr instead of a valid - /// address) if \a hasDITypeMap() is \c false. + /// address) if \a isODRUniquingDebugTypes() is \c false. /// - /// \post If \a hasDITypeMap(), \c S will have a (possibly null) mapping. - /// \note The returned address is only valid until the next call. - DIType **getOrInsertDITypeMapping(const MDString &S); + /// \post If \a isODRUniquingDebugTypes(), \c S will have a (possibly null) + /// mapping. \note The returned address is only valid until the next call. + DIType **getOrInsertODRUniquedType(const MDString &S); typedef void (*InlineAsmDiagHandlerTy)(const SMDiagnostic&, void *Context, unsigned LocCookie); diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index 34f7ec4469b..987ab5de967 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -3843,7 +3843,7 @@ bool LLParser::ParseDICompositeType(MDNode *&Result, bool IsDistinct) { // type map in the context. DIType **MappedT = nullptr; if (!(flags.Val & DINode::FlagFwdDecl) && identifier.Val && - (MappedT = Context.getOrInsertDITypeMapping(*identifier.Val)) && + (MappedT = Context.getOrInsertODRUniquedType(*identifier.Val)) && *MappedT) { Result = *MappedT; return false; diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 18386ed0727..1a83359b6e8 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -2194,7 +2194,7 @@ std::error_code BitcodeReader::parseMetadata(bool ModuleLevel) { auto *Identifier = getMDString(Record[15]); DIType **MappedT = nullptr; if (!(Flags & DINode::FlagFwdDecl) && Identifier) - MappedT = Context.getOrInsertDITypeMapping(*Identifier); + MappedT = Context.getOrInsertODRUniquedType(*Identifier); // Use the mapped type node, or create a new one if necessary. DIType *CT = MappedT ? *MappedT : nullptr; diff --git a/llvm/lib/IR/LLVMContext.cpp b/llvm/lib/IR/LLVMContext.cpp index 3fc79ed03c3..e166a551ade 100644 --- a/llvm/lib/IR/LLVMContext.cpp +++ b/llvm/lib/IR/LLVMContext.cpp @@ -311,19 +311,19 @@ bool LLVMContext::shouldDiscardValueNames() const { return pImpl->DiscardValueNames; } -bool LLVMContext::hasDITypeMap() const { return !!pImpl->DITypeMap; } +bool LLVMContext::isODRUniquingDebugTypes() const { return !!pImpl->DITypeMap; } -void LLVMContext::ensureDITypeMap() { +void LLVMContext::enableDebugTypeODRUniquing() { if (pImpl->DITypeMap) return; pImpl->DITypeMap = llvm::make_unique<DenseMap<const MDString *, DIType *>>(); } -void LLVMContext::destroyDITypeMap() { pImpl->DITypeMap.reset(); } +void LLVMContext::disableDebugTypeODRUniquing() { pImpl->DITypeMap.reset(); } -DIType **LLVMContext::getOrInsertDITypeMapping(const MDString &S) { - if (!hasDITypeMap()) +DIType **LLVMContext::getOrInsertODRUniquedType(const MDString &S) { + if (!isODRUniquingDebugTypes()) return nullptr; return &(*pImpl->DITypeMap)[&S]; } diff --git a/llvm/lib/LTO/LTOCodeGenerator.cpp b/llvm/lib/LTO/LTOCodeGenerator.cpp index a1d4d7bd101..e06903ca37b 100644 --- a/llvm/lib/LTO/LTOCodeGenerator.cpp +++ b/llvm/lib/LTO/LTOCodeGenerator.cpp @@ -84,7 +84,7 @@ LTOCodeGenerator::LTOCodeGenerator(LLVMContext &Context) : Context(Context), MergedModule(new Module("ld-temp.o", Context)), TheLinker(new Linker(*MergedModule)) { Context.setDiscardValueNames(LTODiscardValueNames); - Context.ensureDITypeMap(); + Context.enableDebugTypeODRUniquing(); initializeLTOPasses(); } diff --git a/llvm/tools/gold/gold-plugin.cpp b/llvm/tools/gold/gold-plugin.cpp index 9a78c56b96a..1c78d2fc745 100644 --- a/llvm/tools/gold/gold-plugin.cpp +++ b/llvm/tools/gold/gold-plugin.cpp @@ -1114,7 +1114,7 @@ static void thinLTOBackendTask(claimed_file &F, const void *View, raw_fd_ostream *OS, unsigned TaskID) { // Need to use a separate context for each task LLVMContext Context; - Context.ensureDITypeMap(); // Merge debug info types. + Context.enableDebugTypeODRUniquing(); // Merge debug info types. Context.setDiagnosticHandler(diagnosticHandlerForContext, nullptr, true); std::unique_ptr<llvm::Module> NewModule(new llvm::Module(File.name, Context)); @@ -1236,7 +1236,7 @@ static ld_plugin_status allSymbolsReadHook(raw_fd_ostream *ApiFile) { } LLVMContext Context; - Context.ensureDITypeMap(); // Merge debug info types. + Context.enableDebugTypeODRUniquing(); // Merge debug info types. Context.setDiagnosticHandler(diagnosticHandlerForContext, nullptr, true); std::unique_ptr<Module> Combined(new Module("ld-temp.o", Context)); diff --git a/llvm/tools/llvm-link/llvm-link.cpp b/llvm/tools/llvm-link/llvm-link.cpp index 2dac8eabaee..73ac8727e71 100644 --- a/llvm/tools/llvm-link/llvm-link.cpp +++ b/llvm/tools/llvm-link/llvm-link.cpp @@ -342,7 +342,7 @@ int main(int argc, char **argv) { cl::ParseCommandLineOptions(argc, argv, "llvm linker\n"); if (!DisableDITypeMap) - Context.ensureDITypeMap(); + Context.enableDebugTypeODRUniquing(); auto Composite = make_unique<Module>("llvm-link", Context); Linker L(*Composite); diff --git a/llvm/unittests/IR/LLVMContextTest.cpp b/llvm/unittests/IR/LLVMContextTest.cpp index 16cf0745e09..f1eeb05b1cb 100644 --- a/llvm/unittests/IR/LLVMContextTest.cpp +++ b/llvm/unittests/IR/LLVMContextTest.cpp @@ -14,25 +14,25 @@ using namespace llvm; namespace { -TEST(LLVMContextTest, ensureDITypeMap) { +TEST(LLVMContextTest, enableDebugTypeODRUniquing) { LLVMContext Context; - EXPECT_FALSE(Context.hasDITypeMap()); - Context.ensureDITypeMap(); - EXPECT_TRUE(Context.hasDITypeMap()); - Context.destroyDITypeMap(); - EXPECT_FALSE(Context.hasDITypeMap()); + EXPECT_FALSE(Context.isODRUniquingDebugTypes()); + Context.enableDebugTypeODRUniquing(); + EXPECT_TRUE(Context.isODRUniquingDebugTypes()); + Context.disableDebugTypeODRUniquing(); + EXPECT_FALSE(Context.isODRUniquingDebugTypes()); } -TEST(LLVMContextTest, getOrInsertDITypeMapping) { +TEST(LLVMContextTest, getOrInsertODRUniquedType) { LLVMContext Context; const MDString &S = *MDString::get(Context, "string"); // Without a type map, this should return null. - EXPECT_FALSE(Context.getOrInsertDITypeMapping(S)); + EXPECT_FALSE(Context.getOrInsertODRUniquedType(S)); // Get the mapping. - Context.ensureDITypeMap(); - DIType **Mapping = Context.getOrInsertDITypeMapping(S); + Context.enableDebugTypeODRUniquing(); + DIType **Mapping = Context.getOrInsertODRUniquedType(S); ASSERT_TRUE(Mapping); // Create some type and add it to the mapping. @@ -41,17 +41,17 @@ TEST(LLVMContextTest, getOrInsertDITypeMapping) { *Mapping = &BT; // Check that we get it back. - Mapping = Context.getOrInsertDITypeMapping(S); + Mapping = Context.getOrInsertODRUniquedType(S); ASSERT_TRUE(Mapping); EXPECT_EQ(&BT, *Mapping); // Check that it's discarded with the type map. - Context.destroyDITypeMap(); - EXPECT_FALSE(Context.getOrInsertDITypeMapping(S)); + Context.disableDebugTypeODRUniquing(); + EXPECT_FALSE(Context.getOrInsertODRUniquedType(S)); // And it shouldn't magically reappear... - Context.ensureDITypeMap(); - EXPECT_FALSE(*Context.getOrInsertDITypeMapping(S)); + Context.enableDebugTypeODRUniquing(); + EXPECT_FALSE(*Context.getOrInsertODRUniquedType(S)); } } // end namespace |