Skip to content

Commit

Permalink
[opaque pointer types] [NFC] FindAvailableLoadedValue: take LoadInst …
Browse files Browse the repository at this point in the history
…instead of just the pointer.

Reviewers: mjacob, dblaikie

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D16422

llvm-svn: 258477
  • Loading branch information
eddyb committed Jan 22, 2016
1 parent 710d9f8 commit e2a6917
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion llvm/include/llvm/Analysis/Loads.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ extern cl::opt<unsigned> DefMaxInstsToScan;
/// If AATags is non-null and a load or store is found, the AA tags from the
/// load or store are recorded there. If there are no AA tags or if no access
/// is found, it is left unmodified.
Value *FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB,
Value *FindAvailableLoadedValue(LoadInst *Load, BasicBlock *ScanBB,
BasicBlock::iterator &ScanFrom,
unsigned MaxInstsToScan = DefMaxInstsToScan,
AliasAnalysis *AA = nullptr,
Expand Down
3 changes: 1 addition & 2 deletions llvm/lib/Analysis/Lint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,8 +642,7 @@ Value *Lint::findValueImpl(Value *V, bool OffsetOk,
if (!VisitedBlocks.insert(BB).second)
break;
if (Value *U =
FindAvailableLoadedValue(L->getPointerOperand(),
BB, BBI, DefMaxInstsToScan, AA))
FindAvailableLoadedValue(L, BB, BBI, DefMaxInstsToScan, AA))
return findValueImpl(U, OffsetOk, Visited);
if (BBI != BB->begin()) break;
BB = BB->getUniquePredecessor();
Expand Down
5 changes: 3 additions & 2 deletions llvm/lib/Analysis/Loads.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,14 +196,15 @@ llvm::DefMaxInstsToScan("available-load-scan-limit", cl::init(6), cl::Hidden,
/// If \c AATags is non-null and a load or store is found, the AA tags from the
/// load or store are recorded there. If there are no AA tags or if no access is
/// found, it is left unmodified.
Value *llvm::FindAvailableLoadedValue(Value *Ptr, BasicBlock *ScanBB,
Value *llvm::FindAvailableLoadedValue(LoadInst *Load, BasicBlock *ScanBB,
BasicBlock::iterator &ScanFrom,
unsigned MaxInstsToScan,
AliasAnalysis *AA, AAMDNodes *AATags) {
if (MaxInstsToScan == 0)
MaxInstsToScan = ~0U;

Type *AccessTy = cast<PointerType>(Ptr->getType())->getElementType();
Value *Ptr = Load->getPointerOperand();
Type *AccessTy = Load->getType();

const DataLayout &DL = ScanBB->getModule()->getDataLayout();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ Instruction *InstCombiner::visitLoadInst(LoadInst &LI) {
BasicBlock::iterator BBI(LI);
AAMDNodes AATags;
if (Value *AvailableVal =
FindAvailableLoadedValue(Op, LI.getParent(), BBI,
FindAvailableLoadedValue(&LI, LI.getParent(), BBI,
DefMaxInstsToScan, AA, &AATags)) {
if (LoadInst *NLI = dyn_cast<LoadInst>(AvailableVal)) {
unsigned KnownIDs[] = {
Expand Down
4 changes: 2 additions & 2 deletions llvm/lib/Transforms/Scalar/JumpThreading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -952,7 +952,7 @@ bool JumpThreading::SimplifyPartiallyRedundantLoad(LoadInst *LI) {
BasicBlock::iterator BBIt(LI);

if (Value *AvailableVal =
FindAvailableLoadedValue(LoadedPtr, LoadBB, BBIt, DefMaxInstsToScan)) {
FindAvailableLoadedValue(LI, LoadBB, BBIt, DefMaxInstsToScan)) {
// If the value of the load is locally available within the block, just use
// it. This frequently occurs for reg2mem'd allocas.
//cerr << "LOAD ELIMINATED:\n" << *BBIt << *LI << "\n";
Expand Down Expand Up @@ -994,7 +994,7 @@ bool JumpThreading::SimplifyPartiallyRedundantLoad(LoadInst *LI) {
// Scan the predecessor to see if the value is available in the pred.
BBIt = PredBB->end();
AAMDNodes ThisAATags;
Value *PredAvailable = FindAvailableLoadedValue(LoadedPtr, PredBB, BBIt,
Value *PredAvailable = FindAvailableLoadedValue(LI, PredBB, BBIt,
DefMaxInstsToScan,
nullptr, &ThisAATags);
if (!PredAvailable) {
Expand Down

0 comments on commit e2a6917

Please sign in to comment.