This is an archive of the discontinued LLVM Phabricator instance.

Use target-dependent emitLeading/TrailingFence instead of the target-independent insertLeading/TrailingFence (in AtomicExpandPass)
AbandonedPublic

Authored by morisset on Aug 18 2014, 3:10 PM.

Details

Reviewers
grosbach
jfb
Summary

Fixes two latent bugs:

  • There was no fence inserted before expanded seq_cst load (unsound on Power)
  • There was only a fence release before seq_cst stores (again unsound, in particular on Power) It is not even clear if this is correct on ARM swift processors (where release fences are DMB ishst instead of DMB ish)

These two bugs were not triggered because Power is not (yet) using this pass, and these
behaviours happen to be (mostly?) working on ARM
(although they completely butchered the semantics of the llvm IR).
See:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2014-August/075821.html
for an example of the problems that can be caused by the second of these bugs.

I couldn't see a way of fixing these in a completely target-independent way without
adding lots of unnecessary fences on ARM, hence the target-dependent parts of this
patch.
Depends on D4958, D4959, D4960.

Diff Detail

Event Timeline

morisset updated this revision to Diff 12631.Aug 18 2014, 3:10 PM
morisset retitled this revision from to Use target-dependent emitLeading/TrailingFence instead of the target-independent insertLeading/TrailingFence (in AtomicExpandPass).
morisset updated this object.
morisset edited the test plan for this revision. (Show Details)
morisset added a reviewer: jfb.
morisset added subscribers: t.p.northover, Unknown Object (MLST).
jfb edited edge metadata.Aug 20 2014, 10:11 PM

I'd very much like @t.p.northover's input, especially on the swift parts.

lib/CodeGen/AtomicExpandPass.cpp
109

Are there public references for this? Also, which versions of ARM and POWER?

110

Constant-fold TM->getSubtargetImpl()->getTargetLowering()-> in this function (same for other functions below).

test/Transforms/AtomicExpand/ARM/lit.local.cfg
3 ↗(On Diff #12631)

Undo this change.

morisset updated this revision to Diff 12861.Aug 22 2014, 3:48 PM
morisset edited edge metadata.

Fix the problems pointed by the inline comments of jfb.

morisset updated this revision to Diff 12862.Aug 22 2014, 3:50 PM

Send the right patch this time.

jfb added a comment.Aug 22 2014, 3:59 PM

lgtm, but as we discussed offline we'll either need input on swift, or make sure that the swift behavior stays the same if we don't get any input.

morisset abandoned this revision.Aug 22 2014, 5:32 PM

Merged into D4960 based on the suggestion of rengolin, so that D4960 is testable.

rengolin added a subscriber: rengolin.

Bastien, Tim is on holidays, Jim might know the Swift answers you seek. Added him as a reviewer.

cheers,
--renato