[llvm] r266713 - IR: Rename API for enabling ODR uniquing of DITypes, NFC

Duncan P. N. Exon Smith via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 18 21:55:26 PDT 2016


Author: dexonsmith
Date: Mon Apr 18 23:55:25 2016
New Revision: 266713

URL: http://llvm.org/viewvc/llvm-project?rev=266713&view=rev
Log:
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

Modified:
    llvm/trunk/include/llvm/IR/LLVMContext.h
    llvm/trunk/lib/AsmParser/LLParser.cpp
    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
    llvm/trunk/lib/IR/LLVMContext.cpp
    llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
    llvm/trunk/tools/gold/gold-plugin.cpp
    llvm/trunk/tools/llvm-link/llvm-link.cpp
    llvm/trunk/unittests/IR/LLVMContextTest.cpp

Modified: llvm/trunk/include/llvm/IR/LLVMContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/LLVMContext.h?rev=266713&r1=266712&r2=266713&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/LLVMContext.h (original)
+++ llvm/trunk/include/llvm/IR/LLVMContext.h Mon Apr 18 23:55:25 2016
@@ -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);

Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=266713&r1=266712&r2=266713&view=diff
==============================================================================
--- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
+++ llvm/trunk/lib/AsmParser/LLParser.cpp Mon Apr 18 23:55:25 2016
@@ -3843,7 +3843,7 @@ bool LLParser::ParseDICompositeType(MDNo
   // 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;

Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=266713&r1=266712&r2=266713&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Mon Apr 18 23:55:25 2016
@@ -2194,7 +2194,7 @@ std::error_code BitcodeReader::parseMeta
       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;

Modified: llvm/trunk/lib/IR/LLVMContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/LLVMContext.cpp?rev=266713&r1=266712&r2=266713&view=diff
==============================================================================
--- llvm/trunk/lib/IR/LLVMContext.cpp (original)
+++ llvm/trunk/lib/IR/LLVMContext.cpp Mon Apr 18 23:55:25 2016
@@ -311,19 +311,19 @@ bool LLVMContext::shouldDiscardValueName
   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];
 }

Modified: llvm/trunk/lib/LTO/LTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTOCodeGenerator.cpp?rev=266713&r1=266712&r2=266713&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTOCodeGenerator.cpp (original)
+++ llvm/trunk/lib/LTO/LTOCodeGenerator.cpp Mon Apr 18 23:55:25 2016
@@ -84,7 +84,7 @@ LTOCodeGenerator::LTOCodeGenerator(LLVMC
     : Context(Context), MergedModule(new Module("ld-temp.o", Context)),
       TheLinker(new Linker(*MergedModule)) {
   Context.setDiscardValueNames(LTODiscardValueNames);
-  Context.ensureDITypeMap();
+  Context.enableDebugTypeODRUniquing();
   initializeLTOPasses();
 }
 

Modified: llvm/trunk/tools/gold/gold-plugin.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/gold/gold-plugin.cpp?rev=266713&r1=266712&r2=266713&view=diff
==============================================================================
--- llvm/trunk/tools/gold/gold-plugin.cpp (original)
+++ llvm/trunk/tools/gold/gold-plugin.cpp Mon Apr 18 23:55:25 2016
@@ -1114,7 +1114,7 @@ static void thinLTOBackendTask(claimed_f
                                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 allSymbolsReadHo
   }
 
   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));

Modified: llvm/trunk/tools/llvm-link/llvm-link.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-link/llvm-link.cpp?rev=266713&r1=266712&r2=266713&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-link/llvm-link.cpp (original)
+++ llvm/trunk/tools/llvm-link/llvm-link.cpp Mon Apr 18 23:55:25 2016
@@ -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);

Modified: llvm/trunk/unittests/IR/LLVMContextTest.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/unittests/IR/LLVMContextTest.cpp?rev=266713&r1=266712&r2=266713&view=diff
==============================================================================
--- llvm/trunk/unittests/IR/LLVMContextTest.cpp (original)
+++ llvm/trunk/unittests/IR/LLVMContextTest.cpp Mon Apr 18 23:55:25 2016
@@ -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, getOrInsertDITypeM
   *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




More information about the llvm-commits mailing list