LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 /// \file
10 /// Implementation of the pointer use visitors.
11 ///
12 //===----------------------------------------------------------------------===//
13 
15 
16 using namespace llvm;
17 
19  for (Value::use_iterator UI = I.use_begin(), UE = I.use_end();
20  UI != UE; ++UI) {
21  if (VisitedUses.insert(&UI.getUse())) {
22  UseToVisit NewU = {
24  Offset
25  };
26  Worklist.push_back(llvm_move(NewU));
27  }
28  }
29 }
30 
32  if (!IsOffsetKnown)
33  return false;
34 
35  return GEPI.accumulateConstantOffset(DL, Offset);
36 }
use_iterator use_end()
Definition: Value.h:152
SmallPtrSet< Use *, 8 > VisitedUses
A set of visited uses to break cycles in unreachable code.
#define llvm_move(value)
Definition: Compiler.h:108
bool IsOffsetKnown
True if we have a known constant offset for the use currently being visited.
A struct of the data needed to visit a particular use.
SmallVector< UseToVisit, 8 > Worklist
The worklist of to-visit uses.
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.
PointerIntPair< Use *, 1, bool > UseAndIsOffsetKnownPair
bool accumulateConstantOffset(const DataLayout &DL, APInt &Offset) const
Accumulate the constant address offset of this GEP if possible.
use_iterator use_begin()
Definition: Value.h:150
#define I(x, y, z)
Definition: MD5.cpp:54
APInt Offset
The constant offset of the use if that is known.