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 | 4c8ab19c225ea95587bf06dc5d2107c59e1678a4 (patch) | |
| tree | f2f2f23e6f5e013f9c698b70ca2a40d7c132778c /llvm/lib/Target/ARM/ARMGlobalMerge.cpp | |
| parent | 59182fb4b5c2aa82a9e3d6cd0d69a46728e5fa73 (diff) | |
| download | llvm-4c8ab19c225ea95587bf06dc5d2107c59e1678a4.zip llvm-4c8ab19c225ea95587bf06dc5d2107c59e1678a4.tar.gz llvm-4c8ab19c225ea95587bf06dc5d2107c59e1678a4.tar.bz2 | |
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.
llvm-svn: 119565
Diffstat (limited to 'llvm/lib/Target/ARM/ARMGlobalMerge.cpp')
| -rw-r--r-- | llvm/lib/Target/ARM/ARMGlobalMerge.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/llvm/lib/Target/ARM/ARMGlobalMerge.cpp b/llvm/lib/Target/ARM/ARMGlobalMerge.cpp index 44d5235..72cab64 100644 --- a/llvm/lib/Target/ARM/ARMGlobalMerge.cpp +++ b/llvm/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); |
