From: Tim Northover Date: Thu, 13 Mar 2014 19:25:52 +0000 (+0000) Subject: CodeGen: use symbolic enumerators for memory order X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=cb8e945458e1a594d66b63b2de45a85e6ebbafa3;p=clang CodeGen: use symbolic enumerators for memory order It makes the code clearer and less error-prone to use our (already known) special values for the various memory order cases. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203838 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGAtomic.cpp b/lib/CodeGen/CGAtomic.cpp index 68437866e4..3e996f377a 100644 --- a/lib/CodeGen/CGAtomic.cpp +++ b/lib/CodeGen/CGAtomic.cpp @@ -785,28 +785,33 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E, llvm::Value *Dest) { EmitAtomicOp(*this, E, Dest, Ptr, Val1, Val2, OrderFail, Size, Align, llvm::Acquire); Builder.CreateBr(ContBB); - SI->addCase(Builder.getInt32(1), AcquireBB); - SI->addCase(Builder.getInt32(2), AcquireBB); + SI->addCase(Builder.getInt32(AtomicExpr::AO_ABI_memory_order_consume), + AcquireBB); + SI->addCase(Builder.getInt32(AtomicExpr::AO_ABI_memory_order_acquire), + AcquireBB); } if (!IsLoad) { Builder.SetInsertPoint(ReleaseBB); EmitAtomicOp(*this, E, Dest, Ptr, Val1, Val2, OrderFail, Size, Align, llvm::Release); Builder.CreateBr(ContBB); - SI->addCase(Builder.getInt32(3), ReleaseBB); + SI->addCase(Builder.getInt32(AtomicExpr::AO_ABI_memory_order_release), + ReleaseBB); } if (!IsLoad && !IsStore) { Builder.SetInsertPoint(AcqRelBB); EmitAtomicOp(*this, E, Dest, Ptr, Val1, Val2, OrderFail, Size, Align, llvm::AcquireRelease); Builder.CreateBr(ContBB); - SI->addCase(Builder.getInt32(4), AcqRelBB); + SI->addCase(Builder.getInt32(AtomicExpr::AO_ABI_memory_order_acq_rel), + AcqRelBB); } Builder.SetInsertPoint(SeqCstBB); EmitAtomicOp(*this, E, Dest, Ptr, Val1, Val2, OrderFail, Size, Align, llvm::SequentiallyConsistent); Builder.CreateBr(ContBB); - SI->addCase(Builder.getInt32(5), SeqCstBB); + SI->addCase(Builder.getInt32(AtomicExpr::AO_ABI_memory_order_seq_cst), + SeqCstBB); // Cleanup and return Builder.SetInsertPoint(ContBB);