]> granicus.if.org Git - llvm/commitdiff
[IR] Don't call assertModuleIsMaterialized in release builds
authorCraig Topper <craig.topper@gmail.com>
Fri, 13 Jan 2017 06:26:18 +0000 (06:26 +0000)
committerCraig Topper <craig.topper@gmail.com>
Fri, 13 Jan 2017 06:26:18 +0000 (06:26 +0000)
Summary:
To fix a release vs debug build linking error, r259695 made the body of assertModuleIsMaterialized empty if Value.cpp gets compiled in a release build. This way any code compiled as a debug build can still link against a release version of the function.

This patch takes this a step farther and removes all calls to it from Value.h in any code that includes it in a relase build.

This shrinks the opt binary on my macbook build by 17240 bytes.

Reviewers: rafael

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D28191

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291883 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/IR/Value.h
lib/IR/Value.cpp

index bdafbbf58cc45f191c9791def9fca4b70061dcec..9c91f4e07e330fa2597e738c32e3b130f48f7578 100644 (file)
@@ -294,7 +294,15 @@ public:
   // when using them since you might not get all uses.
   // The methods that don't start with materialized_ assert that modules is
   // fully materialized.
-  void assertModuleIsMaterialized() const;
+  void assertModuleIsMaterializedImpl() const;
+  // This indirection exists so we can keep assertModuleIsMaterializedImpl()
+  // around in release builds of Value.cpp to be linked with other code built
+  // in debug mode. But this avoids calling it in any of the release built code.
+  void assertModuleIsMaterialized() const {
+#ifndef NDEBUG
+    assertModuleIsMaterializedImpl();
+#endif
+  }
 
   bool use_empty() const {
     assertModuleIsMaterialized();
index 91a999b58004755f8d2e082e3b8de362f5e0d94b..d86d7fc11643706e4f7af5e174d83b2d0330e5d8 100644 (file)
@@ -320,7 +320,7 @@ void Value::takeName(Value *V) {
     ST->reinsertValue(this);
 }
 
-void Value::assertModuleIsMaterialized() const {
+void Value::assertModuleIsMaterializedImpl() const {
 #ifndef NDEBUG
   const GlobalValue *GV = dyn_cast<GlobalValue>(this);
   if (!GV)