Skip to content

[Cross-platform] Bug fix for #39713 where assigned temprefs lost their write flag

Summary

This merge request fixes an internal error (200203272) in the AArch64 cross-compilation process under -CriotR rules where a particular setup with the Inc intrinsic and an inlined function as the increment value caused a bad node branch to be generated once it passed through constant propagation. The nf_write flag was cleared for a tempref (used to replace a formal parameter) inside an "assign" node which caused it to be replaced with a constant (the inlined function's actual parameter), thus causing an internal error later on when it tries to generate the code and doesn't find a register or reference as expected.

System

  • Processor architecture: AArch64, possibly others (untested).

What is the current bug behavior?

Under aarch64-linux, running make fullcycle OPT="-O3 -CriotR" would cause an internal error to be raised when cross-compiling for arm and sparc due to an unintentionally contrived set-up with Inc and the inlined align function.

What is the behavior after applying this patch?

make fullcycle OPT="-O3 -CriotR" and the test inside the 993767ed commit should compile and run successfully.

Relevant logs and/or screenshots

See #39713 (closed).

Additional notes

  • The faulty node tree is only generated under -CriotR rules because different nodes are generated for Inc and Dec intrinsics.
  • Part of the above node generation involves resetting the nf_pass1_done, nf_write and nf_modify flags for the nodes that represent the value to increment a variable by. Unfortunately, the nf_write flag is not set again on the next run of firstpass because this is done as part of an assign node's type check, and the assign nodes already have their types by this point.
  • To mitigate this, on top of clearing the above three flags, the merge request now also clears the type information of assign nodes, forcing the re-evaluation of their targets and hence enabling the nf_write flag again.
  • Clearing the type information of all nodes in this branch is generally overkill and can cause other internal errors and inconsistent states to be generated, hence why only assign nodes are selectively cleared.
Edited by J. Gareth "Kit" Moreton

Merge request reports