llvm.org GIT mirror llvm / release_60 lib / Analysis / PtrUseVisitor.cpp
release_60

Tree @release_60 (Download .tar.gz)

PtrUseVisitor.cpp @release_60

ed90ed0
 
 
 
 
 
 
 
89688ce
ed90ed0
 
89688ce
ed90ed0
 
 
89688ce
 
 
ed90ed0
 
 
 
36b699f
5401ba7
ed90ed0
36b699f
ed90ed0
 
0a3eef5
ed90ed0
 
 
 
 
 
 
 
4ced4ee
ed90ed0
//===- PtrUseVisitor.cpp - InstVisitors over a pointers uses --------------===//
//
//                     The LLVM Compiler Infrastructure
//
// This file is distributed under the University of Illinois Open Source
// License. See LICENSE.TXT for details.
//
//===----------------------------------------------------------------------===//
//
/// \file
/// Implementation of the pointer use visitors.
//
//===----------------------------------------------------------------------===//

#include "llvm/Analysis/PtrUseVisitor.h"
#include "llvm/IR/Instruction.h"
#include "llvm/IR/Instructions.h"
#include <algorithm>

using namespace llvm;

void detail::PtrUseVisitorBase::enqueueUsers(Instruction &I) {
  for (Use &U : I.uses()) {
    if (VisitedUses.insert(&U).second) {
      UseToVisit NewU = {
        UseToVisit::UseAndIsOffsetKnownPair(&U, IsOffsetKnown),
        Offset
      };
      Worklist.push_back(std::move(NewU));
    }
  }
}

bool detail::PtrUseVisitorBase::adjustOffsetForGEP(GetElementPtrInst &GEPI) {
  if (!IsOffsetKnown)
    return false;

  return GEPI.accumulateConstantOffset(DL, Offset);
}