-
Notifications
You must be signed in to change notification settings - Fork 444
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
) * Remove unused actions whose external name starts with '__' Signed-off-by: Kyle Cripps <kyle@pensando.io> * Add additional test case Signed-off-by: Kyle Cripps <kyle@pensando.io> --------- Signed-off-by: Kyle Cripps <kyle@pensando.io>
- Loading branch information
Showing
14 changed files
with
375 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <core.p4> | ||
|
||
struct S { | ||
bit<16> f; | ||
} | ||
|
||
extern bool foo(in bool x, in bool y); | ||
|
||
control C(inout S s) { | ||
action a1() { | ||
if (foo(s.f == 0, false)) { | ||
return; | ||
} | ||
} | ||
|
||
@name("._xyz") | ||
action a2() { | ||
a1(); | ||
a1(); | ||
} | ||
|
||
table t { | ||
actions = { a2; } | ||
} | ||
|
||
apply { | ||
t.apply(); | ||
} | ||
} | ||
|
||
control C2() { | ||
apply { | ||
S s; | ||
C.apply(s); | ||
} | ||
} | ||
|
||
control proto(); | ||
package top(proto p); | ||
|
||
top(C2()) main; |
41 changes: 41 additions & 0 deletions
41
testdata/p4_16_samples/issue4883_dup_has_returned_decl2.p4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#include <core.p4> | ||
|
||
struct S { | ||
bit<16> f; | ||
} | ||
|
||
extern bool foo(in bool x, in bool y); | ||
|
||
control C(inout S s) { | ||
action a1() { | ||
if (foo(s.f == 0, false)) { | ||
return; | ||
} | ||
} | ||
|
||
@name("a2") | ||
action __xyz() { | ||
a1(); | ||
a1(); | ||
} | ||
|
||
table t { | ||
actions = { __xyz; } | ||
} | ||
|
||
apply { | ||
t.apply(); | ||
} | ||
} | ||
|
||
control C2() { | ||
apply { | ||
S s; | ||
C.apply(s); | ||
} | ||
} | ||
|
||
control proto(); | ||
package top(proto p); | ||
|
||
top(C2()) main; |
40 changes: 40 additions & 0 deletions
40
testdata/p4_16_samples_outputs/issue4883_dup_has_returned_decl-first.p4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include <core.p4> | ||
|
||
struct S { | ||
bit<16> f; | ||
} | ||
|
||
extern bool foo(in bool x, in bool y); | ||
control C(inout S s) { | ||
action a1() { | ||
if (foo(s.f == 16w0, false)) { | ||
return; | ||
} | ||
} | ||
@name("._xyz") action a2() { | ||
a1(); | ||
a1(); | ||
} | ||
table t { | ||
actions = { | ||
a2(); | ||
@defaultonly NoAction(); | ||
} | ||
default_action = NoAction(); | ||
} | ||
apply { | ||
t.apply(); | ||
} | ||
} | ||
|
||
control C2() { | ||
@name("C") C() C_inst; | ||
apply { | ||
S s; | ||
C_inst.apply(s); | ||
} | ||
} | ||
|
||
control proto(); | ||
package top(proto p); | ||
top(C2()) main; |
31 changes: 31 additions & 0 deletions
31
testdata/p4_16_samples_outputs/issue4883_dup_has_returned_decl-frontend.p4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <core.p4> | ||
|
||
struct S { | ||
bit<16> f; | ||
} | ||
|
||
extern bool foo(in bool x, in bool y); | ||
control C2() { | ||
@name("C2.s") S s_0; | ||
@name("C2.C.tmp") bool C_tmp; | ||
@noWarn("unused") @name(".NoAction") action NoAction_1() { | ||
} | ||
@name("._xyz") action __xyz_0() { | ||
C_tmp = foo(s_0.f == 16w0, false); | ||
C_tmp = foo(s_0.f == 16w0, false); | ||
} | ||
@name("C2.C.t") table C_t { | ||
actions = { | ||
__xyz_0(); | ||
@defaultonly NoAction_1(); | ||
} | ||
default_action = NoAction_1(); | ||
} | ||
apply { | ||
C_t.apply(); | ||
} | ||
} | ||
|
||
control proto(); | ||
package top(proto p); | ||
top(C2()) main; |
30 changes: 30 additions & 0 deletions
30
testdata/p4_16_samples_outputs/issue4883_dup_has_returned_decl-midend.p4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <core.p4> | ||
|
||
struct S { | ||
bit<16> f; | ||
} | ||
|
||
extern bool foo(in bool x, in bool y); | ||
control C2() { | ||
@name("C2.s") S s_0; | ||
@noWarn("unused") @name(".NoAction") action NoAction_1() { | ||
} | ||
@name("._xyz") action __xyz_0() { | ||
foo(s_0.f == 16w0, false); | ||
foo(s_0.f == 16w0, false); | ||
} | ||
@name("C2.C.t") table C_t { | ||
actions = { | ||
__xyz_0(); | ||
@defaultonly NoAction_1(); | ||
} | ||
default_action = NoAction_1(); | ||
} | ||
apply { | ||
C_t.apply(); | ||
} | ||
} | ||
|
||
control proto(); | ||
package top(proto p); | ||
top(C2()) main; |
37 changes: 37 additions & 0 deletions
37
testdata/p4_16_samples_outputs/issue4883_dup_has_returned_decl.p4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#include <core.p4> | ||
|
||
struct S { | ||
bit<16> f; | ||
} | ||
|
||
extern bool foo(in bool x, in bool y); | ||
control C(inout S s) { | ||
action a1() { | ||
if (foo(s.f == 0, false)) { | ||
return; | ||
} | ||
} | ||
@name("._xyz") action a2() { | ||
a1(); | ||
a1(); | ||
} | ||
table t { | ||
actions = { | ||
a2; | ||
} | ||
} | ||
apply { | ||
t.apply(); | ||
} | ||
} | ||
|
||
control C2() { | ||
apply { | ||
S s; | ||
C.apply(s); | ||
} | ||
} | ||
|
||
control proto(); | ||
package top(proto p); | ||
top(C2()) main; |
6 changes: 6 additions & 0 deletions
6
testdata/p4_16_samples_outputs/issue4883_dup_has_returned_decl.p4-stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
issue4883_dup_has_returned_decl.p4(34): [--Wwarn=uninitialized_use] warning: s.f may be uninitialized | ||
C.apply(s); | ||
^ | ||
issue4883_dup_has_returned_decl.p4(11): [--Wwarn=uninitialized_use] warning: s.f may be uninitialized | ||
if (foo(s.f == 0, false)) { | ||
^^^ |
40 changes: 40 additions & 0 deletions
40
testdata/p4_16_samples_outputs/issue4883_dup_has_returned_decl2-first.p4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include <core.p4> | ||
|
||
struct S { | ||
bit<16> f; | ||
} | ||
|
||
extern bool foo(in bool x, in bool y); | ||
control C(inout S s) { | ||
action a1() { | ||
if (foo(s.f == 16w0, false)) { | ||
return; | ||
} | ||
} | ||
@name("a2") action __xyz() { | ||
a1(); | ||
a1(); | ||
} | ||
table t { | ||
actions = { | ||
__xyz(); | ||
@defaultonly NoAction(); | ||
} | ||
default_action = NoAction(); | ||
} | ||
apply { | ||
t.apply(); | ||
} | ||
} | ||
|
||
control C2() { | ||
@name("C") C() C_inst; | ||
apply { | ||
S s; | ||
C_inst.apply(s); | ||
} | ||
} | ||
|
||
control proto(); | ||
package top(proto p); | ||
top(C2()) main; |
31 changes: 31 additions & 0 deletions
31
testdata/p4_16_samples_outputs/issue4883_dup_has_returned_decl2-frontend.p4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <core.p4> | ||
|
||
struct S { | ||
bit<16> f; | ||
} | ||
|
||
extern bool foo(in bool x, in bool y); | ||
control C2() { | ||
@name("C2.s") S s_0; | ||
@name("C2.C.tmp") bool C_tmp; | ||
@noWarn("unused") @name(".NoAction") action NoAction_1() { | ||
} | ||
@name("C2.C.a2") action C_a2_0() { | ||
C_tmp = foo(s_0.f == 16w0, false); | ||
C_tmp = foo(s_0.f == 16w0, false); | ||
} | ||
@name("C2.C.t") table C_t { | ||
actions = { | ||
C_a2_0(); | ||
@defaultonly NoAction_1(); | ||
} | ||
default_action = NoAction_1(); | ||
} | ||
apply { | ||
C_t.apply(); | ||
} | ||
} | ||
|
||
control proto(); | ||
package top(proto p); | ||
top(C2()) main; |
30 changes: 30 additions & 0 deletions
30
testdata/p4_16_samples_outputs/issue4883_dup_has_returned_decl2-midend.p4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include <core.p4> | ||
|
||
struct S { | ||
bit<16> f; | ||
} | ||
|
||
extern bool foo(in bool x, in bool y); | ||
control C2() { | ||
@name("C2.s") S s_0; | ||
@noWarn("unused") @name(".NoAction") action NoAction_1() { | ||
} | ||
@name("C2.C.a2") action C_a2_0() { | ||
foo(s_0.f == 16w0, false); | ||
foo(s_0.f == 16w0, false); | ||
} | ||
@name("C2.C.t") table C_t { | ||
actions = { | ||
C_a2_0(); | ||
@defaultonly NoAction_1(); | ||
} | ||
default_action = NoAction_1(); | ||
} | ||
apply { | ||
C_t.apply(); | ||
} | ||
} | ||
|
||
control proto(); | ||
package top(proto p); | ||
top(C2()) main; |
Oops, something went wrong.