This is an archive of the discontinued LLVM Phabricator instance.

Refactor AtomicExpand::expandAtomicRMWToCmpXchg into a standalone function.
ClosedPublic

Authored by DiamondLovesYou on Jul 22 2015, 11:07 AM.

Details

Summary

This is useful for PNaCl's RewriteAtomics pass. NaCl intrinsics don't exist for some of the more exotic RMW instructions, so by refactoring this function into its own, RewriteAtomics can share code rewriting those atomics with AtomicExpand while additionally saving a few cycles by generating the cmpxchg NaCl-specific intrinsic with the callback. Without this patch, RewriteAtomics would require two extra passes over functions, by first requiring use of the full AtomicExpand pass to just expand the leftover exotic RMWs and then running itself again to expand resulting cmpxchgs.

NFC

Diff Detail

Repository
rL LLVM

Event Timeline

DiamondLovesYou retitled this revision from to Refactor AtomicExpand::expandAtomicRMWToCmpXchg into a standalone function..
DiamondLovesYou updated this object.
DiamondLovesYou added a reviewer: jfb.
DiamondLovesYou set the repository for this revision to rL LLVM.
DiamondLovesYou added a subscriber: llvm-commits.
jfb edited edge metadata.Jul 23 2015, 3:23 PM

Could you edit the patch's description to explain why this change is desirable (where the function will be used)?

include/llvm/CodeGen/AtomicExpandUtils.h
19 ↗(On Diff #30369)

A function_ref seems more LLVM-ish.

22 ↗(On Diff #30369)

Could you not have a default? Right now it's defined and used only in AtomicExpandPass.cpp, so no default is needed.

28 ↗(On Diff #30369)

Why? This isn't very helpful :-)

DiamondLovesYou edited edge metadata.

Addressed JF's feedback. Also made expandAtomicRMWToCmpXchg delegate NewLoaded && Successs value to the callback function.

jfb accepted this revision.Jul 30 2015, 9:12 AM
jfb edited edge metadata.

lgtm ,leaving open if others have comments.

This revision is now accepted and ready to land.Jul 30 2015, 9:12 AM
This revision was automatically updated to reflect the committed changes.