[C++11] Make this interface accept const Use pointers and use override
authorChandler Carruth <chandlerc@gmail.com>
Wed, 5 Mar 2014 10:21:48 +0000 (10:21 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Wed, 5 Mar 2014 10:21:48 +0000 (10:21 +0000)
to ensure we don't mess up any of the overrides. Necessary for cleaning
up the Value use iterators and enabling range-based traversing of use
lists.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202958 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Analysis/CaptureTracking.h
lib/Analysis/AliasAnalysis.cpp
lib/Analysis/CaptureTracking.cpp
lib/Transforms/IPO/FunctionAttrs.cpp
lib/Transforms/Scalar/TailRecursionElimination.cpp

index 8edabfe860a13820e66bf4b149785723c7c0fabd..eccf1f811381485f242d343f01b3a726b1597296 100644 (file)
@@ -45,12 +45,12 @@ namespace llvm {
     /// capture) return false. To search it, return true.
     ///
     /// U->getUser() is always an Instruction.
-    virtual bool shouldExplore(Use *U);
+    virtual bool shouldExplore(const Use *U);
 
     /// captured - Information about the pointer was captured by the user of
     /// use U. Return true to stop the traversal or false to continue looking
     /// for more capturing instructions.
-    virtual bool captured(Use *U) = 0;
+    virtual bool captured(const Use *U) = 0;
   };
 
   /// PointerMayBeCaptured - Visit the value and the values derived from it and
index 8f2ddb5507d4f76f9cdedc865ccc758995aea6f2..36ed40d3549545c0fb09f70b550aa7c07fdecfdc 100644 (file)
@@ -372,7 +372,7 @@ namespace {
 
     void tooManyUses() override { Captured = true; }
 
-    bool shouldExplore(Use *U) override {
+    bool shouldExplore(const Use *U) override {
       Instruction *I = cast<Instruction>(U->getUser());
       BasicBlock *BB = I->getParent();
       // We explore this usage only if the usage can reach "BeforeHere".
@@ -388,7 +388,7 @@ namespace {
       return true;
     }
 
-    bool captured(Use *U) override {
+    bool captured(const Use *U) override {
       Instruction *I = cast<Instruction>(U->getUser());
       BasicBlock *BB = I->getParent();
       // Same logic as in shouldExplore.
index 1e864b2954774e2f96fa579241899dade8c782b4..60978470d2ba818020d8d269a94e3c38c845e53a 100644 (file)
@@ -28,7 +28,7 @@ using namespace llvm;
 
 CaptureTracker::~CaptureTracker() {}
 
-bool CaptureTracker::shouldExplore(Use *U) { return true; }
+bool CaptureTracker::shouldExplore(const Use *U) { return true; }
 
 namespace {
   struct SimpleCaptureTracker : public CaptureTracker {
@@ -37,7 +37,7 @@ namespace {
 
     void tooManyUses() override { Captured = true; }
 
-    bool captured(Use *U) override {
+    bool captured(const Use *U) override {
       if (isa<ReturnInst>(U->getUser()) && !ReturnCaptures)
         return false;
 
@@ -81,8 +81,8 @@ static int const Threshold = 20;
 
 void llvm::PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker) {
   assert(V->getType()->isPointerTy() && "Capture is for pointers only!");
-  SmallVector<Use*, Threshold> Worklist;
-  SmallSet<Use*, Threshold> Visited;
+  SmallVector<const Use *, Threshold> Worklist;
+  SmallSet<const Use *, Threshold> Visited;
   int Count = 0;
 
   for (Value::const_use_iterator UI = V->use_begin(), UE = V->use_end();
@@ -99,7 +99,7 @@ void llvm::PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker) {
   }
 
   while (!Worklist.empty()) {
-    Use *U = Worklist.pop_back_val();
+    const Use *U = Worklist.pop_back_val();
     Instruction *I = cast<Instruction>(U->getUser());
     V = U->get();
 
index 68eca52991b405d5cb91c2ca04031621f0b81212..cb565d0814b606c2bb0b1b952ff919c8d27ea042 100644 (file)
@@ -344,7 +344,7 @@ namespace {
 
     void tooManyUses() override { Captured = true; }
 
-    bool captured(Use *U) override {
+    bool captured(const Use *U) override {
       CallSite CS(U->getUser());
       if (!CS.getInstruction()) { Captured = true; return true; }
 
index fad4e0a6a3db00f307a9f02979583c8ee3478dc4..bf49f814f63756d4a326e4e3fa437a76bea79ef2 100644 (file)
@@ -151,14 +151,14 @@ struct AllocaCaptureTracker : public CaptureTracker {
 
   void tooManyUses() override { Captured = true; }
 
-  bool shouldExplore(Use *U) override {
+  bool shouldExplore(const Use *U) override {
     Value *V = U->getUser();
     if (isa<CallInst>(V) || isa<InvokeInst>(V))
       UsesAlloca.insert(V);
     return true;
   }
 
-  bool captured(Use *U) override {
+  bool captured(const Use *U) override {
     if (isa<ReturnInst>(U->getUser()))
       return false;
     Captured = true;