diff options
author | John Criswell <criswell@uiuc.edu> | 2004-08-12 14:28:44 +0000 |
---|---|---|
committer | John Criswell <criswell@uiuc.edu> | 2004-08-12 14:28:44 +0000 |
commit | 0fe9bd9e6d4a6425491fa39b6584c2e03b6cb0dc (patch) | |
tree | 69e8469a735a2ee8682556aeb0a616fdb2c04dbb | |
parent | 322e13176fc6a19ad11834b93d7c165e76bf8f0c (diff) | |
download | llvm-0fe9bd9e6d4a6425491fa39b6584c2e03b6cb0dc.zip llvm-0fe9bd9e6d4a6425491fa39b6584c2e03b6cb0dc.tar.gz llvm-0fe9bd9e6d4a6425491fa39b6584c2e03b6cb0dc.tar.bz2 |
Merged from mainline.
llvm-svn: 15686
-rw-r--r-- | llvm/lib/Transforms/Hello/Hello.cpp | 1 | ||||
-rw-r--r-- | llvm/lib/Transforms/Utils/CodeExtractor.cpp | 21 |
2 files changed, 13 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Hello/Hello.cpp b/llvm/lib/Transforms/Hello/Hello.cpp index b626211..36a60fa 100644 --- a/llvm/lib/Transforms/Hello/Hello.cpp +++ b/llvm/lib/Transforms/Hello/Hello.cpp @@ -14,6 +14,7 @@ #include "llvm/Pass.h" #include "llvm/Function.h" +#include <iostream> using namespace llvm; namespace { diff --git a/llvm/lib/Transforms/Utils/CodeExtractor.cpp b/llvm/lib/Transforms/Utils/CodeExtractor.cpp index dbc358b..b3de38a 100644 --- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp +++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp @@ -513,21 +513,24 @@ emitCallAndSwitchStatement(Function *newFunction, BasicBlock *codeReplacer, } // Now that we've done the deed, simplify the switch instruction. + const Type *OldFnRetTy = TheSwitch->getParent()->getParent()->getReturnType(); switch (NumExitBlocks) { case 0: - // There is only 1 successor (the block containing the switch itself), which + // There are no successors (the block containing the switch itself), which // means that previously this was the last part of the function, and hence // this should be rewritten as a `ret' // Check if the function should return a value - if (TheSwitch->getParent()->getParent()->getReturnType() != Type::VoidTy && - TheSwitch->getParent()->getParent()->getReturnType() == - TheSwitch->getCondition()->getType()) + if (OldFnRetTy == Type::VoidTy) { + new ReturnInst(0, TheSwitch); // Return void + } else if (OldFnRetTy == TheSwitch->getCondition()->getType()) { // return what we have new ReturnInst(TheSwitch->getCondition(), TheSwitch); - else - // just return - new ReturnInst(0, TheSwitch); + } else { + // Otherwise we must have code extracted an unwind or something, just + // return whatever we want. + new ReturnInst(Constant::getNullValue(OldFnRetTy), TheSwitch); + } TheSwitch->getParent()->getInstList().erase(TheSwitch); break; @@ -583,8 +586,8 @@ void CodeExtractor::moveCodeToFunction(Function *newFunction) { /// for each scalar output in the function: at every exit, store intermediate /// computed result back into memory. /// -Function *CodeExtractor::ExtractCodeRegion(const std::vector<BasicBlock*> &code) -{ +Function *CodeExtractor:: +ExtractCodeRegion(const std::vector<BasicBlock*> &code) { if (!isEligible(code)) return 0; |