X86: remove temporary atomicrmw used during lowering.
[oota-llvm.git] / lib / Target / X86 / X86AtomicExpandPass.cpp
index 1637b55b6d353e98946979d862a214c962a95817..61eefbbf75b19f090d5feee2c9267d295d56dc94 100644 (file)
@@ -277,8 +277,11 @@ bool X86AtomicExpandPass::expandAtomicStore(StoreInst *SI) {
                               SI->getValueOperand(), Order);
 
   // Now we have an appropriate swap instruction, lower it as usual.
-  if (shouldExpandAtomicRMW(AI))
-    return expandAtomicRMW(AI);
+  if (shouldExpandAtomicRMW(AI)) {
+    expandAtomicRMW(AI);
+    AI->eraseFromParent();
+    return true;
+  }
 
   return AI;
 }