Hi, Testcase: > int main(void) > { > volatile int obj = 1; > int x = obj; > > __atomic_compare_exchange_n(&obj, &x, 0, 1, __ATOMIC_RELAXED, __ATOMIC_RELAXED); > } Compiling with: clang-4.0 -O0 test.c -otes Running "test" hangs on Cavium Octeon machines. The bug does not occur if -O1 is used. The generated assembly contains this loop: > .LBB0_1: > ld $1, 16($fp) > ll $2, 0($1) > lw $3, 32($fp) > sw $2, 12($fp) > bne $2, $3, .LBB0_3 > nop > lw $1, 28($fp) > ld $2, 16($fp) > sc $1, 0($2) > beqz $1, .LBB0_1 > nop However the Octeon processor manual states that _any_ store will cause a subsequent sc instruction to fail and therefore this above loop will never complete on Octeon. Thanks, James
Looking into this.
This is a occurrence of PR/25526 but for MIPS. I'm currently trialling a fix.
Should be resolved by r296134.
Thanks! I've tested the fix and it works now. Is it possible for this to be fixed in either 4.0 or 4.0.1 as well?
I've requested it be merged today for 4.0. If not, I'll try and get it in for the next point release of 4.0.
The fix posted has problems, reopening this while I work up another solution.
Has there been any progress on this bug?
I have a fix, but I want to perform more testing before recommitting it. My last attempt fudged handed allocated register, resulting in segfaults everywhere.
(In reply to Simon Dardis from comment #9) > I have a fix, but I want to perform more testing before recommitting it. My > last attempt fudged handed allocated register, resulting in segfaults > everywhere. SimonD, do you have the fix (maybe incomplete) mentioned in your comment? Could you please share it?
I had a look at this bug and it was resolved in r336328. I recommend closing it.
Fixed at https://reviews.llvm.org/rL336328.