This is an archive of the discontinued LLVM Phabricator instance.

Transforms: Fix code duplication between LowerAtomic and AtomicExpand
ClosedPublic

Authored by arsenm on Apr 5 2022, 5:36 PM.

Diff Detail

Event Timeline

arsenm created this revision.Apr 5 2022, 5:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2022, 5:36 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
arsenm requested review of this revision.Apr 5 2022, 5:36 PM
Herald added a project: Restricted Project. · View Herald TranscriptApr 5 2022, 5:36 PM
Herald added a subscriber: wdng. · View Herald Transcript
reames added a comment.Apr 6 2022, 4:12 PM

After you've added the NotAtomic option to AtomicExpand, does LowerAtomic serve any purpose at all? The one in tree use I can find (in ARM) could be handled via the shouldExpandX callbacks without issue (I think). If possible, I'd rather switch that one backend over and then just delete the code.

Unless we think the ability to strip out atomics is useful for debugging or something?

arsenm added a comment.Apr 6 2022, 5:31 PM

After you've added the NotAtomic option to AtomicExpand, does LowerAtomic serve any purpose at all? The one in tree use I can find (in ARM) could be handled via the shouldExpandX callbacks without issue (I think). If possible, I'd rather switch that one backend over and then just delete the code.

NVPTX has another conditionalized version of the pass which could be moved to AtomicExpand. WebAssembly also has a use where they use the pass itself inside another pass. The main annoyance is the clumsy API where each instruction gets its own callback

Unless we think the ability to strip out atomics is useful for debugging or something?

I was thinking it's not useful unless used as a utility, but not sure if there's a real point to that.

reames accepted this revision.Apr 7 2022, 6:46 PM

Good point on your response.

LGTM to this patch as a stepping stone.

I really do think it makes sense to cleanup the aarch64 usage given the new capability. Would you mind doing that? Not urgent, but it'd be good not to forget.

The others really seem like we need a function which lowers an inst to it's non-atomic form, and call it rather than invoking the pass as a helper. Feel free to pursue that or not, we're at the point of diminishing returns here.

This revision is now accepted and ready to land.Apr 7 2022, 6:46 PM
arsenm closed this revision.Jul 7 2023, 6:03 AM

Pushed a long time ago as 9fdd25848a79892eaacc5414d5aef18555b79919 and I never got to the further cleanups