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 (Use &U : I.uses()) {
00020     if (VisitedUses.insert(&U)) {
00021       UseToVisit NewU = {
00022         UseToVisit::UseAndIsOffsetKnownPair(&U, IsOffsetKnown),
00023         Offset
00024       };
00025       Worklist.push_back(std::move(NewU));
00026     }
00027   }
00028 }
00029 
00030 bool detail::PtrUseVisitorBase::adjustOffsetForGEP(GetElementPtrInst &GEPI) {
00031   if (!IsOffsetKnown)
00032     return false;
00033 
00034   return GEPI.accumulateConstantOffset(DL, Offset);
00035 }