[PATCH] Add 32-bit alignment minimum for globals in Thumb1 code
Moritz Roth
moritz.roth11 at gmail.com
Thu Apr 17 08:08:17 PDT 2014
Thumb1 already requests small types to be word-aligned. This patch extends that requirement to globals by setting the minimum alignment for them to 32 bits.
http://reviews.llvm.org/D3411
Files:
../tools/clang/test/CodeGenCXX/arm.cpp
../tools/clang/lib/Basic/Targets.cpp
Index: ../tools/clang/test/CodeGenCXX/arm.cpp
===================================================================
--- ../tools/clang/test/CodeGenCXX/arm.cpp
+++ ../tools/clang/test/CodeGenCXX/arm.cpp
@@ -2,7 +2,7 @@
// CHECK: @_ZZN5test74testEvE1x = internal global i32 0, align 4
// CHECK: @_ZGVZN5test74testEvE1x = internal global i32 0
-// CHECK: @_ZZN5test84testEvE1x = internal global [[TEST8A:.*]] zeroinitializer, align 1
+// CHECK: @_ZZN5test84testEvE1x = internal global [[TEST8A:.*]] zeroinitializer, align 4
// CHECK: @_ZGVZN5test84testEvE1x = internal global i32 0
typedef typeof(sizeof(int)) size_t;
Index: ../tools/clang/lib/Basic/Targets.cpp
===================================================================
--- ../tools/clang/lib/Basic/Targets.cpp
+++ ../tools/clang/lib/Basic/Targets.cpp
@@ -3777,6 +3777,8 @@
if (IsThumb) {
// Thumb1 add sp, #imm requires the immediate value be multiple of 4,
// so set preferred for small types to 32.
+ MinGlobalAlign = 32;
+
if (T.isOSBinFormatMachO()) {
DescriptionString = BigEndian ?
"E-m:o-p:32:32-i1:8:32-i8:8:32-i16:16:32-i64:64-"
@@ -3843,6 +3845,8 @@
if (IsThumb) {
// Thumb1 add sp, #imm requires the immediate value be multiple of 4,
// so set preferred for small types to 32.
+ MinGlobalAlign = 32;
+
if (T.isOSBinFormatMachO())
DescriptionString = BigEndian ?
"E-m:o-p:32:32-i1:8:32-i8:8:32-i16:16:32-f64:32:64"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3411.1.patch
Type: text/x-patch
Size: 1513 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140417/307ae9bb/attachment.bin>
More information about the cfe-commits
mailing list