summaryrefslogtreecommitdiffstats
path: root/lldb/scripts/Python/prepare_binding_Python.py
diff options
context:
space:
mode:
authorHans Wennborg <hans@hanshq.net>2016-12-16 16:34:59 +0000
committerHans Wennborg <hans@hanshq.net>2016-12-16 16:34:59 +0000
commit35f21cba1304f989fd755fc44992142f9cecbc65 (patch)
treee8a5be88ffc609f0dcb0e5fda31f9d66b883bf42 /lldb/scripts/Python/prepare_binding_Python.py
parente9fda9f2013b1356aa48db6897eeaee2c21da603 (diff)
downloadbcm5719-llvm-35f21cba1304f989fd755fc44992142f9cecbc65.tar.gz
bcm5719-llvm-35f21cba1304f989fd755fc44992142f9cecbc65.zip
[X86] Fold (setcc (cmp (atomic_load_add x, -C) C), COND) to (setcc (LADD x, -C), COND) (PR31367)
atomic_load_add returns the value before addition, but sets EFLAGS based on the result of the addition. That means it's setting the flags based on effectively subtracting C from the value at x, which is also what the outer cmp does. This targets a pattern that occurs frequently with reference counting pointers: void decrement(long volatile *ptr) { if (_InterlockedDecrement(ptr) == 0) release(); } Clang would previously compile it (for 32-bit at -Os) as: 00000000 <?decrement@@YAXPCJ@Z>: 0: 8b 44 24 04 mov 0x4(%esp),%eax 4: 31 c9 xor %ecx,%ecx 6: 49 dec %ecx 7: f0 0f c1 08 lock xadd %ecx,(%eax) b: 83 f9 01 cmp $0x1,%ecx e: 0f 84 00 00 00 00 je 14 <?decrement@@YAXPCJ@Z+0x14> 14: c3 ret and with this patch it becomes: 00000000 <?decrement@@YAXPCJ@Z>: 0: 8b 44 24 04 mov 0x4(%esp),%eax 4: f0 ff 08 lock decl (%eax) 7: 0f 84 00 00 00 00 je d <?decrement@@YAXPCJ@Z+0xd> d: c3 ret (Equivalent variants with _InterlockedExchangeAdd, std::atomic<>'s fetch_add or pre-decrement operator generate the same code.) Differential Revision: https://reviews.llvm.org/D27781 llvm-svn: 289955
Diffstat (limited to 'lldb/scripts/Python/prepare_binding_Python.py')
0 files changed, 0 insertions, 0 deletions
OpenPOWER on IntegriCloud