/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/lib/Analysis/PtrUseVisitor.cpp
Line | Count | Source |
1 | | //===- PtrUseVisitor.cpp - InstVisitors over a pointers uses --------------===// |
2 | | // |
3 | | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
4 | | // See https://llvm.org/LICENSE.txt for license information. |
5 | | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
6 | | // |
7 | | //===----------------------------------------------------------------------===// |
8 | | // |
9 | | /// \file |
10 | | /// Implementation of the pointer use visitors. |
11 | | // |
12 | | //===----------------------------------------------------------------------===// |
13 | | |
14 | | #include "llvm/Analysis/PtrUseVisitor.h" |
15 | | #include "llvm/IR/Instruction.h" |
16 | | #include "llvm/IR/Instructions.h" |
17 | | #include <algorithm> |
18 | | |
19 | | using namespace llvm; |
20 | | |
21 | 2.32M | void detail::PtrUseVisitorBase::enqueueUsers(Instruction &I) { |
22 | 6.59M | for (Use &U : I.uses()) { |
23 | 6.59M | if (VisitedUses.insert(&U).second) { |
24 | 6.59M | UseToVisit NewU = { |
25 | 6.59M | UseToVisit::UseAndIsOffsetKnownPair(&U, IsOffsetKnown), |
26 | 6.59M | Offset |
27 | 6.59M | }; |
28 | 6.59M | Worklist.push_back(std::move(NewU)); |
29 | 6.59M | } |
30 | 6.59M | } |
31 | 2.32M | } |
32 | | |
33 | 367k | bool detail::PtrUseVisitorBase::adjustOffsetForGEP(GetElementPtrInst &GEPI) { |
34 | 367k | if (!IsOffsetKnown) |
35 | 331 | return false; |
36 | 367k | |
37 | 367k | APInt TmpOffset(DL.getIndexTypeSizeInBits(GEPI.getType()), 0); |
38 | 367k | if (GEPI.accumulateConstantOffset(DL, TmpOffset)) { |
39 | 363k | Offset += TmpOffset.sextOrTrunc(Offset.getBitWidth()); |
40 | 363k | return true; |
41 | 363k | } |
42 | 4.20k | |
43 | 4.20k | return false; |
44 | 4.20k | } |