[llvm-commits] [poolalloc] r120085 - /poolalloc/trunk/lib/DSA/Local.cpp
Arushi Aggarwal
aggarwa4 at illinois.edu
Tue Nov 23 21:13:48 PST 2010
Author: aggarwa4
Date: Tue Nov 23 23:13:48 2010
New Revision: 120085
URL: http://llvm.org/viewvc/llvm-project?rev=120085&view=rev
Log:
Allow for correct growing of size for Struct Type nodes.
Modified:
poolalloc/trunk/lib/DSA/Local.cpp
Modified: poolalloc/trunk/lib/DSA/Local.cpp
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/Local.cpp?rev=120085&r1=120084&r2=120085&view=diff
==============================================================================
--- poolalloc/trunk/lib/DSA/Local.cpp (original)
+++ poolalloc/trunk/lib/DSA/Local.cpp Tue Nov 23 23:13:48 2010
@@ -565,12 +565,18 @@
const ConstantInt* CUI = cast<ConstantInt>(I.getOperand());
int FieldNo = CUI->getSExtValue();
// increment the offset by the actual byte offset being accessed
- Offset += (unsigned)TD.getStructLayout(STy)->getElementOffset(FieldNo);
+ unsigned requiredSize = TD.getTypeAllocSize(STy) + Value.getOffset() + Offset;
if(!Value.getNode()->isArrayNode() || Value.getNode()->getSize() <= 0){
- if (TD.getTypeAllocSize(STy) + Value.getOffset() > Value.getNode()->getSize())
- Value.getNode()->growSize(TD.getTypeAllocSize(STy) + Value.getOffset());
+ if (requiredSize > Value.getNode()->getSize())
+ Value.getNode()->growSize(requiredSize);
+ } else {
+ if (((Offset + Value.getOffset()) % Value.getNode()->getSize()) == 0
+ && (TD.getTypeAllocSize(STy) % Value.getNode()->getSize() == 0))
+ Value.getNode()->growSize(requiredSize);
}
+
+ Offset += (unsigned)TD.getStructLayout(STy)->getElementOffset(FieldNo);
} else if(const ArrayType *ATy = dyn_cast<ArrayType>(*I)) {
// indexing into an array.
More information about the llvm-commits
mailing list