LLVM API Documentation

PtrUseVisitor.cpp
Go to the documentation of this file.
00001 //===- PtrUseVisitor.cpp - InstVisitors over a pointers uses --------------===//
00002 //
00003 //                     The LLVM Compiler Infrastructure
00004 //
00005 // This file is distributed under the University of Illinois Open Source
00006 // License. See LICENSE.TXT for details.
00007 //
00008 //===----------------------------------------------------------------------===//
00009 /// \file
00010 /// Implementation of the pointer use visitors.
00011 ///
00012 //===----------------------------------------------------------------------===//
00013 
00014 #include "llvm/Analysis/PtrUseVisitor.h"
00015 
00016 using namespace llvm;
00017 
00018 void detail::PtrUseVisitorBase::enqueueUsers(Instruction &I) {
00019   for (Value::use_iterator UI = I.use_begin(), UE = I.use_end();
00020        UI != UE; ++UI) {
00021     if (VisitedUses.insert(&UI.getUse())) {
00022       UseToVisit NewU = {
00023         UseToVisit::UseAndIsOffsetKnownPair(&UI.getUse(), IsOffsetKnown),
00024         Offset
00025       };
00026       Worklist.push_back(llvm_move(NewU));
00027     }
00028   }
00029 }
00030 
00031 bool detail::PtrUseVisitorBase::adjustOffsetForGEP(GetElementPtrInst &GEPI) {
00032   if (!IsOffsetKnown)
00033     return false;
00034 
00035   return GEPI.accumulateConstantOffset(DL, Offset);
00036 }