diff options
| -rw-r--r-- | llvm/include/llvm/IR/Statepoint.h | 6 | ||||
| -rw-r--r-- | llvm/lib/IR/Statepoint.cpp | 62 |
2 files changed, 31 insertions, 37 deletions
diff --git a/llvm/include/llvm/IR/Statepoint.h b/llvm/include/llvm/IR/Statepoint.h index 51a0951a979..357b0ab9717 100644 --- a/llvm/include/llvm/IR/Statepoint.h +++ b/llvm/include/llvm/IR/Statepoint.h @@ -40,14 +40,14 @@ enum class StatepointFlags { class GCRelocateInst; class ImmutableStatepoint; -bool isStatepoint(const ImmutableCallSite &CS); +bool isStatepoint(ImmutableCallSite CS); bool isStatepoint(const Value *V); bool isStatepoint(const Value &V); -bool isGCRelocate(const ImmutableCallSite &CS); +bool isGCRelocate(ImmutableCallSite CS); bool isGCResult(const Value *V); -bool isGCResult(const ImmutableCallSite &CS); +bool isGCResult(ImmutableCallSite CS); /// Analogous to CallSiteBase, this provides most of the actual /// functionality for Statepoint and ImmutableStatepoint. It is 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)); +} |

