diff options
| author | Stephen Hines <srhines@google.com> | 2013-03-20 04:33:54 +0000 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2013-03-20 04:33:54 +0000 |
| commit | 3dd51ae3a043f2edf9dd2bc7c906c3f602967e5a (patch) | |
| tree | 90c0395880593bf195fb818c2af1139cb7e846df /lib/CodeGen/MachineFunction.cpp | |
| parent | 84ba0bec3eb1a5f63c13a01e6d510ecd85fa6ab7 (diff) | |
| parent | 2d4629c5d7dcc6582fa7b85a517744f1a3654eba (diff) | |
| download | external_llvm-3dd51ae3a043f2edf9dd2bc7c906c3f602967e5a.zip external_llvm-3dd51ae3a043f2edf9dd2bc7c906c3f602967e5a.tar.gz external_llvm-3dd51ae3a043f2edf9dd2bc7c906c3f602967e5a.tar.bz2 | |
am 2d4629c5: Merge branch \'upstream\' into merge_2013_03_18
* commit '2d4629c5d7dcc6582fa7b85a517744f1a3654eba': (424 commits)
Change NULL to 0.
Register the flush function for each compile unit.
Remove trailing spaces.
Fix PPC unaligned 64-bit loads and stores
ARM cost model: Make some vector integer to float casts cheaper
ARM cost model: Correct cost for some cheap float to integer conversions
Extend global merge pass to optionally consider global constant variables. Also add some checks to not merge globals used within landing pad instructions or marked as "used".
Change test cases to handle unaligned references.
Remove unnecessary leading comment characters in lit-only file
Add SchedRW annotations to most of X86InstrSSE.td.
Annotate X86 arithmetic instructions with SchedRW lists.
Check whether a pointer is non-null (isKnownNonNull) in isKnownNonZero.
TableGen fix for the new machine model.
Include '.test' suffix in target specific lit configs that need it
Make the fields in the diagram match the descriptive text above them.
Update
Fix 80-col. violations in PPCCTRLoops
Fix large count and negative constant count handling in PPCCTRLoops
Cleanup initial-value constants in PPCCTRLoops
Fix integer comparison in DIEInteger::BestForm.
...
Diffstat (limited to 'lib/CodeGen/MachineFunction.cpp')
| -rw-r--r-- | lib/CodeGen/MachineFunction.cpp | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/lib/CodeGen/MachineFunction.cpp b/lib/CodeGen/MachineFunction.cpp index 5e04f2d..04321f3 100644 --- a/lib/CodeGen/MachineFunction.cpp +++ b/lib/CodeGen/MachineFunction.cpp @@ -574,6 +574,54 @@ MachineFrameInfo::getPristineRegs(const MachineBasicBlock *MBB) const { return BV; } +unsigned MachineFrameInfo::estimateStackSize(const MachineFunction &MF) const { + const TargetFrameLowering *TFI = MF.getTarget().getFrameLowering(); + const TargetRegisterInfo *RegInfo = MF.getTarget().getRegisterInfo(); + unsigned MaxAlign = getMaxAlignment(); + int Offset = 0; + + // This code is very, very similar to PEI::calculateFrameObjectOffsets(). + // It really should be refactored to share code. Until then, changes + // should keep in mind that there's tight coupling between the two. + + for (int i = getObjectIndexBegin(); i != 0; ++i) { + int FixedOff = -getObjectOffset(i); + if (FixedOff > Offset) Offset = FixedOff; + } + for (unsigned i = 0, e = getObjectIndexEnd(); i != e; ++i) { + if (isDeadObjectIndex(i)) + continue; + Offset += getObjectSize(i); + unsigned Align = getObjectAlignment(i); + // Adjust to alignment boundary + Offset = (Offset+Align-1)/Align*Align; + + MaxAlign = std::max(Align, MaxAlign); + } + + if (adjustsStack() && TFI->hasReservedCallFrame(MF)) + Offset += getMaxCallFrameSize(); + + // Round up the size to a multiple of the alignment. If the function has + // any calls or alloca's, align to the target's StackAlignment value to + // ensure that the callee's frame or the alloca data is suitably aligned; + // otherwise, for leaf functions, align to the TransientStackAlignment + // value. + unsigned StackAlign; + if (adjustsStack() || hasVarSizedObjects() || + (RegInfo->needsStackRealignment(MF) && getObjectIndexEnd() != 0)) + StackAlign = TFI->getStackAlignment(); + else + StackAlign = TFI->getTransientStackAlignment(); + + // If the frame pointer is eliminated, all frame offsets will be relative to + // SP not FP. Align to MaxAlign so this works. + StackAlign = std::max(StackAlign, MaxAlign); + unsigned AlignMask = StackAlign - 1; + Offset = (Offset + AlignMask) & ~uint64_t(AlignMask); + + return (unsigned)Offset; +} void MachineFrameInfo::print(const MachineFunction &MF, raw_ostream &OS) const{ if (Objects.empty()) return; |
