[PATCH] Cleaning up static initializers in InterferenceCache by moving the NoInterference static object into the class.

Chris Bieneman beanz at apple.com
Fri Oct 10 15:05:59 PDT 2014

Comment at: lib/CodeGen/InterferenceCache.h:174
@@ -173,3 +173,3 @@
     BlockInterference *Current;
-    static BlockInterference NoInterference;
+    BlockInterference NoInterference;
chandlerc wrote:
> I don't think you should make the Cursor object larger here. One of three options should be employed:
> 1) If possible, just construct a null temporary BlockInterference object where one is needed, or provide a factor function to do so.
> 2) Alternatively (perhaps if that fails because it needs to have identity), make this a static *constant* (ie, constant initialized, should be possible from glancing at it). You could even make it a constexpr when we have support for that.
> 3) If nothing else works, store it in the Entry, and reach it via the CacheEntry pointer.
Unfortunately I don't think any of these options work without significant reworking of the code.

  # We can't construct a null temporary because the way this code works is based on having a pointer to the BlockInterference object.
  # BlockInterference objects can't be statically initialized because they have user defined constructors and contain SlotIndex members. I don't think we can statically initialize those without constexpr.
  # Unfortunately it can't be in the CacheEntry either because the only time this is used is when CacheEntry is null.



More information about the llvm-commits mailing list