forked from OSchip/llvm-project
Move getDebugLocation to ScopDetectionDiagnostic
llvm-svn: 210752
This commit is contained in:
parent
3aa4fb3b8b
commit
fbd643c9e1
|
@ -258,15 +258,6 @@ class ScopDetection : public FunctionPass {
|
|||
/// @return True if the function is not an OpenMP subfunction.
|
||||
bool isValidFunction(llvm::Function &F);
|
||||
|
||||
/// @brief Get the location of a region from the debug info.
|
||||
///
|
||||
/// @param R The region to get debug info for.
|
||||
/// @param LineBegin The first line in the region.
|
||||
/// @param LineEnd The last line in the region.
|
||||
/// @param FileName The filename where the region was defined.
|
||||
void getDebugLocation(const Region *R, unsigned &LineBegin, unsigned &LineEnd,
|
||||
std::string &FileName);
|
||||
|
||||
/// @brief Print the locations of all detected scops.
|
||||
void printLocations(llvm::Function &F);
|
||||
|
||||
|
|
|
@ -42,6 +42,16 @@ class Region;
|
|||
}
|
||||
|
||||
namespace polly {
|
||||
|
||||
/// @brief Get the location of a region from the debug info.
|
||||
///
|
||||
/// @param R The region to get debug info for.
|
||||
/// @param LineBegin The first line in the region.
|
||||
/// @param LineEnd The last line in the region.
|
||||
/// @param FileName The filename where the region was defined.
|
||||
void getDebugLocation(const Region *R, unsigned &LineBegin, unsigned &LineEnd,
|
||||
std::string &FileName);
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// @brief Base class of all reject reasons found during Scop detection.
|
||||
///
|
||||
|
|
|
@ -762,29 +762,6 @@ bool ScopDetection::isValidFunction(llvm::Function &F) {
|
|||
return !InvalidFunctions.count(&F);
|
||||
}
|
||||
|
||||
void ScopDetection::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.isUnknown())
|
||||
continue;
|
||||
|
||||
DIScope Scope(DL.getScope(Inst.getContext()));
|
||||
|
||||
if (FileName.empty())
|
||||
FileName = Scope.getFilename();
|
||||
|
||||
unsigned NewLine = DL.getLine();
|
||||
|
||||
LineBegin = std::min(LineBegin, NewLine);
|
||||
LineEnd = std::max(LineEnd, NewLine);
|
||||
}
|
||||
}
|
||||
|
||||
void ScopDetection::printLocations(llvm::Function &F) {
|
||||
for (const Region *R : *this) {
|
||||
unsigned LineEntry, LineExit;
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
#include "llvm/ADT/SmallVector.h"
|
||||
#include "llvm/ADT/Statistic.h"
|
||||
|
||||
#include "llvm/Analysis/RegionInfo.h"
|
||||
#include "llvm/IR/DebugInfo.h"
|
||||
|
||||
#define DEBUG_TYPE "polly-detect"
|
||||
#include "llvm/Support/Debug.h"
|
||||
|
||||
|
@ -55,6 +58,29 @@ template <typename T> std::string operator+(Twine LHS, const T &RHS) {
|
|||
return LHS.concat(Buf).str();
|
||||
}
|
||||
|
||||
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.isUnknown())
|
||||
continue;
|
||||
|
||||
DIScope Scope(DL.getScope(Inst.getContext()));
|
||||
|
||||
if (FileName.empty())
|
||||
FileName = Scope.getFilename();
|
||||
|
||||
unsigned NewLine = DL.getLine();
|
||||
|
||||
LineBegin = std::min(LineBegin, NewLine);
|
||||
LineEnd = std::max(LineEnd, NewLine);
|
||||
}
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// ReportCFG.
|
||||
|
||||
|
|
Loading…
Reference in New Issue