Defuse analysis fails with "Overwriting definitions" #3650
Closed
Description
The attached file: defuse_fail.p4.txt triggers a failed BUG_CHECK during def-use analysis:
Compiler Bug: Overwriting definitions at <BlockStatement>(1396)
I checked the IR before def-use is invoked - the problematic BlockStatement is reachable on two control-flow program paths, but def-use seems to assume the IR doesn't share nodes. The node sharing is created by the inlining pass (running before defuse since #3591). Inlining substitutes both C1.apply method calls with C1 body, but the body isn't deep-copied, hence the two places where C1 is inlined share part of the IR subtree.