summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/Globals.cpp
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2016-12-29 00:55:51 +0000
committerReid Kleckner <rnk@google.com>2016-12-29 00:55:51 +0000
commite9c8d7f87bb8164cc3e883e55f0af63dc041ad92 (patch)
tree9efe83c67cbae756669644c63e85bbe69010ce70 /llvm/lib/IR/Globals.cpp
parent7ad1ea0984eaefd4e508c940bbaf2c86e6d2c3c7 (diff)
downloadbcm5719-llvm-e9c8d7f87bb8164cc3e883e55f0af63dc041ad92.tar.gz
bcm5719-llvm-e9c8d7f87bb8164cc3e883e55f0af63dc041ad92.zip
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. llvm-svn: 290698
Diffstat (limited to 'llvm/lib/IR/Globals.cpp')
-rw-r--r--llvm/lib/IR/Globals.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/llvm/lib/IR/Globals.cpp b/llvm/lib/IR/Globals.cpp
index 7cad629eaa7..31f89514151 100644
--- a/llvm/lib/IR/Globals.cpp
+++ b/llvm/lib/IR/Globals.cpp
@@ -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();
OpenPOWER on IntegriCloud