Skip to content
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

fuir: fix instability in clazz._id #4648

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions src/dev/flang/fuir/Clazz.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ enum LayoutStatus
/**
* Integer id of this Clazz used in FUIR instance.
*/
final int _id;
int _id = -1;


/**
Expand Down Expand Up @@ -282,14 +282,11 @@ enum LayoutStatus
*
* @param select in case actualType refers to a field whose result type is an
* open generic parameter, select specifies the actual generic to be used.
*
* @param id the inter id used by FUIR to identify this Clazz.
*/
Clazz(GeneratingFUIR fuir,
Clazz outer,
AbstractType type,
int select,
int id)
int select)
{
if (PRECONDITIONS) require
(!type.dependsOnGenerics() || true /* NYI: UNDER DEVELOPMENT: Why? */,
Expand All @@ -307,7 +304,6 @@ enum LayoutStatus

_outer = outer;
_select = select;
_id = id;
_needsCode = false;
_code = IR.NO_SITE;
}
Expand All @@ -318,8 +314,9 @@ enum LayoutStatus
* Additional initialization code that has to be run after this Clazz was
* added to FUIRI._clazzes for recursive clazz lookup.
*/
void init()
void init(int id)
{
_id = id;
_choiceGenerics = determineChoiceGenerics();
var vas = feature().valueArguments();
if (vas.size() == 0 || isBoxed())
Expand Down
11 changes: 8 additions & 3 deletions src/dev/flang/fuir/GeneratingFUIR.java
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ Clazz newClazz(Clazz outerR, AbstractType actualType, int select)
// normalize outer to be value in case t describes a field
outerR = t.feature().isField() ? outerR.asValue() : outerR;

var cl = new Clazz(this, outerR, t, select, CLAZZ_BASE + _clazzes.size());
var cl = new Clazz(this, outerR, t, select);
var existing = _clazzesTM.get(cl);
if (existing != null)
{
Expand All @@ -341,7 +341,12 @@ Clazz newClazz(Clazz outerR, AbstractType actualType, int select)
else
{
result = cl;
var fuirId = CLAZZ_BASE + _clazzes.size();
_clazzes.add(cl);

if (CHECKS) check
(_clazzes.get(clazzId2num(fuirId)) == cl);

if (_lookupDone)
{
if (false) // NYI: BUG: #4273: This still happens for some tests and
Expand Down Expand Up @@ -407,11 +412,11 @@ Clazz newClazz(Clazz outerR, AbstractType actualType, int select)
}
cl._specialClazzId = s;
if (SHOW_NEW_CLAZZES) System.out.println("NEW CLAZZ "+cl);
cl.init();
cl.init(fuirId);

result.registerAsHeir();

// C backend requires the value variant for all ref clazzes, so we make
// backends require the value variant for all ref clazzes, so we make
// sure we have the value clazz as well:
var ignore = clazzAsValue(result._id);
}
Expand Down
Loading