diff options
author | Eric Christopher <echristo@apple.com> | 2010-05-26 01:59:55 +0000 |
---|---|---|
committer | Eric Christopher <echristo@apple.com> | 2010-05-26 01:59:55 +0000 |
commit | 174e597d466547d34cf8fcd2a95976e0cf5ebbac (patch) | |
tree | 44a098a405e1b13f0012f074584db93d6ec2afa8 /lib/CodeGen/StackSlotColoring.cpp | |
parent | 54e13eceff09ee79dc6408be990aabdee1a561dc (diff) |
Temporarily revert r104655 as it's breaking the bots.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@104664 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/StackSlotColoring.cpp')
-rw-r--r-- | lib/CodeGen/StackSlotColoring.cpp | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/lib/CodeGen/StackSlotColoring.cpp b/lib/CodeGen/StackSlotColoring.cpp index 354878aa42..8043556349 100644 --- a/lib/CodeGen/StackSlotColoring.cpp +++ b/lib/CodeGen/StackSlotColoring.cpp @@ -118,6 +118,7 @@ namespace { private: void InitializeSlots(); + bool CheckForSetJmpCall(const MachineFunction &MF) const; void ScanForSpillSlotRefs(MachineFunction &MF); bool OverlapWithAssignments(LiveInterval *li, int Color) const; int ColorSlot(LiveInterval *li); @@ -161,6 +162,34 @@ namespace { }; } +/// CheckForSetJmpCall - Return true if there's a call to setjmp/sigsetjmp in +/// this function. +bool StackSlotColoring::CheckForSetJmpCall(const MachineFunction &MF) const { + const Function *F = MF.getFunction(); + const Module *M = F->getParent(); + const Function *SetJmp = M->getFunction("setjmp"); + const Function *SigSetJmp = M->getFunction("sigsetjmp"); + + if (!SetJmp && !SigSetJmp) + return false; + + if (SetJmp && !SetJmp->use_empty()) + for (Value::const_use_iterator + I = SetJmp->use_begin(), E = SetJmp->use_end(); I != E; ++I) + if (const CallInst *CI = dyn_cast<CallInst>(I)) + if (CI->getParent()->getParent() == F) + return true; + + if (SigSetJmp && !SigSetJmp->use_empty()) + for (Value::const_use_iterator + I = SigSetJmp->use_begin(), E = SigSetJmp->use_end(); I != E; ++I) + if (const CallInst *CI = dyn_cast<CallInst>(I)) + if (CI->getParent()->getParent() == F) + return true; + + return false; +} + /// ScanForSpillSlotRefs - Scan all the machine instructions for spill slot /// references and update spill slot weights. void StackSlotColoring::ScanForSpillSlotRefs(MachineFunction &MF) { @@ -724,11 +753,14 @@ bool StackSlotColoring::runOnMachineFunction(MachineFunction &MF) { return false; } - // If there is a call to a function with the attribute "returns_twice" (like - // setjmp or sigsetjmp), don't perform stack slot coloring. The stack could be - // modified before the the second return, resulting in the wrong value being - // used afterwards. (See <rdar://problem/8007500>.) - if (MF.hasReturnsTwiceCall()) + // If there are calls to setjmp or sigsetjmp, don't perform stack slot + // coloring. The stack could be modified before the longjmp is executed, + // resulting in the wrong value being used afterwards. (See + // <rdar://problem/8007500>.) + // + // FIXME: This goes beyond the setjmp/sigsetjmp functions. Ideally, we should + // check for the GCC "returns twice" attribute. + if (CheckForSetJmpCall(MF)) return false; // Gather spill slot references |