Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(424)

Issue 927493002: PNaCl: Impl the other atomicrmw operations: nand, max, min, umax, and umin.

Created:
5 years, 10 months ago by Richard Diamond
Modified:
5 years, 4 months ago
Reviewers:
JF
CC:
native-client-reviews_googlegroups.com
Base URL:
https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Target Ref:
refs/heads/master
Visibility:
Public.

Description

PNaCl: Impl the other atomicrmw operations: nand, max, min, umax, and umin. Originally, only Nand was implemented, as that seems to be the only extra operation used in practice by Rust. However, rewriting the rest in addition was easy, so I've included those as well. R= jfb@chromium.org TEST= (cd toolchain_build/out/llvm_x86_64_linux_work && make check) BUG=

Patch Set 1 #

Total comments: 2

Patch Set 2 : #

Total comments: 8

Patch Set 3 : #

Patch Set 4 : Rebase #

Total comments: 2

Patch Set 5 : Reduce big-O cost. #

Total comments: 1

Patch Set 6 : #

Patch Set 7 : #

Total comments: 12

Patch Set 8 : #

Total comments: 8

Patch Set 9 : #

Patch Set 10 : #

Patch Set 11 : #

Total comments: 2

Patch Set 12 : #

Patch Set 13 : #

Patch Set 14 : #

Total comments: 7

Patch Set 15 : #

Patch Set 16 : #

Unified diffs Side-by-side diffs Delta from patch set Stats (+415 lines, -49 lines) Patch
A include/llvm/Analysis/NaCl/PNaClSimplificationAnalyses.h View 1 2 3 4 5 6 7 8 9 10 1 chunk +102 lines, -0 lines 0 comments Download
M include/llvm/InitializePasses.h View 1 2 3 4 5 6 1 chunk +4 lines, -0 lines 0 comments Download
M include/llvm/Transforms/NaCl.h View 1 2 3 4 5 6 7 4 chunks +3 lines, -1 line 0 comments Download
M lib/Analysis/NaCl/CMakeLists.txt View 1 2 3 4 5 6 7 1 chunk +1 line, -0 lines 0 comments Download
A lib/Analysis/NaCl/PNaClSimplificationAnalyses.cpp View 1 2 3 4 5 6 7 8 9 10 1 chunk +56 lines, -0 lines 0 comments Download
M lib/Transforms/NaCl/CMakeLists.txt View 1 2 3 4 5 6 1 chunk +1 line, -1 line 0 comments Download
M lib/Transforms/NaCl/LLVMBuild.txt View 1 2 3 4 5 6 1 chunk +1 line, -1 line 0 comments Download
M lib/Transforms/NaCl/RewriteAtomics.cpp View 1 2 3 4 5 6 7 8 9 10 11 15 chunks +169 lines, -46 lines 0 comments Download
A test/Transforms/NaCl/atomic/extra-rmw-operations.ll View 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 1 chunk +78 lines, -0 lines 0 comments Download

Messages

