Skip to content

Commit

Permalink
[ExtractTopFunc] avoid setting private to public
Browse files Browse the repository at this point in the history
  • Loading branch information
kumasento committed Oct 27, 2021
1 parent 70ed446 commit be07e3e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/mlir/Transforms/ExtractTopFunc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,10 @@ struct ExtractTopFuncPass
unionCallee(f, m, keep);

m.walk([&](FuncOp g) {
if (!keep.contains(g) && !keepAll)
g.erase();
else // Enforce every extracted function to be public
if (!keep.contains(g)) {
if (!keepAll)
g.erase();
} else // Enforce every extracted function to be public
g.setVisibility(SymbolTable::Visibility::Public);
});
}
Expand Down
7 changes: 7 additions & 0 deletions test/mlir/Transforms/ExtractTopFunc/keep-all.mlir
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// RUN: phism-opt %s -extract-top-func="name=foo keepall=1" | FileCheck %s

func private @bar() { return }
func @foo() { return }

// CHECK: func private @bar
// CHECK: func @foo

0 comments on commit be07e3e

Please sign in to comment.