[PATCH] D31261: [IR] De-virtualize ~Value to save a vptr

George Burgess IV via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 22 15:21:48 PDT 2017


george.burgess.iv added a comment.

Thanks for working on this!

> I think we need some way of checking this at compile time, because developers are going to trip over this



  #define NO_VIRTUALS_ALLOWED(cls) static_assert(!std::is_polymorphic<cls>::value, #cls " is not allowed to have virtual methods");
  
  class Value /* ... */ { /* ... */ };
  NO_VIRTUALS_ALLOWED(Value);
  
  class BasicBlock : public Value, /* ... */ { /* ... */ };
  NO_VIRTUALS_ALLOWED(BasicBlock);

might be a good starting point. Can't think of a way to make it automagically apply to subclasses, though.



================
Comment at: include/llvm/IR/DerivedUser.h:28
+/// Extension point for the Value hierarchy. All classes outside of lib/IR
+/// that wish to inherit from User should instead inherit from DerivedUser
+/// instead.
----------------
"instead inherit from DerivedUser instead"?


https://reviews.llvm.org/D31261





More information about the llvm-commits mailing list