p4c: Follow-up issue on exit statements
As @jafingerhut pointed out in #2225 , there might be some fallout from the exit changes. One of them is an edge-case in how to handle SideEffectOrdering.
SideEffectOrdering transforms the following program:
control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) {
action NoAction() {
}
action call_exit(inout bit<48> val, in bit<48> val1) {
val = 1;
exit;
}
apply {
call_exit(h.eth_hdr.src_addr, h.eth_hdr.src_addr);
}
}
into
control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) {
@name("call_exit") action call_exit_0(inout bit<48> val, in bit<48> val1) {
val = 48w1;
exit;
}
bit<48> tmp;
bit<48> tmp_0;
apply {
{
tmp = h.eth_hdr.src_addr;
tmp_0 = h.eth_hdr.src_addr;
call_exit_0(tmp, tmp_0);
h.eth_hdr.src_addr = tmp;
}
}
}
which still looks okay, but ultimately this change causes this transformation in the MidEnd pass RemoveActionParameters:
control ingress(inout Headers h, inout Meta m, inout standard_metadata_t sm) {
bit<48> tmp;
bit<48> tmp_0;
bit<48> val;
bit<48> val1;
@name("ingress.call_exit") action call_exit() {
val = tmp;
val1 = tmp_0;
val = 48w1;
tmp = val;
exit;
tmp = val;
}
apply {
tmp = h.eth_hdr.src_addr;
tmp_0 = h.eth_hdr.src_addr;
call_exit();
h.eth_hdr.src_addr = tmp;
}
}
Here, h.eth_hdr.src_addr will never be assigned the value 1, from what I can tell.
side_effect_ordering_exit.p4.txt side_effect_ordering_exit.stf.txt
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 28 (26 by maintainers)
The enclosing control is exited, always. The copy-out behavior (up the entire “call stack”) is the only thing done after the exit statement is executed – nothing else.