You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tmp4.p4(5): [--Wwarn=uninitialized_use] warning: f may be uninitialized
f[3:0] = 2;
^
It doesn't make sense to print this kind of warning about a write to an uninitialized field. The code in SimplifyDefUse considers these assignments to "read" the sliced l-value f, but this is a gross hack and the logic should be rewritten in a more sensible way. Doing so should result in this unhelpful warning going away.
A similar problem was recently fixed in the ParsersUnroll pass: #4948
The text was updated successfully, but these errors were encountered:
kfcripps
added
bug
This behavior is unintended and should be fixed.
core
Topics concerning the core segments of the compiler (frontend, midend, parser)
labels
Oct 13, 2024
It's not actually that it considers sliced assignments to be "reads" -- its that it considered sliced assignments to not replace all previous writes to the variable. Fixing this would require tracking each bit of each variable individually, instead of just tracking the variable as a whole.
Fixing this would require tracking each bit of each variable individually, instead of just tracking the variable as a whole.
I agree, that's basically what needs to be done for this issue. I spent some time trying something like this but I gave up as I couldn't get it to work initially and didn't want to spend anymore time working on it.
Fixing this would require tracking each bit of each variable individually, instead of just tracking the variable as a whole.
Alternatively, we can just be conservative in SimplifyDefUse (but the current behavior of treating writes as reads is too conservative):
A write to an l-value should clobber all previous writes to slices of the same l-value
A read of some l-value should be considered as a read of all previously written slices of the same l-value
A write to an l-value slice should be treated as a write to that specific slice only
A read of a sliced l-value should be considered as a read of the whole l-value (and therefore as a read of all previously written slices of the same l-value)
The SliceTracker logic should be moved to its own separate pass (this is where we can more carefully track each read/written bit individually)
Building the following P4 program:
results in the following warning:
It doesn't make sense to print this kind of warning about a write to an uninitialized field. The code in
SimplifyDefUse
considers these assignments to "read" the sliced l-valuef
, but this is a gross hack and the logic should be rewritten in a more sensible way. Doing so should result in this unhelpful warning going away.A similar problem was recently fixed in the
ParsersUnroll
pass: #4948The text was updated successfully, but these errors were encountered: