Pocc: Fix some bugs in the PoCC optimizer pass

This includes:
  - The isl_id of the domain of the scattering must be copied from the original
    domain
  - Remove outdated references to a 'FinalRead' statement
  - Print of the Pocc output, if -debug is provided.
  - Add line breaks to some error messages.

Reported and Debugged by:  Dustin Feld  <d3.feld@gmail.com>

llvm-svn: 162901
This commit is contained in:
Tobias Grosser 2012-08-30 11:49:38 +00:00
parent 4a7527e0eb
commit cd95b77330
4 changed files with 24 additions and 10 deletions

View File

@ -309,6 +309,11 @@ public:
/// @return The space of the iteration domain
isl_space *getDomainSpace() const;
/// @brief Get the id of the iteration domain space
///
/// @return The id of the iteration domain space
isl_id *getDomainId() const;
/// @brief Get an isl string representing this domain.
std::string getDomainStr() const;

View File

@ -676,6 +676,10 @@ isl_space *ScopStmt::getDomainSpace() const {
return isl_set_get_space(Domain);
}
isl_id *ScopStmt::getDomainId() const {
return isl_set_get_tuple_id(Domain);
}
ScopStmt::~ScopStmt() {
while (!MemAccs.empty()) {
delete MemAccs.back();

View File

@ -652,7 +652,7 @@ isl_map *scatteringForStmt(scoplib_matrix_p m, ScopStmt *PollyStmt,
isl_space_free(ParamSpace);
Space = isl_space_set_tuple_name(Space, isl_dim_out, "scattering");
Space = isl_space_set_tuple_name(Space, isl_dim_in, PollyStmt->getBaseName());
Space = isl_space_set_tuple_id(Space, isl_dim_in, PollyStmt->getDomainId());
if (scatteringDims == -1)
return mapFromMatrix(m, Space);

View File

@ -24,6 +24,8 @@
#include "polly/ScheduleOptimizer.h"
#include "polly/ScopInfo.h"
#define DEBUG_TYPE "polly-opt-pocc"
#include "llvm/Support/Debug.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/Program.h"
#include "llvm/Support/MemoryBuffer.h"
@ -62,20 +64,17 @@ namespace {
virtual bool runOnScop(Scop &S);
void printScop(llvm::raw_ostream &OS) const;
void getAnalysisUsage(AnalysisUsage &AU) const;
private:
bool runTransform(Scop &S);
};
}
char Pocc::ID = 0;
bool Pocc::runOnScop(Scop &S) {
bool Pocc::runTransform(Scop &S) {
Dependences *D = &getAnalysis<Dependences>();
// Only the final read statement in the SCoP. No need to optimize anything.
// (In case we would try, Pocc complains that there is no statement in the
// SCoP).
if (S.begin() + 1 == S.end())
return false;
// Create the scop file.
sys::Path tempDir = sys::Path::GetTemporaryDirectory();
sys::Path scopFile = tempDir;
@ -234,6 +233,12 @@ bool Pocc::runOnScop(Scop &S) {
return false;
}
bool Pocc::runOnScop(Scop &S) {
bool Result = runTransform(S);
DEBUG(printScop(dbgs()));
return Result;
}
void Pocc::printScop(raw_ostream &OS) const {
OwningPtr<MemoryBuffer> stdoutBuffer;
@ -249,14 +254,14 @@ void Pocc::printScop(raw_ostream &OS) const {
OS << "\n";
if (error_code ec = MemoryBuffer::getFile(plutoStdout.c_str(), stdoutBuffer))
OS << "Could not open pocc stdout file: " + ec.message();
OS << "Could not open pocc stdout file: " + ec.message() << "\n";
else {
OS << "pocc stdout: " << stdoutBuffer->getBufferIdentifier() << "\n";
OS << stdoutBuffer->getBuffer() << "\n";
}
if (error_code ec = MemoryBuffer::getFile(plutoStderr.c_str(), stderrBuffer))
OS << "Could not open pocc stderr file: " + ec.message();
OS << "Could not open pocc stderr file: " + ec.message() << "\n";
else {
OS << "pocc stderr: " << plutoStderr.c_str() << "\n";
OS << stderrBuffer->getBuffer() << "\n";