diff options
author | Dan Gohman <gohman@apple.com> | 2010-07-28 20:56:48 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2010-07-28 20:56:48 +0000 |
commit | 6bbe671e1c58dd58fcf0165c1127dda5037ad3e2 (patch) | |
tree | 0b758a76465b6fad8e13cce392747a1ac73556a5 /lib | |
parent | 4c010ec85185e2f1d671ac17a387b55228199d5b (diff) |
Make GlobalValue alignment consistent with load, store, and alloca
alignment, fixing silent truncation of alignment values.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@109653 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/VMCore/Globals.cpp | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/VMCore/Globals.cpp b/lib/VMCore/Globals.cpp index b758eb8702..96716eeb34 100644 --- a/lib/VMCore/Globals.cpp +++ b/lib/VMCore/Globals.cpp @@ -102,7 +102,14 @@ void GlobalValue::copyAttributesFrom(const GlobalValue *Src) { setVisibility(Src->getVisibility()); } - +void GlobalValue::setAlignment(unsigned Align) { + assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!"); + assert(Align <= MaximumAlignment && + "Alignment is greater than MaximumAlignment!"); + Alignment = Log2_32(Align) + 1; + assert(getAlignment() == Align && "Alignment representation error!"); +} + //===----------------------------------------------------------------------===// // GlobalVariable Implementation //===----------------------------------------------------------------------===// |