Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed crashes when no statement in scop in PlutoTransform #52

Merged
merged 1 commit into from
Nov 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/polymer/Support/OslScop.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ class OslScop {
/// Get statement by index.
mlir::LogicalResult getStatement(unsigned index, osl_statement **stmt);

/// Get the total number of statements
unsigned getNumStatements() const;

/// Get extension by interface name
osl_generic *getExtension(llvm::StringRef interface) const;

Expand Down
4 changes: 4 additions & 0 deletions lib/Support/OslScop.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,10 @@ LogicalResult OslScop::getStatement(unsigned index, osl_statement **stmt) {
return success();
}

unsigned OslScop::getNumStatements() const {
return osl_statement_number(scop->statement);
}

osl_generic_p OslScop::getExtension(llvm::StringRef tag) const {
osl_generic_p ext = scop->extension;
osl_interface_p interface = osl_interface_lookup(scop->registry, tag.data());
Expand Down
8 changes: 7 additions & 1 deletion lib/Transforms/PlutoTransform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,13 @@ struct PlutoTransform : public OpConversionPattern<mlir::FuncOp> {
"Cannot emit a valid OpenScop representation from the given FuncOp.");
return failure();
}
// scop->print();

if (scop->getNumStatements() == 0) {
// TODO: Is there a good way to replace this pair?
rewriter.startRootUpdate(funcOp);
rewriter.finalizeRootUpdate(funcOp);
return success();
}

// Should use isldep, candl cannot work well for this case.
// TODO: should discover why.
Expand Down
9 changes: 9 additions & 0 deletions test/polymer-opt/PlutoTransform/empty.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// RUN: polymer-opt %s -pluto-opt | FileCheck %s

func @empty() {
return
}

// CHECK: func @empty() {
// CHECK-NEXT: return
// CHECK-NEXT: }