[PATCH 01/11] Move getDebugLocation to ScopDetectionDiagnostic
Tobias Grosser
tobias at grosser.es
Mon Jun 9 03:27:25 PDT 2014
On 09/06/2014 02:42, Andreas Simbuerger wrote:
> ---
> include/polly/ScopDetection.h | 9 ---------
> include/polly/ScopDetectionDiagnostic.h | 10 ++++++++++
> lib/Analysis/ScopDetection.cpp | 23 -----------------------
> lib/Analysis/ScopDetectionDiagnostic.cpp | 27 +++++++++++++++++++++++++++
> 4 files changed, 37 insertions(+), 32 deletions(-)
>
> diff --git a/include/polly/ScopDetection.h b/include/polly/ScopDetection.h
> index d72c5aa..5bab520 100644
> --- a/include/polly/ScopDetection.h
> +++ b/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/include/polly/ScopDetectionDiagnostic.h b/include/polly/ScopDetectionDiagnostic.h
> index b510e78..1006770 100644
> --- a/include/polly/ScopDetectionDiagnostic.h
> +++ b/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/lib/Analysis/ScopDetection.cpp b/lib/Analysis/ScopDetection.cpp
> index 9c25308..8a9226e 100644
> --- a/lib/Analysis/ScopDetection.cpp
> +++ b/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/lib/Analysis/ScopDetectionDiagnostic.cpp b/lib/Analysis/ScopDetectionDiagnostic.cpp
> index 4a3091d..eaed954 100644
> --- a/lib/Analysis/ScopDetectionDiagnostic.cpp
> +++ b/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 <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.
>
> @@ -205,4 +231,5 @@ std::string ReportPHIinExit::getMessage() const {
> std::string ReportEntry::getMessage() const {
> return "Region containing entry block of function is invalid!";
> }
> +
Unrelated change.
> } // namespace polly
Otherwise, looks good to me.
Tobias
More information about the llvm-commits
mailing list