[PlaceSafeopints] Extract out `callsGCLeafFunction`, NFC
Summary:
This will be used in a later change to RewriteStatepointsForGC.
Reviewers: reames, swaroop.sridhar
Subscribers: llvm-commits
Differential Revision: http://reviews.llvm.org/D13490
llvm-svn: 249777
diff --git a/llvm/lib/Transforms/Utils/Local.cpp b/llvm/lib/Transforms/Utils/Local.cpp
index 5be5a7d..de04ea5 100644
--- a/llvm/lib/Transforms/Utils/Local.cpp
+++ b/llvm/lib/Transforms/Utils/Local.cpp
@@ -1480,3 +1480,20 @@
}
return Count;
}
+
+bool llvm::callsGCLeafFunction(ImmutableCallSite CS) {
+ if (isa<IntrinsicInst>(CS.getInstruction()))
+ // Most LLVM intrinsics are things which can never take a safepoint.
+ // As a result, we don't need to have the stack parsable at the
+ // callsite. This is a highly useful optimization since intrinsic
+ // calls are fairly prevalent, particularly in debug builds.
+ return true;
+
+ // Check if the function is specifically marked as a gc leaf function.
+ //
+ // TODO: we should be checking the attributes on the call site as well.
+ if (const Function *F = CS.getCalledFunction())
+ return F->hasFnAttribute("gc-leaf-function");
+
+ return false;
+}