You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Compiler Bug: t.p4(8): visitor returned non-MethodCallExpression type: 8
h.minSizeInBits();
^^^^^^^^^^^^^^^^^
The text was updated successfully, but these errors were encountered:
kfcripps
added
bug
This behavior is unintended and should be fixed.
core
Topics concerning the core segments of the compiler (frontend, midend, parser)
labels
Apr 17, 2024
Seems like the TypeInference pass may transform an IR::MethodCallStatement's methodCall to an IR::Constant, but a methodCall must be an IR::MethodCallExpression.
// Constant-fold constant expressions
if (auto mem = expression->method->to<IR::Member>()) {
auto type = typeMap->getType(mem->expr, true);
if (((mem->member == IR::Type::minSizeInBits ||
mem->member == IR::Type::minSizeInBytes ||
mem->member == IR::Type::maxSizeInBits ||
mem->member == IR::Type::maxSizeInBytes)) &&
!type->is<IR::Type_Extern>() && expression->typeArguments->size() == 0 &&
expression->arguments->size() == 0) {
auto max = mem->member.name.startsWith("max");
int w = typeMap->widthBits(type, expression, max);
LOG3("Folding " << mem << " to " << w);
if (w < 0) return expression;
if (mem->member.name.endsWith("Bytes")) w = ROUNDUP(w, 8);
auto result = new IR::Constant(expression->srcInfo, w);
auto tt = new IR::Type_Type(result->type);
setType(result->type, tt);
setType(result, result->type);
setCompileTimeConstant(result);
return result;
}
…resolves to a compile-time constant. (#4627)
* Prune MethodCallStatements if child MethodCallExpression resolves to a compile-time constant.
* Apply clang formatting
* code cleanup
The following P4 program:
crashes with:
The text was updated successfully, but these errors were encountered: