[PATCH] D91256: [AtomicExpandPass] Allow for pointer types in insertRMWCmpXchgLoop()

Alexander Richardson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 11 06:28:10 PST 2020


arichardson created this revision.
arichardson added reviewers: t.p.northover, jyknight.
Herald added subscribers: llvm-commits, jfb, hiraditya.
Herald added a project: LLVM.
arichardson requested review of this revision.

In our CHERI target we support RMW operations on capability types which
are implemented as i8 addrspace(200)*. In certain case we have to fall
back to the cmpxchg expansion and were hitting an assertion here since
getPrimitiveSizeInBits() returns zero for pointer types. Fix this by
querying the DataLayout instead.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D91256

Files:
  llvm/lib/CodeGen/AtomicExpandPass.cpp


Index: llvm/lib/CodeGen/AtomicExpandPass.cpp
===================================================================
--- llvm/lib/CodeGen/AtomicExpandPass.cpp
+++ llvm/lib/CodeGen/AtomicExpandPass.cpp
@@ -1413,7 +1413,8 @@
   Builder.SetInsertPoint(BB);
   LoadInst *InitLoaded = Builder.CreateLoad(ResultTy, Addr);
   // Atomics require at least natural alignment.
-  InitLoaded->setAlignment(Align(ResultTy->getPrimitiveSizeInBits() / 8));
+  auto TypeSize = F->getParent()->getDataLayout().getTypeSizeInBits(ResultTy);
+  InitLoaded->setAlignment(Align(TypeSize.getFixedSize() / 8));
   Builder.CreateBr(LoopBB);
 
   // Start the main loop block now that we've taken care of the preliminaries.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D91256.304503.patch
Type: text/x-patch
Size: 694 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201111/69c5f02c/attachment.bin>


More information about the llvm-commits mailing list