1 //=== ScopLocation.cpp - Debug location for ScopDetection ----- -*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
9 // Helper function for extracting region debug information.
11 //===----------------------------------------------------------------------===//
13 #include "polly/Support/ScopLocation.h"
14 #include "llvm/Analysis/RegionInfo.h"
15 #include "llvm/IR/DebugInfoMetadata.h"
21 void getDebugLocation(const Region
*R
, unsigned &LineBegin
, unsigned &LineEnd
,
22 std::string
&FileName
) {
26 for (const BasicBlock
*BB
: R
->blocks())
27 for (const Instruction
&Inst
: *BB
) {
28 DebugLoc DL
= Inst
.getStableDebugLoc();
32 auto *Scope
= cast
<DIScope
>(DL
.getScope());
35 FileName
= Scope
->getFilename().str();
37 unsigned NewLine
= DL
.getLine();
39 LineBegin
= std::min(LineBegin
, NewLine
);
40 LineEnd
= std::max(LineEnd
, NewLine
);