Skip to content
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
5 changes: 3 additions & 2 deletions lib/Dialect/LLHD/Transforms/InlineCalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,9 @@ LogicalResult InlineCallsPass::runOnRegion(Region &region,
// the inlined operations immediately after visiting the call.
for (auto &block : region) {
for (auto &op : block) {
// If this is an op after a call, pop that call off the call stack.
if (!inlineEndMarkers.empty() && inlineEndMarkers.back().first == &op) {
// Pop all calls that are followed by this op off the call stack.
while (!inlineEndMarkers.empty() &&
inlineEndMarkers.back().first == &op) {
assert(inlineEndMarkers.back().second == callStack.back());
LLVM_DEBUG(llvm::dbgs()
<< "- Finished @"
Expand Down
8 changes: 7 additions & 1 deletion test/Dialect/LLHD/Transforms/inline-calls.mlir
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func.func private @foo(%arg0: i42, %arg1: i42) -> (i42, i42) {
cf.br ^bb1
^bb1:
%0 = comb.add %arg0, %arg1 : i42
%1 = call @bar(%arg0) : (i42) -> i42
%1 = call @bar_wrapper(%arg0) : (i42) -> i42
%2 = comb.mul %1, %arg1 : i42
cf.br ^bb2
^bb2:
Expand All @@ -62,3 +62,9 @@ func.func private @bar(%arg0: i42) -> i42 {
%1 = comb.xor %arg0, %0 : i42
return %1 : i42
}

// CHECK-DCE-NOT: @bar_wrapper
func.func private @bar_wrapper(%arg0: i42) -> i42 {
%0 = call @bar(%arg0) : (i42) -> i42
return %0 : i42
}