[llvm] r267778 - [ARM] Set correct successors in CMPXCHG pseudo expansion.

Ahmed Bougacha via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 27 13:32:54 PDT 2016


Author: ab
Date: Wed Apr 27 15:32:54 2016
New Revision: 267778

URL: http://llvm.org/viewvc/llvm-project?rev=267778&view=rev
Log:
[ARM] Set correct successors in CMPXCHG pseudo expansion.

transferSuccessors() would LoadCmpBB a successor of DoneBB, whereas
it should be a successor of the original MBB.

The testcase changes are caused by Thumb2SizeReduction, which
was previously confused by the broken CFG.

Follow-up to r266679.

Unfortunately, it's tricky to catch this in the verifier.

Modified:
    llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp
    llvm/trunk/test/CodeGen/ARM/cmpxchg-O0.ll

Modified: llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp?rev=267778&r1=267777&r2=267778&view=diff
==============================================================================
--- llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp (original)
+++ llvm/trunk/lib/Target/ARM/ARMExpandPseudoInsts.cpp Wed Apr 27 15:32:54 2016
@@ -801,7 +801,6 @@ bool ARMExpandPseudo::ExpandCMP_SWAP(Mac
   //     ldrex rDest, [rAddr]
   //     cmp rDest, rDesired
   //     bne .Ldone
-  MBB.addSuccessor(LoadCmpBB);
   LoadCmpBB->addLiveIn(Addr.getReg());
   LoadCmpBB->addLiveIn(Dest.getReg());
   LoadCmpBB->addLiveIn(Desired.getReg());
@@ -857,6 +856,8 @@ bool ARMExpandPseudo::ExpandCMP_SWAP(Mac
   DoneBB->transferSuccessors(&MBB);
   addPostLoopLiveIns(DoneBB, LiveRegs);
 
+  MBB.addSuccessor(LoadCmpBB);
+
   NextMBBI = MBB.end();
   MI.eraseFromParent();
   return true;
@@ -914,7 +915,6 @@ bool ARMExpandPseudo::ExpandCMP_SWAP_64(
   //     cmp rDestLo, rDesiredLo
   //     sbcs rStatus<dead>, rDestHi, rDesiredHi
   //     bne .Ldone
-  MBB.addSuccessor(LoadCmpBB);
   LoadCmpBB->addLiveIn(Addr.getReg());
   LoadCmpBB->addLiveIn(Dest.getReg());
   LoadCmpBB->addLiveIn(Desired.getReg());
@@ -977,6 +977,8 @@ bool ARMExpandPseudo::ExpandCMP_SWAP_64(
   DoneBB->transferSuccessors(&MBB);
   addPostLoopLiveIns(DoneBB, LiveRegs);
 
+  MBB.addSuccessor(LoadCmpBB);
+
   NextMBBI = MBB.end();
   MI.eraseFromParent();
   return true;

Modified: llvm/trunk/test/CodeGen/ARM/cmpxchg-O0.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/ARM/cmpxchg-O0.ll?rev=267778&r1=267777&r2=267778&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/ARM/cmpxchg-O0.ll (original)
+++ llvm/trunk/test/CodeGen/ARM/cmpxchg-O0.ll Wed Apr 27 15:32:54 2016
@@ -18,7 +18,7 @@ define { i8, i1 } @test_cmpxchg_8(i8* %a
 ; CHECK:     bne [[RETRY]]
 ; CHECK: [[DONE]]:
 ; CHECK:     cmp{{(\.w)?}} [[OLD]], [[DESIRED]]
-; CHECK:     {{moveq.w|movweq}} {{r[0-9]+}}, #1
+; CHECK:     {{moveq|movweq}} {{r[0-9]+}}, #1
 ; CHECK:     dmb ish
   %res = cmpxchg i8* %addr, i8 %desired, i8 %new seq_cst monotonic
   ret { i8, i1 } %res
@@ -37,7 +37,7 @@ define { i16, i1 } @test_cmpxchg_16(i16*
 ; CHECK:     bne [[RETRY]]
 ; CHECK: [[DONE]]:
 ; CHECK:     cmp{{(\.w)?}} [[OLD]], [[DESIRED]]
-; CHECK:     {{moveq.w|movweq}} {{r[0-9]+}}, #1
+; CHECK:     {{moveq|movweq}} {{r[0-9]+}}, #1
 ; CHECK:     dmb ish
   %res = cmpxchg i16* %addr, i16 %desired, i16 %new seq_cst monotonic
   ret { i16, i1 } %res
@@ -56,7 +56,7 @@ define { i32, i1 } @test_cmpxchg_32(i32*
 ; CHECK:     bne [[RETRY]]
 ; CHECK: [[DONE]]:
 ; CHECK:     cmp{{(\.w)?}} [[OLD]], [[DESIRED]]
-; CHECK:     {{moveq.w|movweq}} {{r[0-9]+}}, #1
+; CHECK:     {{moveq|movweq}} {{r[0-9]+}}, #1
 ; CHECK:     dmb ish
   %res = cmpxchg i32* %addr, i32 %desired, i32 %new seq_cst monotonic
   ret { i32, i1 } %res




More information about the llvm-commits mailing list