From 9337818f107b40e4cca7180eddd7449b8c528cf3 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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@290698 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/IR/Globals.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/IR/Globals.cpp b/lib/IR/Globals.cpp index 7cad629eaa7d..31f89514151c 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();