From 36f848cda19e5a20a506a2c305ca8cc93b9bc14c Mon Sep 17 00:00:00 2001 From: Reid Kleckner Date: Thu, 29 Dec 2016 00:55:51 +0000 Subject: [PATCH] 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 --- lib/IR/Globals.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/IR/Globals.cpp b/lib/IR/Globals.cpp index 7cad629eaa7..31f89514151 100644 --- a/lib/IR/Globals.cpp +++ b/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(this)) return F->isMaterializable();