diff options
author | Bob Wilson <bob.wilson@apple.com> | 2010-11-17 21:25:36 +0000 |
---|---|---|
committer | Bob Wilson <bob.wilson@apple.com> | 2010-11-17 21:25:36 +0000 |
commit | 619a3726177c63a14e2822a80e6bc897be2e5a91 (patch) | |
tree | d53a5db9a75e6c1cd36f80127f4252c512f35b83 /lib/Target/ARM/ARMGlobalMerge.cpp | |
parent | 72831dc905c2354fc08762dbfd5f1b20fbd5b18b (diff) |
Fix ARMGlobalMerge pass to check if globals are entirely within range.
It is generally not sufficient to check if the starting offset is in range
of the maximum offset that can be efficiently used for the target.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119565 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Target/ARM/ARMGlobalMerge.cpp')
-rw-r--r-- | lib/Target/ARM/ARMGlobalMerge.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/Target/ARM/ARMGlobalMerge.cpp b/lib/Target/ARM/ARMGlobalMerge.cpp index 44d523569e..72cab6462c 100644 --- a/lib/Target/ARM/ARMGlobalMerge.cpp +++ b/lib/Target/ARM/ARMGlobalMerge.cpp @@ -129,11 +129,14 @@ bool ARMGlobalMerge::doMerge(SmallVectorImpl<GlobalVariable*> &Globals, uint64_t MergedSize = 0; std::vector<const Type*> Tys; std::vector<Constant*> Inits; - for (j = i; MergedSize < MaxOffset && j != e; ++j) { + for (j = i; j != e; ++j) { const Type *Ty = Globals[j]->getType()->getElementType(); + MergedSize += TD->getTypeAllocSize(Ty); + if (MergedSize > MaxOffset) { + break; + } Tys.push_back(Ty); Inits.push_back(Globals[j]->getInitializer()); - MergedSize += TD->getTypeAllocSize(Ty); } StructType *MergedTy = StructType::get(M.getContext(), Tys); |