[PATCH] D79017: [mlir][llvm] Fix llvmBuilder for llvm.alloca so it could emit to non-zero addrspace.

Wen-Heng (Jack) Chung via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 28 09:39:06 PDT 2020


whchung created this revision.
Herald added subscribers: llvm-commits, Kayjukh, frgossen, grosul1, Joonsoo, liufengdb, lucyrfox, mgester, arpith-jacob, nicolasvasilache, antiagainst, shauheen, jpienaar, rriddle, mehdi_amini.
Herald added a reviewer: ftynse.
Herald added a project: LLVM.
whchung retitled this revision from "Fix llvmBuilder for llvm.alloca so it could emit to non-zero addrspace." to "[mlir][llvm] Fix llvmBuilder for llvm.alloca so it could emit to non-zero addrspace.".
whchung edited the summary of this revision.
whchung added a reviewer: nicolasvasilache.
whchung added a project: MLIR.

For certain targets alloca can take place on a non-zero addrspace.

No tests are added for this patch as existing patches would all pass.

Subsequent patches to mlir-translate would cover cases where alloca on non-zero addrspace takes place.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D79017

Files:
  mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td


Index: mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
===================================================================
--- mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
+++ mlir/include/mlir/Dialect/LLVMIR/LLVMOps.td
@@ -219,8 +219,10 @@
     LLVM_OneResultOp<"alloca">,
     Arguments<(ins LLVM_Type:$arraySize, OptionalAttr<I64Attr>:$alignment)> {
   string llvmBuilder = [{
+    llvm::Module *module = builder.GetInsertBlock()->getModule();
+    auto allocaAddrSpace = module->getDataLayout().getAllocaAddrSpace();
     auto *alloca = builder.CreateAlloca(
-      $_resultType->getPointerElementType(), $arraySize);
+      $_resultType->getPointerElementType(), allocaAddrSpace, $arraySize);
     if ($alignment.hasValue()) {
       auto align = $alignment.getValue().getZExtValue();
       if (align != 0)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D79017.260664.patch
Type: text/x-patch
Size: 808 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200428/efee5f13/attachment.bin>


More information about the llvm-commits mailing list