summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2010-11-17 21:25:27 +0000
committerBob Wilson <bob.wilson@apple.com>2010-11-17 21:25:27 +0000
commitedf046716ce7d0da9479c37a5bbb6dd33ce6d390 (patch)
tree4a10914e829db118408b7b2c172f72f79fd45bc5
parent17ead4ff4baceb2c5503f233d0288d363ae44165 (diff)
downloadllvm-edf046716ce7d0da9479c37a5bbb6dd33ce6d390.tar.gz
llvm-edf046716ce7d0da9479c37a5bbb6dd33ce6d390.tar.bz2
llvm-edf046716ce7d0da9479c37a5bbb6dd33ce6d390.tar.xz
Fix the ARMGlobalMerge pass to look at variable sizes instead of pointer sizes.
It was mistakenly looking at the pointer type when checking for the size of global variables. This is a partial fix for Radar 8673120. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119563 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Target/ARM/ARMGlobalMerge.cpp2
-rw-r--r--test/CodeGen/ARM/global-merge.ll11
2 files changed, 12 insertions, 1 deletions
diff --git a/lib/Target/ARM/ARMGlobalMerge.cpp b/lib/Target/ARM/ARMGlobalMerge.cpp
index fdcb67062f..b25915a0bd 100644
--- a/lib/Target/ARM/ARMGlobalMerge.cpp
+++ b/lib/Target/ARM/ARMGlobalMerge.cpp
@@ -179,7 +179,7 @@ bool ARMGlobalMerge::doInitialization(Module &M) {
I->getName().startswith(".llvm."))
continue;
- if (TD->getTypeAllocSize(I->getType()) < MaxOffset) {
+ if (TD->getTypeAllocSize(I->getType()->getElementType()) < MaxOffset) {
if (I->isConstant())
ConstGlobals.push_back(I);
else
diff --git a/test/CodeGen/ARM/global-merge.ll b/test/CodeGen/ARM/global-merge.ll
new file mode 100644
index 0000000000..9cadebd9c5
--- /dev/null
+++ b/test/CodeGen/ARM/global-merge.ll
@@ -0,0 +1,11 @@
+; RUN: llc < %s -march=thumb | FileCheck %s
+; Test the ARMGlobalMerge pass. Use -march=thumb because it has a small
+; value for the maximum offset (127).
+
+; A local array that exceeds the maximum offset should not be merged.
+; CHECK: g0:
+@g0 = internal global [32 x i32] [ i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 1, i32 2 ]
+
+; CHECK: merged:
+@g1 = internal global i32 1
+@g2 = internal global i32 2