/// 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
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".
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.
CaptureTracker::~CaptureTracker() {}
-bool CaptureTracker::shouldExplore(Use *U) { return true; }
+bool CaptureTracker::shouldExplore(const Use *U) { return true; }
namespace {
struct SimpleCaptureTracker : public CaptureTracker {
void tooManyUses() override { Captured = true; }
- bool captured(Use *U) override {
+ bool captured(const Use *U) override {
if (isa<ReturnInst>(U->getUser()) && !ReturnCaptures)
return false;
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();
}
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();
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; }
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;