2015-05-03 13:21:36 +08:00
|
|
|
//=== ScopLocation.cpp - Debug location for ScopDetection ----- -*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// Helper function for extracting region debug information.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
#include "polly/Support/ScopLocation.h"
|
2015-05-09 17:13:42 +08:00
|
|
|
#include "llvm/Analysis/RegionInfo.h"
|
2015-05-03 13:21:36 +08:00
|
|
|
#include "llvm/IR/BasicBlock.h"
|
|
|
|
#include "llvm/IR/DebugInfo.h"
|
|
|
|
#include "llvm/IR/DebugLoc.h"
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
namespace polly {
|
|
|
|
|
|
|
|
void getDebugLocation(const Region *R, unsigned &LineBegin, unsigned &LineEnd,
|
|
|
|
std::string &FileName) {
|
|
|
|
LineBegin = -1;
|
|
|
|
LineEnd = 0;
|
|
|
|
|
|
|
|
for (const BasicBlock *BB : R->blocks())
|
|
|
|
for (const Instruction &Inst : *BB) {
|
|
|
|
DebugLoc DL = Inst.getDebugLoc();
|
|
|
|
if (!DL)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
auto *Scope = cast<DIScope>(DL.getScope());
|
|
|
|
|
|
|
|
if (FileName.empty())
|
|
|
|
FileName = Scope->getFilename();
|
|
|
|
|
|
|
|
unsigned NewLine = DL.getLine();
|
|
|
|
|
|
|
|
LineBegin = std::min(LineBegin, NewLine);
|
|
|
|
LineEnd = std::max(LineEnd, NewLine);
|
|
|
|
}
|
|
|
|
}
|
2016-06-24 06:17:27 +08:00
|
|
|
} // namespace polly
|