summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AtomicExpandPass.cpp
diff options
context:
space:
mode:
authorPhilip Reames <listmail@philipreames.com>2019-03-05 23:00:14 +0000
committerPhilip Reames <listmail@philipreames.com>2019-03-05 23:00:14 +0000
commit1e4c5d36110e883fe5160db60000db73708a3daa (patch)
tree768d86b60cca397443028642bd782f615142eb7e /llvm/lib/CodeGen/AtomicExpandPass.cpp
parent98d412ff13506660eb5af3c5e57c3736d4c6d4b1 (diff)
downloadbcm5719-llvm-1e4c5d36110e883fe5160db60000db73708a3daa.tar.gz
bcm5719-llvm-1e4c5d36110e883fe5160db60000db73708a3daa.zip
[AtomicExpand] Allow libcall expansion for non-zero address spaces
Be consistent about how we treat atomics in non-zero address spaces. If we get to the backend, we tend to lower them as if in address space 0. Do the same if we need to insert a libcall instead. Differential Revision: https://reviews.llvm.org/D58760 llvm-svn: 355453
Diffstat (limited to 'llvm/lib/CodeGen/AtomicExpandPass.cpp')
-rw-r--r--llvm/lib/CodeGen/AtomicExpandPass.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/llvm/lib/CodeGen/AtomicExpandPass.cpp b/llvm/lib/CodeGen/AtomicExpandPass.cpp
index c247a8afcf7..10dd21d1ef9 100644
--- a/llvm/lib/CodeGen/AtomicExpandPass.cpp
+++ b/llvm/lib/CodeGen/AtomicExpandPass.cpp
@@ -1691,8 +1691,14 @@ bool AtomicExpand::expandAtomicOpToLibcall(
}
// 'ptr' argument.
- Value *PtrVal =
- Builder.CreateBitCast(PointerOperand, Type::getInt8PtrTy(Ctx));
+ // note: This assumes all address spaces share a common libfunc
+ // implementation and that addresses are convertable. For systems without
+ // that property, we'd need to extend this mechanism to support AS-specific
+ // families of atomic intrinsics.
+ auto PtrTypeAS = PointerOperand->getType()->getPointerAddressSpace();
+ Value *PtrVal = Builder.CreateBitCast(PointerOperand,
+ Type::getInt8PtrTy(Ctx, PtrTypeAS));
+ PtrVal = Builder.CreateAddrSpaceCast(PtrVal, Type::getInt8PtrTy(Ctx));
Args.push_back(PtrVal);
// 'expected' argument, if present.
OpenPOWER on IntegriCloud