This is an archive of the discontinued LLVM Phabricator instance.

llvm.swift.async.context.addr cannot be modeled as NoMem because we don't want it to be cse'd accross async suspends
ClosedPublic

Authored by aschwaighofer on Jul 20 2022, 2:01 PM.

Details

Summary

An async suspend models the split between two partial async functions.
llvm.swift.async.context.addr will have a different value in the two
partial functions so it is not correct to generally CSE the instruction.

rdar://97336162

Diff Detail

Event Timeline

aschwaighofer created this revision.Jul 20 2022, 2:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2022, 2:01 PM
aschwaighofer requested review of this revision.Jul 20 2022, 2:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 20 2022, 2:01 PM
aschwaighofer added inline comments.Jul 22 2022, 8:13 AM
llvm/include/llvm/IR/Intrinsics.td
498

Hmm. We could be a little less conservative and mark the intrinsic as IntrReadMem. The suspend intrinsic does write to memory so the required ordering would be maintained.

In practice, I don't think it matters much because the way we use this intrinsic is to store to its result:

%addr = call i8** @llvm.swift.async.context.addr()
store i8* %something, i8** %addr
t.p.northover accepted this revision.Jul 22 2022, 9:51 AM

Looks reasonable to me.

This revision is now accepted and ready to land.Jul 22 2022, 9:51 AM
This revision was landed with ongoing or failed builds.Jul 22 2022, 11:51 AM
This revision was automatically updated to reflect the committed changes.