Chandler Carruth | e41e7b7 | 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) { |
Chandler Carruth | cdf4788 | 2014-03-09 03:16:01 +0000 | [diff] [blame] | 19 | for (Use &U : I.uses()) { |
David Blaikie | 70573dc | 2014-11-19 07:49:26 +0000 | [diff] [blame^] | 20 | if (VisitedUses.insert(&U).second) { |
Chandler Carruth | e41e7b7 | 2012-12-10 08:28:39 +0000 | [diff] [blame] | 21 | UseToVisit NewU = { |
Chandler Carruth | cdf4788 | 2014-03-09 03:16:01 +0000 | [diff] [blame] | 22 | UseToVisit::UseAndIsOffsetKnownPair(&U, IsOffsetKnown), |
Chandler Carruth | e41e7b7 | 2012-12-10 08:28:39 +0000 | [diff] [blame] | 23 | Offset |
| 24 | }; |
Chandler Carruth | 002da5d | 2014-03-02 04:08:41 +0000 | [diff] [blame] | 25 | Worklist.push_back(std::move(NewU)); |
Chandler Carruth | e41e7b7 | 2012-12-10 08:28:39 +0000 | [diff] [blame] | 26 | } |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | bool detail::PtrUseVisitorBase::adjustOffsetForGEP(GetElementPtrInst &GEPI) { |
| 31 | if (!IsOffsetKnown) |
| 32 | return false; |
| 33 | |
Chandler Carruth | 1e14053 | 2012-12-11 10:29:10 +0000 | [diff] [blame] | 34 | return GEPI.accumulateConstantOffset(DL, Offset); |
Chandler Carruth | e41e7b7 | 2012-12-10 08:28:39 +0000 | [diff] [blame] | 35 | } |