diff options
author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2016-03-17 00:47:18 +0000 |
---|---|---|
committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2016-03-17 00:47:18 +0000 |
commit | d6fc46ea0384899913db5d19d535b092057d6e77 (patch) | |
tree | 4082136e64782fd562ed30685ebbf030680441d5 /llvm/lib/IR/Statepoint.cpp | |
parent | 3a02019fbc7a1089cd48fb18e844778de35c4f8c (diff) | |
download | bcm5719-llvm-d6fc46ea0384899913db5d19d535b092057d6e77.tar.gz bcm5719-llvm-d6fc46ea0384899913db5d19d535b092057d6e77.zip |
[Statepoints] Minor NFC cleanups
Mostly code simplifcations, and bringing up IR/Statepoints.cpp up to
LLVM coding style.
llvm-svn: 263683
Diffstat (limited to 'llvm/lib/IR/Statepoint.cpp')
-rw-r--r-- | llvm/lib/IR/Statepoint.cpp | 62 |
1 files changed, 28 insertions, 34 deletions
diff --git a/llvm/lib/IR/Statepoint.cpp b/llvm/lib/IR/Statepoint.cpp index 27a990eaff8..e56da6beaff 100644 --- a/llvm/lib/IR/Statepoint.cpp +++ b/llvm/lib/IR/Statepoint.cpp @@ -7,55 +7,49 @@ // //===----------------------------------------------------------------------===// // -// +// This file contains some utility functions to help recognize gc.statepoint +// intrinsics. +// //===----------------------------------------------------------------------===// -#include "llvm/IR/Function.h" -#include "llvm/IR/Constant.h" -#include "llvm/IR/Constants.h" #include "llvm/IR/Statepoint.h" -#include "llvm/Support/CommandLine.h" -using namespace std; +#include "llvm/IR/Function.h" + using namespace llvm; -bool llvm::isStatepoint(const ImmutableCallSite &CS) { - if (!CS.getInstruction()) { - // This is not a call site - return false; - } +static const Function *getCalledFunction(ImmutableCallSite CS) { + if (!CS.getInstruction()) + return nullptr; + return CS.getCalledFunction(); +} - const Function *F = CS.getCalledFunction(); - return (F && F->getIntrinsicID() == Intrinsic::experimental_gc_statepoint); +bool llvm::isStatepoint(ImmutableCallSite CS) { + if (auto *F = getCalledFunction(CS)) + return F->getIntrinsicID() == Intrinsic::experimental_gc_statepoint; + return false; } -bool llvm::isStatepoint(const Value *inst) { - if (isa<InvokeInst>(inst) || isa<CallInst>(inst)) { - ImmutableCallSite CS(inst); + +bool llvm::isStatepoint(const Value *V) { + if (auto CS = ImmutableCallSite(V)) return isStatepoint(CS); - } return false; } -bool llvm::isStatepoint(const Value &inst) { - return isStatepoint(&inst); + +bool llvm::isStatepoint(const Value &V) { + return isStatepoint(&V); } -bool llvm::isGCRelocate(const ImmutableCallSite &CS) { +bool llvm::isGCRelocate(ImmutableCallSite CS) { return CS.getInstruction() && isa<GCRelocateInst>(CS.getInstruction()); } -bool llvm::isGCResult(const ImmutableCallSite &CS) { - if (!CS.getInstruction()) { - // This is not a call site - return false; - } - - return isGCResult(CS.getInstruction()); -} -bool llvm::isGCResult(const Value *inst) { - if (const CallInst *call = dyn_cast<CallInst>(inst)) { - if (Function *F = call->getCalledFunction()) { - return F->getIntrinsicID() == Intrinsic::experimental_gc_result; - } - } +bool llvm::isGCResult(ImmutableCallSite CS) { + if (auto *F = getCalledFunction(CS)) + return F->getIntrinsicID() == Intrinsic::experimental_gc_result; return false; } + +bool llvm::isGCResult(const Value *V) { + return isGCResult(ImmutableCallSite(V)); +} |