Total messages: 34 (0 generated)
Richard Diamond
5 years, 10 months ago (2015-02-13 08:54:05 UTC) #1
JF
https://codereview.chromium.org/927493002/diff/1/lib/Transforms/NaCl/RewriteAtomics.cpp File lib/Transforms/NaCl/RewriteAtomics.cpp (right): https://codereview.chromium.org/927493002/diff/1/lib/Transforms/NaCl/RewriteAtomics.cpp#newcode132 lib/Transforms/NaCl/RewriteAtomics.cpp:132: Instruction::CastOps castOp(Instruction &I, Value *Src, Type *Dst, Twine Name) ...
5 years, 10 months ago (2015-02-13 17:14:26 UTC) #2
Richard Diamond
On 2015/02/13 17:14:26, JF wrote: > https://codereview.chromium.org/927493002/diff/1/lib/Transforms/NaCl/RewriteAtomics.cpp > File lib/Transforms/NaCl/RewriteAtomics.cpp (right): > > https://codereview.chromium.org/927493002/diff/1/lib/Transforms/NaCl/RewriteAtomics.cpp#newcode132 > ...
5 years, 10 months ago (2015-02-16 20:13:08 UTC) #3
JF
> Actually, such generalization has already been completed and is present in the > `merge_36` ...
5 years, 10 months ago (2015-02-16 21:09:01 UTC) #4
Richard Diamond
https://codereview.chromium.org/927493002/diff/20001/lib/Transforms/NaCl/RewriteAtomics.cpp File lib/Transforms/NaCl/RewriteAtomics.cpp (right): https://codereview.chromium.org/927493002/diff/20001/lib/Transforms/NaCl/RewriteAtomics.cpp#newcode179 lib/Transforms/NaCl/RewriteAtomics.cpp:179: Triple TheTriple = Triple("i686-none-nacl"); On 2015/02/16 21:09:01, JF wrote: ...
5 years, 10 months ago (2015-02-16 23:36:31 UTC) #5
JF
I think this approach is OK as a temporary fix, but I think medium term ...
5 years, 10 months ago (2015-02-17 17:30:16 UTC) #6
Richard Diamond
On 2015/02/17 17:30:16, JF wrote: > I think this approach is OK as a temporary ...
5 years, 10 months ago (2015-02-17 21:58:39 UTC) #7
JF
> Happy to help, I'll submit a patch for (1) to llvm-commits soonish. Great! Please ...
5 years, 10 months ago (2015-02-17 22:02:52 UTC) #8
Richard Diamond
On 2015/02/17 22:02:52, JF wrote: > On 2015/02/17 17:30:16, JF wrote: > > I think ...
5 years, 10 months ago (2015-02-17 23:01:30 UTC) #9
Richard Diamond
On 2015/02/17 22:02:52, JF wrote: > > Happy to help, I'll submit a patch for ...
5 years, 10 months ago (2015-02-17 23:02:25 UTC) #10
Richard Diamond
On 2015/02/17 23:02:25, Richard Diamond wrote: > On 2015/02/17 22:02:52, JF wrote: > > > ...
5 years, 10 months ago (2015-02-17 23:04:01 UTC) #11
JF
> Now that I've read the surrounding code (to shouldExpandAtomicRMWInIR), nvm the > bitfield thing. ...
5 years, 10 months ago (2015-02-18 00:36:39 UTC) #12
Richard Diamond
Now that `pnacl-llvm` is more up-to-date w.r.t. upstream, this can be reviewed and committed.
5 years, 5 months ago (2015-07-09 22:36:01 UTC) #13
JF
https://codereview.chromium.org/927493002/diff/60001/lib/Transforms/NaCl/RewriteAtomics.cpp File lib/Transforms/NaCl/RewriteAtomics.cpp (right): https://codereview.chromium.org/927493002/diff/60001/lib/Transforms/NaCl/RewriteAtomics.cpp#newcode188 lib/Transforms/NaCl/RewriteAtomics.cpp:188: (createAtomicExpandPass(Target.get())); Could the pass instead go in lib/Transforms/NaCl/PNaClABISimplify.cpp, just ...
5 years, 5 months ago (2015-07-10 18:07:32 UTC) #14
Richard Diamond
https://codereview.chromium.org/927493002/diff/60001/lib/Transforms/NaCl/RewriteAtomics.cpp File lib/Transforms/NaCl/RewriteAtomics.cpp (right): https://codereview.chromium.org/927493002/diff/60001/lib/Transforms/NaCl/RewriteAtomics.cpp#newcode188 lib/Transforms/NaCl/RewriteAtomics.cpp:188: (createAtomicExpandPass(Target.get())); On 2015/07/10 at 18:07:32, JF wrote: > Could ...
5 years, 5 months ago (2015-07-10 21:08:17 UTC) #15
JF
On 2015/07/10 21:08:17, Richard Diamond wrote: > https://codereview.chromium.org/927493002/diff/60001/lib/Transforms/NaCl/RewriteAtomics.cpp > File lib/Transforms/NaCl/RewriteAtomics.cpp (right): > > https://codereview.chromium.org/927493002/diff/60001/lib/Transforms/NaCl/RewriteAtomics.cpp#newcode188 ...
5 years, 5 months ago (2015-07-10 21:46:53 UTC) #16
Richard Diamond
On 2015/07/10 at 21:46:53, jfb wrote: > On 2015/07/10 21:08:17, Richard Diamond wrote: > > ...
5 years, 5 months ago (2015-07-13 18:12:15 UTC) #17
Richard Diamond
JF, I've added the analysis pass we've discussed.
5 years, 5 months ago (2015-07-22 22:38:03 UTC) #18
JF
https://codereview.chromium.org/927493002/diff/80001/lib/Transforms/NaCl/RewriteAtomics.cpp File lib/Transforms/NaCl/RewriteAtomics.cpp (right): https://codereview.chromium.org/927493002/diff/80001/lib/Transforms/NaCl/RewriteAtomics.cpp#newcode93 lib/Transforms/NaCl/RewriteAtomics.cpp:93: /// the expection rather than the rule). "exception" https://codereview.chromium.org/927493002/diff/120001/include/llvm/Analysis/NaCl/SimplificationAnalyses.h ...
5 years, 5 months ago (2015-07-23 22:44:39 UTC) #19
Richard Diamond
https://codereview.chromium.org/927493002/diff/120001/include/llvm/Analysis/NaCl/SimplificationAnalyses.h File include/llvm/Analysis/NaCl/SimplificationAnalyses.h (right): https://codereview.chromium.org/927493002/diff/120001/include/llvm/Analysis/NaCl/SimplificationAnalyses.h#newcode36 include/llvm/Analysis/NaCl/SimplificationAnalyses.h:36: const SmallVectorImpl<FenceInst *> &getFences() const { return Fences; } ...
5 years, 5 months ago (2015-07-24 19:54:39 UTC) #20
JF
https://codereview.chromium.org/927493002/diff/140001/include/llvm/Analysis/NaCl/PNaClSimplificationAnalyses.h File include/llvm/Analysis/NaCl/PNaClSimplificationAnalyses.h (right): https://codereview.chromium.org/927493002/diff/140001/include/llvm/Analysis/NaCl/PNaClSimplificationAnalyses.h#newcode86 include/llvm/Analysis/NaCl/PNaClSimplificationAnalyses.h:86: AtomicAnalysis &operator=(AtomicAnalysis &&) { return *this; } Do you ...
5 years, 4 months ago (2015-07-27 19:49:28 UTC) #21
Richard Diamond
https://codereview.chromium.org/927493002/diff/140001/include/llvm/Analysis/NaCl/PNaClSimplificationAnalyses.h File include/llvm/Analysis/NaCl/PNaClSimplificationAnalyses.h (right): https://codereview.chromium.org/927493002/diff/140001/include/llvm/Analysis/NaCl/PNaClSimplificationAnalyses.h#newcode86 include/llvm/Analysis/NaCl/PNaClSimplificationAnalyses.h:86: AtomicAnalysis &operator=(AtomicAnalysis &&) { return *this; } On 2015/07/27 ...
5 years, 4 months ago (2015-07-30 11:47:08 UTC) #22
Richard Diamond
https://codereview.chromium.org/927493002/diff/140001/lib/Transforms/NaCl/RewriteAtomics.cpp File lib/Transforms/NaCl/RewriteAtomics.cpp (right): https://codereview.chromium.org/927493002/diff/140001/lib/Transforms/NaCl/RewriteAtomics.cpp#newcode65 lib/Transforms/NaCl/RewriteAtomics.cpp:65: // For rewritting nand, (u)max, (u)min rmw atomics: On ...
5 years, 4 months ago (2015-07-30 11:48:08 UTC) #23
Richard Diamond
Updated for the AtomicExpand refactor.
5 years, 4 months ago (2015-08-03 20:16:46 UTC) #24
JF
https://codereview.chromium.org/927493002/diff/200001/lib/Transforms/NaCl/RewriteAtomics.cpp File lib/Transforms/NaCl/RewriteAtomics.cpp (right): https://codereview.chromium.org/927493002/diff/200001/lib/Transforms/NaCl/RewriteAtomics.cpp#newcode407 lib/Transforms/NaCl/RewriteAtomics.cpp:407: auto Factory = [&] (IRBuilder<> &Builder, Value *Addr, I'd ...
5 years, 4 months ago (2015-08-04 17:10:30 UTC) #25
Richard Diamond
Done.
5 years, 4 months ago (2015-08-04 19:03:38 UTC) #26
Richard Diamond
Wait, check doesn't pass.
5 years, 4 months ago (2015-08-04 19:08:56 UTC) #27
Richard Diamond
On 2015/08/04 at 19:08:56, Richard Diamond wrote: > Wait, check doesn't pass. Fixed.
5 years, 4 months ago (2015-08-04 19:13:40 UTC) #28
JF
https://codereview.chromium.org/927493002/diff/260001/include/llvm/CodeGen/AtomicExpandUtils.h File include/llvm/CodeGen/AtomicExpandUtils.h (right): https://codereview.chromium.org/927493002/diff/260001/include/llvm/CodeGen/AtomicExpandUtils.h#newcode1 include/llvm/CodeGen/AtomicExpandUtils.h:1: //===-- AtomicExpandUtils.h - Utilities for expanding atomic instructions -===// ...
5 years, 4 months ago (2015-08-05 16:25:22 UTC) #29
Richard Diamond
https://codereview.chromium.org/927493002/diff/260001/lib/Transforms/NaCl/RewriteAtomics.cpp File lib/Transforms/NaCl/RewriteAtomics.cpp (right): https://codereview.chromium.org/927493002/diff/260001/lib/Transforms/NaCl/RewriteAtomics.cpp#newcode98 lib/Transforms/NaCl/RewriteAtomics.cpp:98: freezeMemoryOrder(const Instruction &I, AtomicOrdering S, On 2015/08/05 at 16:25:21, ...
5 years, 4 months ago (2015-08-05 16:35:44 UTC) #30
Richard Diamond
> https://codereview.chromium.org/927493002/diff/260001/test/Transforms/NaCl/atomic/extra-rmw-operations.ll#newcode14 > test/Transforms/NaCl/atomic/extra-rmw-operations.ll:14: ; CHECK-NEXT: %1 = load i8, i8* %ptr, align 8 > ...
5 years, 4 months ago (2015-08-22 06:51:42 UTC) #31
JF
On 2015/08/22 06:51:42, Richard Diamond wrote: > > > https://codereview.chromium.org/927493002/diff/260001/test/Transforms/NaCl/atomic/extra-rmw-operations.ll#newcode14 > > test/Transforms/NaCl/atomic/extra-rmw-operations.ll:14: ; CHECK-NEXT: ...
5 years, 4 months ago (2015-08-25 19:37:46 UTC) #32
Richard Diamond
On 2015/08/25 at 19:37:46, jfb wrote: > On 2015/08/22 06:51:42, Richard Diamond wrote: > > ...
5 years, 4 months ago (2015-08-25 21:14:08 UTC) #33
JF
5 years, 4 months ago (2015-08-25 21:17:43 UTC) #34
> > It does need to be atomic: on weak memory systems the CPU can speculate on
> subsequent loads (e.g. the cmpxchg) and observe them without honoring the
> happens-before ordering of the corresponding stores. This is the "load
> buffering" problem in literature, and occurs on ARM and POWER.
> 
> Hm. Which is a problem if the cmpxchg's are subsequently expanded during
bitcode
> translation.
> 
> But don't both ARM && PPC expand the resulting cmpxchg's into linked loads &&
> conditional stores with memory fences?

What ARM and PPC do isn't known by LLVM at this point in time (or rather, the IR
transform doesn't ask the target if a non-atomic load was OK here, it just
assumes it is!). This break LLVM's memory model without an explicit opt-in from
the target: other optimizations could occur in between this and further
lowering.

Powered by Google App Engine
This is Rietveld 408576698