summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExpr.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2011-10-14 20:59:01 +0000
committerEli Friedman <eli.friedman@gmail.com>2011-10-14 20:59:01 +0000
commit4b72fddd9914d76370704c79f5fdedfbc6c6dedc (patch)
treea7fdd04f544b898111e60d696d30d8b5f6953571 /clang/lib/CodeGen/CGExpr.cpp
parent8b478360efd56c1b150647f794b2e13e6fef8400 (diff)
downloadbcm5719-llvm-4b72fddd9914d76370704c79f5fdedfbc6c6dedc.tar.gz
bcm5719-llvm-4b72fddd9914d76370704c79f5fdedfbc6c6dedc.zip
Misc fixes for atomics. Biggest fix is doing alignment correctly for _Atomic types.
llvm-svn: 142002
Diffstat (limited to 'clang/lib/CodeGen/CGExpr.cpp')
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index ad27506d56e..bd4e553991b 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -2567,9 +2567,9 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E, llvm::Value *Dest) {
uint64_t Size = sizeChars.getQuantity();
CharUnits alignChars = getContext().getTypeAlignInChars(AtomicTy);
unsigned Align = alignChars.getQuantity();
- // FIXME: Bound on Size should not be hardcoded.
- bool UseLibcall = (sizeChars != alignChars || !llvm::isPowerOf2_64(Size) ||
- Size > 8);
+ unsigned MaxInlineWidth =
+ getContext().getTargetInfo().getMaxAtomicInlineWidth();
+ bool UseLibcall = (Size != Align || Size > MaxInlineWidth);
llvm::Value *Ptr, *Order, *OrderFail = 0, *Val1 = 0, *Val2 = 0;
Ptr = EmitScalarExpr(E->getPtr());
@@ -2585,11 +2585,9 @@ RValue CodeGenFunction::EmitAtomicExpr(AtomicExpr *E, llvm::Value *Dest) {
// is not the same as adding 1 to a uintptr_t.
QualType Val1Ty = E->getVal1()->getType();
llvm::Value *Val1Scalar = EmitScalarExpr(E->getVal1());
- uint64_t PointeeIncAmt =
- getContext().getTypeSizeInChars(MemTy->getPointeeType()).getQuantity();
- llvm::Value *PointeeIncAmtVal =
- llvm::ConstantInt::get(Val1Scalar->getType(), PointeeIncAmt);
- Val1Scalar = Builder.CreateMul(Val1Scalar, PointeeIncAmtVal);
+ CharUnits PointeeIncAmt =
+ getContext().getTypeSizeInChars(MemTy->getPointeeType());
+ Val1Scalar = Builder.CreateMul(Val1Scalar, CGM.getSize(PointeeIncAmt));
Val1 = CreateMemTemp(Val1Ty, ".atomictmp");
EmitStoreOfScalar(Val1Scalar, MakeAddrLValue(Val1, Val1Ty));
} else if (E->getOp() != AtomicExpr::Load) {
OpenPOWER on IntegriCloud