-
Notifications
You must be signed in to change notification settings - Fork 449
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
Disable the expansion of header unions in the copy structures pass. #5093
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,13 +73,14 @@ const IR::Node *DoCopyStructures::postorder(IR::AssignmentStatement *statement) | |
FIXME: this is not correct for header unions and should be fixed. | ||
The fix bellow, commented-out, causes problems elsewhere. | ||
https://github.com/p4lang/p4c/issues/3842 | ||
if (ltype->is<IR::Type_HeaderUnion>()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure, but it appears that these changes are attempting to fix the issue #3842 mentioned in comments just before this line, and thus those comments can be removed? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well, the current fix just disables union expansion by default to avoid running into #3842. Ideally, we fix the problem in the copyStructures pass somehow by tracking validity. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, this PR is not fixing that issue, if I understand the changes correctly. You are just disabling incorrect transformations. |
||
return statement; | ||
*/ | ||
if (!config.expandUnions && ltype->is<IR::Type_HeaderUnion>()) { | ||
return statement; | ||
} | ||
|
||
// Do not copy structures for method calls. | ||
if (statement->right->is<IR::MethodCallExpression>()) { | ||
if (errorOnMethodCall) { | ||
if (config.errorOnMethodCall) { | ||
::P4::error(ErrorType::ERR_UNSUPPORTED_ON_TARGET, | ||
"%1%: functions or methods returning structures " | ||
"are not supported on this target", | ||
|
@@ -98,7 +99,7 @@ const IR::Node *DoCopyStructures::postorder(IR::AssignmentStatement *statement) | |
retval.push_back( | ||
new IR::AssignmentStatement(statement->srcInfo, left, right->expression)); | ||
} | ||
} else if (copyHeaders && ltype->is<IR::Type_Header>()) { | ||
} else if (config.copyHeaders && ltype->is<IR::Type_Header>()) { | ||
const auto *header = ltype->checkedTo<IR::Type_Header>(); | ||
// Build a "src.isValid()" call. | ||
const auto *isSrcValidCall = new IR::MethodCallExpression( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems unrelated. Also, it would be better to print the space only after the
if (!isDeclaration)
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is intentional. Fixes a bug introduced by #5036. If you do not change this line you will produce incorrect reference files. I am actually a little concerned why this is not picked up in checks.