[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 /* ... */ { /* ... */ };
  class BasicBlock : public Value, /* ... */ { /* ... */ };

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"?


More information about the llvm-commits mailing list