[llvm-commits] [llvm] r109653 - in /llvm/trunk: include/llvm/GlobalValue.h lib/VMCore/Globals.cpp test/Assembler/align-inst.ll
Dan Gohman
gohman at apple.com
Wed Jul 28 13:56:48 PDT 2010
Author: djg
Date: Wed Jul 28 15:56:48 2010
New Revision: 109653
URL: http://llvm.org/viewvc/llvm-project?rev=109653&view=rev
Log:
Make GlobalValue alignment consistent with load, store, and alloca
alignment, fixing silent truncation of alignment values.
Modified:
llvm/trunk/include/llvm/GlobalValue.h
llvm/trunk/lib/VMCore/Globals.cpp
llvm/trunk/test/Assembler/align-inst.ll
Modified: llvm/trunk/include/llvm/GlobalValue.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/GlobalValue.h?rev=109653&r1=109652&r2=109653&view=diff
==============================================================================
--- llvm/trunk/include/llvm/GlobalValue.h (original)
+++ llvm/trunk/include/llvm/GlobalValue.h Wed Jul 28 15:56:48 2010
@@ -74,11 +74,10 @@
removeDeadConstantUsers(); // remove any dead constants using this.
}
- unsigned getAlignment() const { return Alignment; }
- void setAlignment(unsigned Align) {
- assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
- Alignment = Align;
+ unsigned getAlignment() const {
+ return (1u << Alignment) >> 1;
}
+ void setAlignment(unsigned Align);
VisibilityTypes getVisibility() const { return VisibilityTypes(Visibility); }
bool hasDefaultVisibility() const { return Visibility == DefaultVisibility; }
Modified: llvm/trunk/lib/VMCore/Globals.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Globals.cpp?rev=109653&r1=109652&r2=109653&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Globals.cpp (original)
+++ llvm/trunk/lib/VMCore/Globals.cpp Wed Jul 28 15:56:48 2010
@@ -102,7 +102,14 @@
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
//===----------------------------------------------------------------------===//
Modified: llvm/trunk/test/Assembler/align-inst.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Assembler/align-inst.ll?rev=109653&r1=109652&r2=109653&view=diff
==============================================================================
--- llvm/trunk/test/Assembler/align-inst.ll (original)
+++ llvm/trunk/test/Assembler/align-inst.ll Wed Jul 28 15:56:48 2010
@@ -1,5 +1,7 @@
; RUN: llvm-as %s -o /dev/null
+ at A = global i1 0, align 536870912
+
define void @foo() {
%p = alloca i1, align 536870912
load i1* %p, align 536870912
More information about the llvm-commits
mailing list