[llvm] r290698 - Add a static_assert about the sizeof(GlobalValue)
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Wed Dec 28 16:55:51 PST 2016
Author: rnk
Date: Wed Dec 28 18:55:51 2016
New Revision: 290698
URL: http://llvm.org/viewvc/llvm-project?rev=290698&view=rev
Log:
Add a static_assert about the sizeof(GlobalValue)
I added one for Value back in r262045, and I'm starting to think we
should have these for any class with bitfields whose memory efficiency
really matters.
Modified:
llvm/trunk/lib/IR/Globals.cpp
Modified: llvm/trunk/lib/IR/Globals.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Globals.cpp?rev=290698&r1=290697&r2=290698&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Globals.cpp (original)
+++ llvm/trunk/lib/IR/Globals.cpp Wed Dec 28 18:55:51 2016
@@ -30,6 +30,13 @@ using namespace llvm;
// GlobalValue Class
//===----------------------------------------------------------------------===//
+// GlobalValue should be a Constant, plus a type, a module, some flags, and an
+// intrinsic ID. Add an assert to prevent people from accidentally growing
+// GlobalValue while adding flags.
+static_assert(sizeof(GlobalValue) ==
+ sizeof(Constant) + 2 * sizeof(void *) + 2 * sizeof(unsigned),
+ "unexpected GlobalValue size growth");
+
bool GlobalValue::isMaterializable() const {
if (const Function *F = dyn_cast<Function>(this))
return F->isMaterializable();
More information about the llvm-commits
mailing list