PtrUseVisitor.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  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. #include "llvm/Analysis/PtrUseVisitor.h"
  14. using namespace llvm;
  15. void detail::PtrUseVisitorBase::enqueueUsers(Instruction &I) {
  16. for (Use &U : I.uses()) {
  17. if (VisitedUses.insert(&U).second) {
  18. UseToVisit NewU = {
  19. UseToVisit::UseAndIsOffsetKnownPair(&U, IsOffsetKnown),
  20. Offset
  21. };
  22. Worklist.push_back(std::move(NewU));
  23. }
  24. }
  25. }
  26. bool detail::PtrUseVisitorBase::adjustOffsetForGEP(GetElementPtrInst &GEPI) {
  27. if (!IsOffsetKnown)
  28. return false;
  29. return GEPI.accumulateConstantOffset(DL, Offset);
  30. }