8000 Fixes related to type and function specialization by mihaibudiu · Pull Request #3458 · p4lang/p4c · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fixes related to type and function specialization #3458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 7, 2022

Conversation

mihaibudiu
Copy link
Contributor

Signed-off-by: Mihai Budiu mbudiu@vmware.com
Fixes #3291
The fix is in the typechecking code.
But the tests revealed some bugs in the specialization code: now we insert the specialized function code in a different place in the source code, to make sure it's after all type declarations that it may depend on. So the function specialization code is more similar to the existing type specialization code.

@mihaibudiu mihaibudiu requested a review from fruffy July 22, 2022 20:42
@mihaibudiu
Copy link
Contributor Author

@fruffy It looks like gauntlet does not like one of the new tests.

@fruffy
Copy link
Collaborator
fruffy commented Jul 24, 2022

Gauntlet complains about this transformation:

bool g_0(in h_0 a) {
    @name("v") h<h_0> v_0;
    v_0.f = a;
    return v_0.f == a;
}
bool gg() {
    bool tmp;
    @name("a") h_0 a_0;
    a_0 = (h_0){f = 1w0};
    tmp = g_0(a_0);
    return tmp;
}
control c(out bool x) {
    apply {
        x = gg();
    }
}

to

bool g_0(in h_0 a) {
    @name("v") h<h_0> v_0;
    ;
    return v_0.f == a;
}
bool gg() {
    bool tmp;
    @name("a") h_0 a_0;
    a_0 = (h_0){f = 1w0};
    tmp = g_0(a_0);
    return tmp;
}
control c(out bool x) {
    apply {
        x = gg();
    }
}

Removing the v_0.f = a; does not seem correct to me, unless I am missing something. Since v_0 is not initialized. Also, this is a struct, so validity does not come into play here.

@mihaibudiu
Copy link
Contributor Author

Gauntlet seems right, this looks like a bug, but it's probably somewhere else.

@mihaibudiu mihaibudiu requested review from rst0git and removed request for rst0git August 5, 2022 23:15
@mihaibudiu mihaibudiu marked this pull request as draft August 5, 2022 23:15
@mihaibudiu mihaibudiu marked this pull request as ready for review September 6, 2022 23:37
@mihaibudiu
Copy link
Contributor Author

@fruffy indeed, Gauntlet was right. I have fixed that bug, and now this is ready for review.
There are in fact several bug fixes in this PR.
In particular, specialization of types and functions has to be iterated, because a generic function may use generic types to call other generic functions. This caused a bug in def-use analysis, which does not understand generic types, which cased the incorrect code removal that Gauntled complained about. There is now a sanity check about this.

@@ -0,0 +1 @@
/home/mbudiu/git/p4c/extensions/p4c-xdp/xdp_target.py
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There must be a way to ignore symlinks in specific folders. Let me check.

Mihai Budiu added 5 commits September 7, 2022 11:27
Signed-off-by: Mihai Budiu <mbudiu@vmware.com>
Signed-off-by: Mihai Budiu <mbudiu@vmware.com>
Signed-off-by: Mihai Budiu <mbudiu@vmware.com>
Signed-off-by: Mihai Budiu <mbudiu@vmware.com>
Signed-off-by: Mihai Budiu <mbudiu@vmware.com>
Signed-off-by: Mihai Budiu <mbudiu@vmware.com>
@mihaibudiu mihaibudiu merged commit 369b5da into p4lang:main Sep 7, 2022
@mihaibudiu mihaibudiu deleted the issue3291 branch September 7, 2022 22:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Compiler bug with struct<struct<bit>> where struct is the same struct but using a typedef
2 participants
0