Skip to content

IRGen: We can't look through opaque archetypes if the underlying type contains a private type #27609

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

Conversation

aschwaighofer
Copy link
Contributor

Not without more context at least (where the substitution happens). The
private type could be from a different TU.

Yes, this can probably happen in earlier uses of opaque archetype
substitution. For now, fix the known failure.

rdar://56093964

… contains a private type

Not without more context at least (where the substitution happens). The
private type could be from a different TU.

Yes, this can probably happen in earlier uses of opaque archetype
substitution. For now, fix the known failure.

rdar://56093964
@aschwaighofer
Copy link
Contributor Author

@swift-ci Please test

type = type.subst(replacer, replacer,
SubstFlags::SubstituteOpaqueArchetypes)
->getCanonicalType();
auto underlyingTy =
Copy link
Contributor

Choose a reason for hiding this comment

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

Since you have an IRGenModule here, I think you should instead use getTypeInfo(type).isABIAccessible()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

isABIAccessible does not give the right answer for private non resilient types:

 /// Whether this type is known to be ABI-accessible, i.e. whether it's        
  /// actually possible to do ABI operations on it from this current SILModule. 
  /// See SILModule::isTypeABIAccessible.                                       
  ///                                                                           
  /// All fixed-size types are currently ABI-accessible, although this would    
  /// not be difficult to change (e.g. if we had an archetype size constraint   
  /// that didn't say anything about triviality).                               
  IsABIAccessible_t isABIAccessible() const {    

The failure occurs when we build the associated type witness. The associated type resolves to an opaque type and the underlying type contains the private type.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, good point. In that case, I think it's still worth extracting a new predicate since it might come up elsewhere.

Is 'private' access enough though? It seems if the declaration is internal, you'll run into the same problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right internal access is problematic across modules (the problematic case can happen with non-inlineable functions from non resilient modules).

I will fix the code in the ReplaceOpaqueTypesWithUnderlyingTypes utility instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

New PR: #27666

@swift-ci
Copy link
Contributor

Build failed
Swift Test Linux Platform
Git Sha - e1f11e4

@aschwaighofer
Copy link
Contributor Author

@swift-ci Please smoke test linux

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.

3 participants