[llvm] r263683 - [Statepoints] Minor NFC cleanups
Sanjoy Das via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 16 17:47:19 PDT 2016
Author: sanjoy
Date: Wed Mar 16 19:47:18 2016
New Revision: 263683
URL: http://llvm.org/viewvc/llvm-project?rev=263683&view=rev
Log:
[Statepoints] Minor NFC cleanups
Mostly code simplifcations, and bringing up IR/Statepoints.cpp up to
LLVM coding style.
Modified:
llvm/trunk/include/llvm/IR/Statepoint.h
llvm/trunk/lib/IR/Statepoint.cpp
Modified: llvm/trunk/include/llvm/IR/Statepoint.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Statepoint.h?rev=263683&r1=263682&r2=263683&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Statepoint.h (original)
+++ llvm/trunk/include/llvm/IR/Statepoint.h Wed Mar 16 19:47:18 2016
@@ -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
Modified: llvm/trunk/lib/IR/Statepoint.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/Statepoint.cpp?rev=263683&r1=263682&r2=263683&view=diff
==============================================================================
--- llvm/trunk/lib/IR/Statepoint.cpp (original)
+++ llvm/trunk/lib/IR/Statepoint.cpp Wed Mar 16 19:47:18 2016
@@ -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;
- }
-
- const Function *F = CS.getCalledFunction();
- return (F && F->getIntrinsicID() == Intrinsic::experimental_gc_statepoint);
-}
-bool llvm::isStatepoint(const Value *inst) {
- if (isa<InvokeInst>(inst) || isa<CallInst>(inst)) {
- ImmutableCallSite CS(inst);
+static const Function *getCalledFunction(ImmutableCallSite CS) {
+ if (!CS.getInstruction())
+ return nullptr;
+ return CS.getCalledFunction();
+}
+
+bool llvm::isStatepoint(ImmutableCallSite CS) {
+ if (auto *F = getCalledFunction(CS))
+ return F->getIntrinsicID() == Intrinsic::experimental_gc_statepoint;
+ return false;
+}
+
+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));
+}
More information about the llvm-commits
mailing list