Chandler Carruth | ed90ed0 | 2012-12-10 08:28:39 +0000 | [diff] [blame] | 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 | |
| 14 | #include "llvm/Analysis/PtrUseVisitor.h" |
| 15 | |
| 16 | using namespace llvm; |
| 17 | |
| 18 | void detail::PtrUseVisitorBase::enqueueUsers(Instruction &I) { |
| 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 = { |
| 23 | UseToVisit::UseAndIsOffsetKnownPair(&UI.getUse(), IsOffsetKnown), |
| 24 | Offset |
| 25 | }; |
| 26 | Worklist.push_back(llvm_move(NewU)); |
| 27 | } |
| 28 | } |
| 29 | } |
| 30 | |
| 31 | bool detail::PtrUseVisitorBase::adjustOffsetForGEP(GetElementPtrInst &GEPI) { |
| 32 | if (!IsOffsetKnown) |
| 33 | return false; |
| 34 | |
Chandler Carruth | 4ced4ee | 2012-12-11 10:29:10 +0000 | [diff] [blame] | 35 | return GEPI.accumulateConstantOffset(DL, Offset); |
Chandler Carruth | ed90ed0 | 2012-12-10 08:28:39 +0000 | [diff] [blame] | 36 | } |