-
Notifications
You must be signed in to change notification settings - Fork 500
Open
Labels
coreTopics concerning the core segments of the compiler (frontend, midend, parser)Topics concerning the core segments of the compiler (frontend, midend, parser)
Description
Log:
Error compiling
issuex.p4(24): [--Wwarn=unreachable] warning: accept state in parser SubParserReject is unreachable
parser SubParserReject(packet_in packet,
^^^^^^^^^^^^^^^
def_use.h:531
Compiler Bug: no definitions found for <Type_Boolean>(28091) bool hdr/hdr.hs[0].$valid
Input program:
#include <core.p4>
parser ParserDef<H, M>(packet_in packet,
out H hdr,
inout M meta);
package ParserOnlyArch<H, M>(ParserDef<H, M> p);
header hdr0_t {
bit<8> f0;
bit<8> f1;
}
struct metadata {
bit<8> m0;
bit<8> m1;
}
struct headers {
hdr0_t h0;
hdr0_t[3] hs;
}
parser SubParserReject(packet_in packet,
inout metadata meta,
in bit<8> val) {
state start {
meta.m0 = meta.m0 + val;
transition reject;
}
}
parser Parser(packet_in packet,
out headers hdr,
inout metadata meta) {
SubParserReject() subParser;
state start {
packet.extract(hdr.h0);
subParser.apply(packet, meta, hdr.h0.f0);
transition state0;
}
state state0 {
packet.extract(hdr.hs.next);
transition select(hdr.hs.last.f0) {
0: state0;
default: accept;
}
}
}
ParserOnlyArch(
Parser()
) main;
P4 dump after SimplifyDefUse pass:
#include <core.p4>
parser ParserDef<H, M>(packet_in packet, out H hdr, inout M meta);
package ParserOnlyArch<H, M>(ParserDef<H, M> p);
header hdr0_t {
bit<8> f0;
bit<8> f1;
}
struct metadata {
bit<8> m0;
bit<8> m1;
}
struct headers {
hdr0_t h0;
hdr0_t[3] hs;
}
parser Parser(packet_in packet, out headers hdr, inout metadata meta) {
state start {
packet.extract<hdr0_t>(hdr.h0);
transition SubParserReject_start;
}
state SubParserReject_start {
meta.m0 = meta.m0 + hdr.h0.f0;
transition reject;
}
state state0 {
packet.extract<hdr0_t>(hdr.hs.next);
transition select(hdr.hs.last.f0) {
8w0: state0;
default: accept;
}
}
}
ParserOnlyArch<headers, metadata>(Parser()) main;
Seems like the sub parser inlining pass Inline did not remove the unused/unreachable state state0. ComputeWriteSet in the SimplifyDefUse pass on the other hand, uses parser call graph to traverse the graph and collects defuse info, but not for the state0 state. This later causes crash on missing info.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
coreTopics concerning the core segments of the compiler (frontend, midend, parser)Topics concerning the core segments of the compiler (frontend, midend, parser)