Skip to content

Commit

Permalink
Add a static_assert about the sizeof(GlobalValue)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
rnk committed Dec 29, 2016
1 parent 7102a29 commit 9337818
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/IR/Globals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 9337818

Please sign in to comment.