LLVM  6.0.0svn
PtrUseVisitor.cpp
Go to the documentation of this file.
1 //===- PtrUseVisitor.cpp - InstVisitors over a pointers uses --------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 /// \file
11 /// Implementation of the pointer use visitors.
12 //
13 //===----------------------------------------------------------------------===//
14 
16 #include "llvm/IR/Instruction.h"
17 #include "llvm/IR/Instructions.h"
18 #include <algorithm>
19 
20 using namespace llvm;
21 
23  for (Use &U : I.uses()) {
24  if (VisitedUses.insert(&U).second) {
25  UseToVisit NewU = {
27  Offset
28  };
29  Worklist.push_back(std::move(NewU));
30  }
31  }
32 }
33 
35  if (!IsOffsetKnown)
36  return false;
37 
38  return GEPI.accumulateConstantOffset(DL, Offset);
39 }
iterator_range< use_iterator > uses()
Definition: Value.h:356
Compute iterated dominance frontiers using a linear time algorithm.
Definition: AllocatorList.h:24
Use * U
The use currently being visited.
SmallPtrSet< Use *, 8 > VisitedUses
A set of visited uses to break cycles in unreachable code.
bool IsOffsetKnown
True if we have a known constant offset for the use currently being visited.
A Use represents the edge between a Value definition and its users.
Definition: Use.h:56
This file provides a collection of visitors which walk the (instruction) uses of a pointer...
A struct of the data needed to visit a particular use.
SmallVector< UseToVisit, 8 > Worklist
The worklist of to-visit uses.
PointerIntPair< Use *, 1, bool > UseAndIsOffsetKnownPair
an instruction for type-safe pointer arithmetic to access elements of arrays and structs ...
Definition: Instructions.h:837
void enqueueUsers(Instruction &I)
Enqueue the users of this instruction in the visit worklist.
bool adjustOffsetForGEP(GetElementPtrInst &GEPI)
Walk the operands of a GEP and adjust the offset as appropriate.
bool accumulateConstantOffset(const DataLayout &DL, APInt &Offset) const
Accumulate the constant address offset of this GEP if possible.
#define I(x, y, z)
Definition: MD5.cpp:58
APInt Offset
The constant offset of the use if that is known.