diff options
Diffstat (limited to 'clang/lib/CodeGen/CGAtomic.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGAtomic.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/clang/lib/CodeGen/CGAtomic.cpp b/clang/lib/CodeGen/CGAtomic.cpp index 10569ae2c3f9..dee0cb64be97 100644 --- a/clang/lib/CodeGen/CGAtomic.cpp +++ b/clang/lib/CodeGen/CGAtomic.cpp @@ -86,15 +86,14 @@ namespace { lvalue.getAlignment(); VoidPtrAddr = CGF.Builder.CreateConstGEP1_64( CGF.Int8Ty, VoidPtrAddr, OffsetInChars.getQuantity()); + llvm::Type *IntTy = CGF.Builder.getIntNTy(AtomicSizeInBits); auto Addr = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast( - VoidPtrAddr, - CGF.Builder.getIntNTy(AtomicSizeInBits)->getPointerTo(), - "atomic_bitfield_base"); + VoidPtrAddr, IntTy->getPointerTo(), "atomic_bitfield_base"); BFI = OrigBFI; BFI.Offset = Offset; BFI.StorageSize = AtomicSizeInBits; BFI.StorageOffset += OffsetInChars; - LVal = LValue::MakeBitfield(Address(Addr, lvalue.getAlignment()), + LVal = LValue::MakeBitfield(Address(Addr, IntTy, lvalue.getAlignment()), BFI, lvalue.getType(), lvalue.getBaseInfo(), lvalue.getTBAAInfo()); AtomicTy = C.getIntTypeForBitwidth(AtomicSizeInBits, OrigBFI.IsSigned); @@ -149,7 +148,16 @@ namespace { return LVal.getExtVectorPointer(); } Address getAtomicAddress() const { - return Address(getAtomicPointer(), getAtomicAlignment()); + llvm::Type *ElTy; + if (LVal.isSimple()) + ElTy = LVal.getAddress(CGF).getElementType(); + else if (LVal.isBitField()) + ElTy = LVal.getBitFieldAddress().getElementType(); + else if (LVal.isVectorElt()) + ElTy = LVal.getVectorAddress().getElementType(); + else + ElTy = LVal.getExtVectorAddress().getElementType(); + return Address(getAtomicPointer(), ElTy, getAtomicAlignment()); } Address getAtomicAddressAsAtomicIntPointer() const { @@ -296,7 +304,8 @@ Address AtomicInfo::CreateTempAlloca() const { // Cast to pointer to value type for bitfields. if (LVal.isBitField()) return CGF.Builder.CreatePointerBitCastOrAddrSpaceCast( - TempAlloca, getAtomicAddress().getType()); + TempAlloca, getAtomicAddress().getType(), + getAtomicAddress().getElementType()); return TempAlloca; } @@ -779,9 +788,9 @@ AddDirectArgument(CodeGenFunction &CGF, CallArgList &Args, int64_t SizeInBits = CGF.getContext().toBits(SizeInChars); ValTy = CGF.getContext().getIntTypeForBitwidth(SizeInBits, /*Signed=*/false); - llvm::Type *IPtrTy = llvm::IntegerType::get(CGF.getLLVMContext(), - SizeInBits)->getPointerTo(); - Address Ptr = Address(CGF.Builder.CreateBitCast(Val, IPtrTy), Align); + llvm::Type *ITy = llvm::IntegerType::get(CGF.getLLVMContext(), SizeInBits); + Address Ptr = Address(CGF.Builder.CreateBitCast(Val, ITy->getPointerTo()), + ITy, Align); Val = CGF.EmitLoadOfScalar(Ptr, false, CGF.getContext().getPointerType(ValTy), Loc); |
