This is an archive of the discontinued LLVM Phabricator instance.

[mlir][DCA] Fix visiting call ops when run at function scopes
ClosedPublic

Authored by Mogball on Jul 30 2022, 7:25 PM.

Details

Summary

When dead-code analysis is run at the scope of a function, call ops to
other functions at the same level were being marked as unreachable,
since the analysis optimistically assumes the call op to have no known
predecessors and that all predecessors are known, but the callee would
never get visited.

This patch fixes the bug by checking if a referenced function is above
the top-level op of the analysis, and is thus considered an external
callable.

Fixes #56830

Diff Detail

Event Timeline

Mogball created this revision.Jul 30 2022, 7:25 PM
Mogball requested review of this revision.Jul 30 2022, 7:25 PM
zero9178 accepted this revision.Jul 31 2022, 3:51 AM

LGTM!
Tested with my downstream compiler which was originally affected as well and it works perfectly now.

(Here is the corresponding GitHub issue you wanted as well, so that you can refer to it in the commit message: https://github.com/llvm/llvm-project/issues/56830)

mlir/include/mlir/Analysis/DataFlow/DeadCodeAnalysis.h
239
This revision is now accepted and ready to land.Jul 31 2022, 3:51 AM
Mogball edited the summary of this revision. (Show Details)Jul 31 2022, 1:00 PM
This revision was landed with ongoing or failed builds.Jul 31 2022, 1:03 PM
This revision was automatically updated to reflect the committed changes.