[llvm] r259132 - [RS4GC] Delete code that is dead due to r259129; NFC

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 28 17:03:17 PST 2016


Author: sanjoy
Date: Thu Jan 28 19:03:17 2016
New Revision: 259132

URL: http://llvm.org/viewvc/llvm-project?rev=259132&view=rev
Log:
[RS4GC] Delete code that is dead due to r259129; NFC

Modified:
    llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp?rev=259132&r1=259131&r2=259132&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/RewriteStatepointsForGC.cpp Thu Jan 28 19:03:17 2016
@@ -72,8 +72,6 @@ static cl::opt<bool, true> ClobberNonLiv
                                                   cl::location(ClobberNonLive),
                                                   cl::Hidden);
 
-static const bool UseDeoptBundles = true;
-
 static cl::opt<bool>
     AllowStatepointWithNoDeoptInfo("rs4gc-allow-statepoint-with-no-deopt-info",
                                    cl::Hidden, cl::init(true));
@@ -199,8 +197,6 @@ struct PartiallyConstructedSafepointReco
 }
 
 static ArrayRef<Use> GetDeoptBundleOperands(ImmutableCallSite CS) {
-  assert(UseDeoptBundles && "Should not be called otherwise!");
-
   Optional<OperandBundleUse> DeoptBundle =
       CS.getOperandBundle(LLVMContext::OB_deopt);
 
@@ -1381,8 +1377,6 @@ makeStatepointExplicitImpl(const CallSit
                            PartiallyConstructedSafepointRecord &Result,
                            std::vector<DeferredReplacement> &Replacements) {
   assert(BasePtrs.size() == LiveVariables.size());
-  assert((UseDeoptBundles || isStatepoint(CS)) &&
-         "This method expects to be rewriting a statepoint");
 
   // Then go ahead and use the builder do actually do the inserts.  We insert
   // immediately before the previous instruction under the assumption that all
@@ -1402,41 +1396,27 @@ makeStatepointExplicitImpl(const CallSit
 
   Value *CallTarget = nullptr;
 
-  if (UseDeoptBundles) {
-    CallArgs = {CS.arg_begin(), CS.arg_end()};
-    DeoptArgs = GetDeoptBundleOperands(CS);
-    if (auto TransitionBundle =
-            CS.getOperandBundle(LLVMContext::OB_gc_transition)) {
-      Flags |= uint32_t(StatepointFlags::GCTransition);
-      TransitionArgs = TransitionBundle->Inputs;
-    }
-    AttributeSet OriginalAttrs = CS.getAttributes();
-
-    Attribute AttrID = OriginalAttrs.getAttribute(AttributeSet::FunctionIndex,
-                                                  "statepoint-id");
-    if (AttrID.isStringAttribute())
-      AttrID.getValueAsString().getAsInteger(10, StatepointID);
-
-    Attribute AttrNumPatchBytes = OriginalAttrs.getAttribute(
-        AttributeSet::FunctionIndex, "statepoint-num-patch-bytes");
-    if (AttrNumPatchBytes.isStringAttribute())
-      AttrNumPatchBytes.getValueAsString().getAsInteger(10, NumPatchBytes);
+  CallArgs = {CS.arg_begin(), CS.arg_end()};
+  DeoptArgs = GetDeoptBundleOperands(CS);
+  if (auto TransitionBundle =
+      CS.getOperandBundle(LLVMContext::OB_gc_transition)) {
+    Flags |= uint32_t(StatepointFlags::GCTransition);
+    TransitionArgs = TransitionBundle->Inputs;
+  }
+  AttributeSet OriginalAttrs = CS.getAttributes();
+
+  Attribute AttrID = OriginalAttrs.getAttribute(AttributeSet::FunctionIndex,
+                                                "statepoint-id");
+  if (AttrID.isStringAttribute())
+    AttrID.getValueAsString().getAsInteger(10, StatepointID);
+
+  Attribute AttrNumPatchBytes = OriginalAttrs.getAttribute(
+    AttributeSet::FunctionIndex, "statepoint-num-patch-bytes");
+  if (AttrNumPatchBytes.isStringAttribute())
+    AttrNumPatchBytes.getValueAsString().getAsInteger(10, NumPatchBytes);
+
+  CallTarget = CS.getCalledValue();
 
-    CallTarget = CS.getCalledValue();
-  } else {
-    // This branch will be gone soon, and we will soon only support the
-    // UseDeoptBundles == true configuration.
-    Statepoint OldSP(CS);
-    StatepointID = OldSP.getID();
-    NumPatchBytes = OldSP.getNumPatchBytes();
-    Flags = OldSP.getFlags();
-
-    CallArgs = {OldSP.arg_begin(), OldSP.arg_end()};
-    DeoptArgs = {OldSP.vm_state_begin(), OldSP.vm_state_end()};
-    TransitionArgs = {OldSP.gc_transition_args_begin(),
-                      OldSP.gc_transition_args_end()};
-    CallTarget = OldSP.getCalledValue();
-  }
 
   // Create the statepoint given all the arguments
   Instruction *Token = nullptr;
@@ -1518,38 +1498,22 @@ makeStatepointExplicitImpl(const CallSit
   }
   assert(Token && "Should be set in one of the above branches!");
 
-  if (UseDeoptBundles) {
-    Token->setName("statepoint_token");
-    if (!CS.getType()->isVoidTy() && !CS.getInstruction()->use_empty()) {
-      StringRef Name =
-          CS.getInstruction()->hasName() ? CS.getInstruction()->getName() : "";
-      CallInst *GCResult = Builder.CreateGCResult(Token, CS.getType(), Name);
-      GCResult->setAttributes(CS.getAttributes().getRetAttributes());
-
-      // We cannot RAUW or delete CS.getInstruction() because it could be in the
-      // live set of some other safepoint, in which case that safepoint's
-      // PartiallyConstructedSafepointRecord will hold a raw pointer to this
-      // llvm::Instruction.  Instead, we defer the replacement and deletion to
-      // after the live sets have been made explicit in the IR, and we no longer
-      // have raw pointers to worry about.
-      Replacements.emplace_back(CS.getInstruction(), GCResult);
-    } else {
-      Replacements.emplace_back(CS.getInstruction(), nullptr);
-    }
+  Token->setName("statepoint_token");
+  if (!CS.getType()->isVoidTy() && !CS.getInstruction()->use_empty()) {
+    StringRef Name =
+      CS.getInstruction()->hasName() ? CS.getInstruction()->getName() : "";
+    CallInst *GCResult = Builder.CreateGCResult(Token, CS.getType(), Name);
+    GCResult->setAttributes(CS.getAttributes().getRetAttributes());
+
+    // We cannot RAUW or delete CS.getInstruction() because it could be in the
+    // live set of some other safepoint, in which case that safepoint's
+    // PartiallyConstructedSafepointRecord will hold a raw pointer to this
+    // llvm::Instruction.  Instead, we defer the replacement and deletion to
+    // after the live sets have been made explicit in the IR, and we no longer
+    // have raw pointers to worry about.
+    Replacements.emplace_back(CS.getInstruction(), GCResult);
   } else {
-    assert(!CS.getInstruction()->hasNUsesOrMore(2) &&
-           "only valid use before rewrite is gc.result");
-    assert(!CS.getInstruction()->hasOneUse() ||
-           isGCResult(cast<Instruction>(*CS.getInstruction()->user_begin())));
-
-    // Take the name of the original statepoint token if there was one.
-    Token->takeName(CS.getInstruction());
-
-    // Update the gc.result of the original statepoint (if any) to use the newly
-    // inserted statepoint.  This is safe to do here since the token can't be
-    // considered a live reference.
-    CS.getInstruction()->replaceAllUsesWith(Token);
-    CS.getInstruction()->eraseFromParent();
+    Replacements.emplace_back(CS.getInstruction(), nullptr);
   }
 
   Result.StatepointToken = Token;
@@ -2262,8 +2226,6 @@ static bool insertParsePoints(Function &
 
   for (CallSite CS : ToUpdate) {
     assert(CS.getInstruction()->getParent()->getParent() == &F);
-    assert((UseDeoptBundles || isStatepoint(CS)) &&
-           "expected to already be a deopt statepoint");
   }
 #endif
 
@@ -2290,12 +2252,7 @@ static bool insertParsePoints(Function &
   for (CallSite CS : ToUpdate) {
     SmallVector<Value *, 64> DeoptValues;
 
-    iterator_range<const Use *> DeoptStateRange =
-        UseDeoptBundles
-            ? iterator_range<const Use *>(GetDeoptBundleOperands(CS))
-            : iterator_range<const Use *>(Statepoint(CS).vm_state_args());
-
-    for (Value *Arg : DeoptStateRange) {
+    for (Value *Arg : GetDeoptBundleOperands(CS)) {
       assert(!isUnhandledGCPointerType(Arg->getType()) &&
              "support for FCA unimplemented");
       if (isHandledGCPointerType(Arg->getType()))
@@ -2595,13 +2552,9 @@ bool RewriteStatepointsForGC::runOnFunct
       getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F);
 
   auto NeedsRewrite = [](Instruction &I) {
-    if (UseDeoptBundles) {
-      if (ImmutableCallSite CS = ImmutableCallSite(&I))
-        return !callsGCLeafFunction(CS);
-      return false;
-    }
-
-    return isStatepoint(I);
+    if (ImmutableCallSite CS = ImmutableCallSite(&I))
+      return !callsGCLeafFunction(CS);
+    return false;
   };
 
   // Gather all the statepoints which need rewritten.  Be careful to only




More information about the llvm-commits mailing list