diff options
author | Vikram S. Adve <vadve@cs.uiuc.edu> | 2002-03-24 03:39:26 +0000 |
---|---|---|
committer | Vikram S. Adve <vadve@cs.uiuc.edu> | 2002-03-24 03:39:26 +0000 |
commit | e4e4d4e2f9d49855712f6dc9e785d5d9416f0dab (patch) | |
tree | 1d754e1eb6d9cfcac71dab5f7683f6889448f09d /lib/CodeGen/MachineFunction.cpp | |
parent | c941b87397877a2fc76980935765e70262828e4c (diff) |
Fix padding for variables allocated on stack.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1969 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/MachineFunction.cpp')
-rw-r--r-- | lib/CodeGen/MachineFunction.cpp | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp index 8e1a80b37e..de3e4f694f 100644 --- a/lib/CodeGen/MachineFunction.cpp +++ b/lib/CodeGen/MachineFunction.cpp @@ -134,49 +134,54 @@ MachineCodeForMethod::MachineCodeForMethod(const Method* _M, int MachineCodeForMethod::computeOffsetforLocalVar(const TargetMachine& target, const Value* val, - unsigned int size) + unsigned int& getPaddedSize, + unsigned int sizeToUse = 0) { bool growUp; int firstOffset =target.getFrameInfo().getFirstAutomaticVarOffset(*this, growUp); unsigned char align; - if (size == 0) + if (sizeToUse == 0) { - size = target.findOptimalStorageSize(val->getType()); + sizeToUse = target.findOptimalStorageSize(val->getType()); // align = target.DataLayout.getTypeAlignment(val->getType()); } - - align = SizeToAlignment(size, target); + + align = SizeToAlignment(sizeToUse, target); int offset = getAutomaticVarsSize(); if (! growUp) - offset += size; + offset += sizeToUse; if (unsigned int mod = offset % align) { - offset += align - mod; - size += align - mod; + offset += align - mod; + getPaddedSize = sizeToUse + align - mod; } - + else + getPaddedSize = sizeToUse; + offset = growUp? firstOffset + offset : firstOffset - offset; - + return offset; } int MachineCodeForMethod::allocateLocalVar(const TargetMachine& target, const Value* val, - unsigned int size) + unsigned int sizeToUse = 0) { // Check if we've allocated a stack slot for this value already // int offset = getOffset(val); if (offset == INVALID_FRAME_OFFSET) { - offset = this->computeOffsetforLocalVar(target, val, size); + unsigned int getPaddedSize; + offset = this->computeOffsetforLocalVar(target, val, getPaddedSize, + sizeToUse); offsets[val] = offset; - incrementAutomaticVarsSize(size); + incrementAutomaticVarsSize(getPaddedSize); } return offset; } |