diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2019-01-07 05:42:51 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2019-01-07 05:42:51 +0000 |
commit | 363ac6837427ffc6adcc68c44788bb4d92d52873 (patch) | |
tree | 1f5211bde4f720eed89db8e62ee16a4be663c2a8 /llvm/lib/Analysis/CaptureTracking.cpp | |
parent | f6f134e4d44ca8db242e168de6da7eb68e9cf76e (diff) | |
download | bcm5719-llvm-363ac6837427ffc6adcc68c44788bb4d92d52873.tar.gz bcm5719-llvm-363ac6837427ffc6adcc68c44788bb4d92d52873.zip |
[CallSite removal] Migrate all Alias Analysis APIs to use the newly
minted `CallBase` class instead of the `CallSite` wrapper.
This moves the largest interwoven collection of APIs that traffic in
`CallSite`s. While a handful of these could have been migrated with
a minorly more shallow migration by converting from a `CallSite` to
a `CallBase`, it hardly seemed worth it. Most of the APIs needed to
migrate together because of the complex interplay of AA APIs and the
fact that converting from a `CallBase` to a `CallSite` isn't free in its
current implementation.
Out of tree users of these APIs can fairly reliably migrate with some
combination of `.getInstruction()` on the `CallSite` instance and
casting the resulting pointer. The most generic form will look like `CS`
-> `cast_or_null<CallBase>(CS.getInstruction())` but in most cases there
is a more elegant migration. Hopefully, this migrates enough APIs for
users to fully move from `CallSite` to the base class. All of the
in-tree users were easily migrated in that fashion.
Thanks for the review from Saleem!
Differential Revision: https://reviews.llvm.org/D55641
llvm-svn: 350503
Diffstat (limited to 'llvm/lib/Analysis/CaptureTracking.cpp')
-rw-r--r-- | llvm/lib/Analysis/CaptureTracking.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/llvm/lib/Analysis/CaptureTracking.cpp b/llvm/lib/Analysis/CaptureTracking.cpp index 5cac5e5ca61..669f4f2835f 100644 --- a/llvm/lib/Analysis/CaptureTracking.cpp +++ b/llvm/lib/Analysis/CaptureTracking.cpp @@ -23,7 +23,6 @@ #include "llvm/Analysis/CFG.h" #include "llvm/Analysis/OrderedBasicBlock.h" #include "llvm/Analysis/ValueTracking.h" -#include "llvm/IR/CallSite.h" #include "llvm/IR/Constants.h" #include "llvm/IR/Dominators.h" #include "llvm/IR/Instructions.h" @@ -240,11 +239,12 @@ void llvm::PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker, switch (I->getOpcode()) { case Instruction::Call: case Instruction::Invoke: { - CallSite CS(I); + auto *Call = cast<CallBase>(I); // Not captured if the callee is readonly, doesn't return a copy through // its return value and doesn't unwind (a readonly function can leak bits // by throwing an exception or not depending on the input value). - if (CS.onlyReadsMemory() && CS.doesNotThrow() && I->getType()->isVoidTy()) + if (Call->onlyReadsMemory() && Call->doesNotThrow() && + Call->getType()->isVoidTy()) break; // The pointer is not captured if returned pointer is not captured. @@ -252,14 +252,14 @@ void llvm::PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker, // marked with nocapture do not capture. This means that places like // GetUnderlyingObject in ValueTracking or DecomposeGEPExpression // in BasicAA also need to know about this property. - if (isIntrinsicReturningPointerAliasingArgumentWithoutCapturing(CS)) { - AddUses(I); + if (isIntrinsicReturningPointerAliasingArgumentWithoutCapturing(Call)) { + AddUses(Call); break; } // Volatile operations effectively capture the memory location that they // load and store to. - if (auto *MI = dyn_cast<MemIntrinsic>(I)) + if (auto *MI = dyn_cast<MemIntrinsic>(Call)) if (MI->isVolatile()) if (Tracker->captured(U)) return; @@ -271,13 +271,14 @@ void llvm::PointerMayBeCaptured(const Value *V, CaptureTracker *Tracker, // that loading a value from a pointer does not cause the pointer to be // captured, even though the loaded value might be the pointer itself // (think of self-referential objects). - CallSite::data_operand_iterator B = - CS.data_operands_begin(), E = CS.data_operands_end(); - for (CallSite::data_operand_iterator A = B; A != E; ++A) - if (A->get() == V && !CS.doesNotCapture(A - B)) + for (auto IdxOpPair : enumerate(Call->data_ops())) { + int Idx = IdxOpPair.index(); + Value *A = IdxOpPair.value(); + if (A == V && !Call->doesNotCapture(Idx)) // The parameter is not marked 'nocapture' - captured. if (Tracker->captured(U)) return; + } break; } case Instruction::Load: |