diff options
author | Duncan Sands <baldrick@free.fr> | 2007-11-28 17:07:01 +0000 |
---|---|---|
committer | Duncan Sands <baldrick@free.fr> | 2007-11-28 17:07:01 +0000 |
commit | afa3b6da11bc05281bcf09e45de9e037e0ee5011 (patch) | |
tree | bad8f7480a6ea8ab2cbce2ad3427e8173247f68e /lib/Transforms | |
parent | 1e7b1bbd9c939ce1581862a6e0f8961279ea5992 (diff) | |
download | external_llvm-afa3b6da11bc05281bcf09e45de9e037e0ee5011.zip external_llvm-afa3b6da11bc05281bcf09e45de9e037e0ee5011.tar.gz external_llvm-afa3b6da11bc05281bcf09e45de9e037e0ee5011.tar.bz2 |
Add some convenience methods for querying attributes, and
use them.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44403 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r-- | lib/Transforms/Scalar/SimplifyCFG.cpp | 33 |
1 files changed, 2 insertions, 31 deletions
diff --git a/lib/Transforms/Scalar/SimplifyCFG.cpp b/lib/Transforms/Scalar/SimplifyCFG.cpp index 22d81c8..ed51746 100644 --- a/lib/Transforms/Scalar/SimplifyCFG.cpp +++ b/lib/Transforms/Scalar/SimplifyCFG.cpp @@ -90,35 +90,6 @@ static void ChangeToCall(InvokeInst *II) { BB->getInstList().erase(II); } -/// IsNoReturn - Return true if the specified call is to a no-return function. -static bool IsNoReturn(const CallInst *CI) { - if (const ParamAttrsList *Attrs = CI->getParamAttrs()) - if (Attrs->paramHasAttr(0, ParamAttr::NoReturn)) - return true; - - if (const Function *Callee = CI->getCalledFunction()) - if (const ParamAttrsList *Attrs = Callee->getParamAttrs()) - if (Attrs->paramHasAttr(0, ParamAttr::NoReturn)) - return true; - - return false; -} - -/// IsNoUnwind - Return true if the specified invoke is to a no-unwind function. -static bool IsNoUnwind(const InvokeInst *II) { - if (const ParamAttrsList *Attrs = II->getParamAttrs()) - if (Attrs->paramHasAttr(0, ParamAttr::NoUnwind)) - return true; - - if (const Function *Callee = II->getCalledFunction()) - if (const ParamAttrsList *Attrs = Callee->getParamAttrs()) - if (Attrs->paramHasAttr(0, ParamAttr::NoUnwind)) - return true; - - return false; -} - - static bool MarkAliveBlocks(BasicBlock *BB, SmallPtrSet<BasicBlock*, 128> &Reachable) { @@ -137,7 +108,7 @@ static bool MarkAliveBlocks(BasicBlock *BB, // canonicalizes unreachable insts into stores to null or undef. for (BasicBlock::iterator BBI = BB->begin(), E = BB->end(); BBI != E;++BBI){ if (CallInst *CI = dyn_cast<CallInst>(BBI)) { - if (IsNoReturn(CI)) { + if (CI->paramHasAttr(0, ParamAttr::NoReturn)) { // If we found a call to a no-return function, insert an unreachable // instruction after it. Make sure there isn't *already* one there // though. @@ -161,7 +132,7 @@ static bool MarkAliveBlocks(BasicBlock *BB, // Turn invokes that call 'nounwind' functions into ordinary calls. if (InvokeInst *II = dyn_cast<InvokeInst>(BB->getTerminator())) - if (IsNoUnwind(II)) { + if (II->paramHasAttr(0, ParamAttr::NoUnwind)) { ChangeToCall(II); Changed = true; } |