This is an archive of the discontinued LLVM Phabricator instance.

[IR] Support named struct result in intrinsic remangling
AbandonedPublic

Authored by nikic on Mar 24 2022, 3:06 AM.

Details

Reviewers
aeubanks
Group Reviewers
Restricted Project
Summary

When an intrinsic is remangled, we currently try to replace with the canonical declaration. Unfortunately there is a quirk that makes intrinsic declarations in LLVM non-unique: For intrinsics with struct return type, the canonical declaration returns an unnamed struct, but LLVM also accepts named structs of equivalent structure. This "feature" is in active use by some target intrinsics.

As such, when we remangle an intrinsic we should use the original function type and just assign the new remangled name. matchIntrinsicSignature() has already checked that the function signature is valid.

This is not directly related to opaque pointers, but opaque pointer autoupgrade needs to remangle all intrinsics involving pointers, which is why we're hitting this issue now.

Diff Detail

Event Timeline

nikic created this revision.Mar 24 2022, 3:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 24 2022, 3:06 AM
nikic requested review of this revision.Mar 24 2022, 3:06 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 24 2022, 3:06 AM
aeubanks accepted this revision.Mar 24 2022, 11:15 AM
aeubanks added a subscriber: aeubanks.

we might be able to stop supporting this "feature" but it'd require some work in the bitcode reader

This revision is now accepted and ready to land.Mar 24 2022, 11:15 AM
nikic added a comment.Mar 25 2022, 3:44 AM

we might be able to stop supporting this "feature" but it'd require some work in the bitcode reader

I looked into this, and it turned out to be easier than I expected: D122471 Might make sense to go directly with that variant.

nikic abandoned this revision.Mar 30 2022, 12:51 AM

Abandoning in favor of D122471.