Polly 19.0.0git
ScopLocation.cpp
Go to the documentation of this file.
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//
14#include "llvm/Analysis/RegionInfo.h"
15#include "llvm/IR/DebugInfoMetadata.h"
16
17using namespace llvm;
18
19namespace polly {
20
21void getDebugLocation(const Region *R, unsigned &LineBegin, unsigned &LineEnd,
22 std::string &FileName) {
23 LineBegin = -1;
24 LineEnd = 0;
25
26 for (const BasicBlock *BB : R->blocks())
27 for (const Instruction &Inst : *BB) {
28 DebugLoc DL = Inst.getStableDebugLoc();
29 if (!DL)
30 continue;
31
32 auto *Scope = cast<DIScope>(DL.getScope());
33
34 if (FileName.empty())
35 FileName = Scope->getFilename().str();
36
37 unsigned NewLine = DL.getLine();
38
39 LineBegin = std::min(LineBegin, NewLine);
40 LineEnd = std::max(LineEnd, NewLine);
41 }
42}
43} // namespace polly
This file contains the declaration of the PolyhedralInfo class, which will provide an interface to ex...
void getDebugLocation(const llvm::Region *R, unsigned &LineBegin, unsigned &LineEnd, std::string &FileName)
Get the location of a region from the debug info.