/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/tools/polly/lib/Support/ScopLocation.cpp
Line | Count | Source |
1 | | //=== ScopLocation.cpp - Debug location for ScopDetection ----- -*- C++ -*-===// |
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 | | // Helper function for extracting region debug information. |
10 | | // |
11 | | //===----------------------------------------------------------------------===// |
12 | | // |
13 | | #include "polly/Support/ScopLocation.h" |
14 | | #include "llvm/Analysis/RegionInfo.h" |
15 | | #include "llvm/IR/DebugInfoMetadata.h" |
16 | | |
17 | | using namespace llvm; |
18 | | |
19 | | namespace polly { |
20 | | |
21 | | void getDebugLocation(const Region *R, unsigned &LineBegin, unsigned &LineEnd, |
22 | 6 | std::string &FileName) { |
23 | 6 | LineBegin = -1; |
24 | 6 | LineEnd = 0; |
25 | 6 | |
26 | 6 | for (const BasicBlock *BB : R->blocks()) |
27 | 81 | for (const Instruction &Inst : *BB)27 { |
28 | 81 | DebugLoc DL = Inst.getDebugLoc(); |
29 | 81 | if (!DL) |
30 | 67 | continue; |
31 | 14 | |
32 | 14 | auto *Scope = cast<DIScope>(DL.getScope()); |
33 | 14 | |
34 | 14 | if (FileName.empty()) |
35 | 2 | FileName = Scope->getFilename(); |
36 | 14 | |
37 | 14 | unsigned NewLine = DL.getLine(); |
38 | 14 | |
39 | 14 | LineBegin = std::min(LineBegin, NewLine); |
40 | 14 | LineEnd = std::max(LineEnd, NewLine); |
41 | 14 | } |
42 | 6 | } |
43 | | } // namespace polly |