diff options
| author | Bill Wendling <isanbard@gmail.com> | 2010-05-26 00:32:40 +0000 |
|---|---|---|
| committer | Bill Wendling <isanbard@gmail.com> | 2010-05-26 00:32:40 +0000 |
| commit | c5222d6c3821a05fdc0fc2f4245a769b50a67e45 (patch) | |
| tree | fd0fa6022344cd4792ddf7c10777f33ce3a5dcea /llvm/lib/CodeGen/SelectionDAG | |
| parent | 0b0274524cca2165b175c9ea4701f8353f8894a4 (diff) | |
| download | bcm5719-llvm-c5222d6c3821a05fdc0fc2f4245a769b50a67e45.tar.gz bcm5719-llvm-c5222d6c3821a05fdc0fc2f4245a769b50a67e45.zip | |
Dale and Evan suggested putting the "check for setjmp" much earlier in the
machine code generation. That's a good idea, so I made it so.
llvm-svn: 104655
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
| -rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp index 6d789a674cf..7e40cb9c640 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp @@ -25,6 +25,7 @@ #include "llvm/Intrinsics.h" #include "llvm/IntrinsicInst.h" #include "llvm/LLVMContext.h" +#include "llvm/Module.h" #include "llvm/CodeGen/FastISel.h" #include "llvm/CodeGen/GCStrategy.h" #include "llvm/CodeGen/GCMetadata.h" @@ -253,6 +254,39 @@ bool SelectionDAGISel::runOnMachineFunction(MachineFunction &mf) { done:; } + // Set a flag indicating if the machine function makes a call to setjmp / + // sigsetjmp (i.e., a function marked "returns_twice"). We'll use this to + // disable certain optimizations which cannot handle such control flows. + // + // FIXME: This goes beyond the setjmp/sigsetjmp functions. We should check for + // the GCC "returns twice" attribute. + const Module *M = Fn.getParent(); + const Function *SetJmp = M->getFunction("setjmp"); + const Function *SigSetJmp = M->getFunction("sigsetjmp"); + bool HasReturnsTwiceCall = false; + + if (SetJmp || SigSetJmp) { + 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() == &Fn) { + HasReturnsTwiceCall = true; + break; + } + + if (!HasReturnsTwiceCall && 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() == &Fn) { + HasReturnsTwiceCall = true; + break; + } + + mf.setReturnsTwiceCall(HasReturnsTwiceCall); + } + // Release function-specific state. SDB and CurDAG are already cleared // at this point. FuncInfo->clear(); |

