summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2015-02-21 00:09:09 +0000
committerPhilip Reames <listmail@philipreames.com>2015-02-21 00:09:09 +0000
commit0b1b387441c4c8bae5d918eb204f2dc44bd54ff4 (patch)
tree81cfc3264a14035b499d10223348a9b05f907dac /llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp
parenta05c7f876bcb3ee7430b3c19219e15e054d7db14 (diff)
downloadbcm5719-llvm-0b1b387441c4c8bae5d918eb204f2dc44bd54ff4.tar.gz
bcm5719-llvm-0b1b387441c4c8bae5d918eb204f2dc44bd54ff4.zip
[PlaceSafepoints] Adjust enablement logic to default to off and be GC configurable per GC
Previously, this pass ran over every function in the Module if added to the pass order. With this change, it runs only over those with a GC attribute where the GC explicitly opts in. A GC can also choose which of entry safepoint polls, backedge safepoint polls, and call safepoints it wants. I hope to get these exposed as checks on the GCStrategy at some point, but for now, the checks are manual string comparisons. llvm-svn: 230097
Diffstat (limited to 'llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp')
-rw-r--r--llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp37
1 files changed, 26 insertions, 11 deletions
diff --git a/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp b/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp
index a3e759f0f3b..376be88fe8a 100644
--- a/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp
+++ b/llvm/lib/Transforms/Scalar/PlaceSafepoints.cpp
@@ -150,15 +150,8 @@ namespace {
struct PlaceSafepoints : public ModulePass {
static char ID; // Pass identification, replacement for typeid
- bool EnableEntrySafepoints;
- bool EnableBackedgeSafepoints;
- bool EnableCallSafepoints;
-
PlaceSafepoints() : ModulePass(ID) {
initializePlaceSafepointsPass(*PassRegistry::getPassRegistry());
- EnableEntrySafepoints = !NoEntry;
- EnableBackedgeSafepoints = !NoBackedge;
- EnableCallSafepoints = !NoCall;
}
bool runOnModule(Module &M) override {
bool modified = false;
@@ -504,6 +497,25 @@ static bool isGCSafepointPoll(Function &F) {
return F.getName().equals(GCSafepointPollName);
}
+/// Returns true if this function should be rewritten to include safepoint
+/// polls and parseable call sites. The main point of this function is to be
+/// an extension point for custom logic.
+static bool shouldRewriteFunction(Function &F) {
+ // TODO: This should check the GCStrategy
+ if (F.hasGC()) {
+ const std::string StatepointExampleName("statepoint-example");
+ return StatepointExampleName == F.getGC();
+ } else
+ return false;
+}
+
+// TODO: These should become properties of the GCStrategy, possibly with
+// command line overrides.
+static bool enableEntrySafepoints(Function &F) { return !NoEntry; }
+static bool enableBackedgeSafepoints(Function &F) { return !NoBackedge; }
+static bool enableCallSafepoints(Function &F) { return !NoCall; }
+
+
bool PlaceSafepoints::runOnFunction(Function &F) {
if (F.isDeclaration() || F.empty()) {
// This is a declaration, nothing to do. Must exit early to avoid crash in
@@ -518,6 +530,9 @@ bool PlaceSafepoints::runOnFunction(Function &F) {
return false;
}
+ if (!shouldRewriteFunction(F))
+ return false;
+
bool modified = false;
// In various bits below, we rely on the fact that uses are reachable from
@@ -536,13 +551,13 @@ bool PlaceSafepoints::runOnFunction(Function &F) {
std::vector<CallSite> ParsePointNeeded;
- if (EnableBackedgeSafepoints) {
+ if (enableBackedgeSafepoints(F)) {
// Construct a pass manager to run the LoopPass backedge logic. We
// need the pass manager to handle scheduling all the loop passes
// appropriately. Doing this by hand is painful and just not worth messing
// with for the moment.
legacy::FunctionPassManager FPM(F.getParent());
- bool CanAssumeCallSafepoints = EnableCallSafepoints;
+ bool CanAssumeCallSafepoints = enableCallSafepoints(F);
PlaceBackedgeSafepointsImpl *PBS =
new PlaceBackedgeSafepointsImpl(CanAssumeCallSafepoints);
FPM.add(PBS);
@@ -609,7 +624,7 @@ bool PlaceSafepoints::runOnFunction(Function &F) {
}
}
- if (EnableEntrySafepoints) {
+ if (enableEntrySafepoints(F)) {
DT.recalculate(F);
Instruction *term = findLocationForEntrySafepoint(F, DT);
if (!term) {
@@ -624,7 +639,7 @@ bool PlaceSafepoints::runOnFunction(Function &F) {
}
}
- if (EnableCallSafepoints) {
+ if (enableCallSafepoints(F)) {
DT.recalculate(F);
std::vector<CallSite> Calls;
findCallSafepoints(F, Calls);
OpenPOWER on IntegriCloud