summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/lib/Analysis/PtrUseVisitor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm/lib/Analysis/PtrUseVisitor.cpp')
-rw-r--r--contrib/llvm/lib/Analysis/PtrUseVisitor.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/contrib/llvm/lib/Analysis/PtrUseVisitor.cpp b/contrib/llvm/lib/Analysis/PtrUseVisitor.cpp
new file mode 100644
index 0000000..68c7535
--- /dev/null
+++ b/contrib/llvm/lib/Analysis/PtrUseVisitor.cpp
@@ -0,0 +1,35 @@
+//===- PtrUseVisitor.cpp - InstVisitors over a pointers uses --------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// Implementation of the pointer use visitors.
+///
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Analysis/PtrUseVisitor.h"
+
+using namespace llvm;
+
+void detail::PtrUseVisitorBase::enqueueUsers(Instruction &I) {
+ for (Use &U : I.uses()) {
+ if (VisitedUses.insert(&U).second) {
+ UseToVisit NewU = {
+ UseToVisit::UseAndIsOffsetKnownPair(&U, IsOffsetKnown),
+ Offset
+ };
+ Worklist.push_back(std::move(NewU));
+ }
+ }
+}
+
+bool detail::PtrUseVisitorBase::adjustOffsetForGEP(GetElementPtrInst &GEPI) {
+ if (!IsOffsetKnown)
+ return false;
+
+ return GEPI.accumulateConstantOffset(DL, Offset);
+}
OpenPOWER on IntegriCloud