diff --git a/polly/include/polly/ScopDetection.h b/polly/include/polly/ScopDetection.h index d72c5aa33bb2..5bab5208c663 100644 --- a/polly/include/polly/ScopDetection.h +++ b/polly/include/polly/ScopDetection.h @@ -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); diff --git a/polly/include/polly/ScopDetectionDiagnostic.h b/polly/include/polly/ScopDetectionDiagnostic.h index b510e7848216..1006770adaef 100644 --- a/polly/include/polly/ScopDetectionDiagnostic.h +++ b/polly/include/polly/ScopDetectionDiagnostic.h @@ -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. /// diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp index 9c25308ccece..8a9226e63316 100644 --- a/polly/lib/Analysis/ScopDetection.cpp +++ b/polly/lib/Analysis/ScopDetection.cpp @@ -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; diff --git a/polly/lib/Analysis/ScopDetectionDiagnostic.cpp b/polly/lib/Analysis/ScopDetectionDiagnostic.cpp index 4a3091d815bd..0fa7ba7cd002 100644 --- a/polly/lib/Analysis/ScopDetectionDiagnostic.cpp +++ b/polly/lib/Analysis/ScopDetectionDiagnostic.cpp @@ -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 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.