Skip to content

Commit

Permalink
[ReuseIR] fix alignment for alloca
Browse files Browse the repository at this point in the history
  • Loading branch information
Yifan Zhu committed Aug 21, 2024
1 parent 3a68cd0 commit c7c750d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
1 change: 0 additions & 1 deletion reuse-mlir/src/cxx/Passes/ConvertReuseIRToLLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ class ValueToRefOpLowering
mlir::ConversionPatternRewriter &rewriter) const override final {
uint64_t alignment = cache.getDataLayout().getTypePreferredAlignment(
op.getValue().getType());
alignment = std::max(cache.getDataLayout().getStackAlignment(), alignment);
auto ptrTy = LLVM::LLVMPointerType::get(getContext());
auto alloca = rewriter.create<mlir::LLVM::AllocaOp>(
op->getLoc(), ptrTy, adaptor.getValue().getType(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
module @test attributes {dlti.dl_spec = #dlti.dl_spec<#dlti.dl_entry<f80, dense<128> : vector<2xi64>>, #dlti.dl_entry<i128, dense<128> : vector<2xi64>>, #dlti.dl_entry<i32, dense<32> : vector<2xi64>>, #dlti.dl_entry<f128, dense<128> : vector<2xi64>>, #dlti.dl_entry<f64, dense<64> : vector<2xi64>>, #dlti.dl_entry<f16, dense<16> : vector<2xi64>>, #dlti.dl_entry<i1, dense<8> : vector<2xi64>>, #dlti.dl_entry<!llvm.ptr, dense<64> : vector<4xi64>>, #dlti.dl_entry<!llvm.ptr<270>, dense<32> : vector<4xi64>>, #dlti.dl_entry<i8, dense<8> : vector<2xi64>>, #dlti.dl_entry<i16, dense<16> : vector<2xi64>>, #dlti.dl_entry<!llvm.ptr<272>, dense<64> : vector<4xi64>>, #dlti.dl_entry<!llvm.ptr<271>, dense<32> : vector<4xi64>>, #dlti.dl_entry<i64, dense<64> : vector<2xi64>>, #dlti.dl_entry<"dlti.stack_alignment", 128 : i64>, #dlti.dl_entry<"dlti.endianness", "little">>, llvm.data_layout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"} {
func.func @borrow_nonfreezing(%0: !test) {
// CHECK-ORIGIN: %[[REG0:[a-z0-9]+]] = llvm.mlir.constant(1 : i64) : i64
// CHECK-ORIGIN: %[[REG1:[a-z0-9]+]] = llvm.alloca %[[REG0]] x !llvm.struct<(struct<(i128, i32, array<12 x i8>)>, i32, array<12 x i8>)> {alignment = 128 : i64} : (i64) -> !llvm.ptr
// CHECK-ORIGIN: llvm.store %{{[a-z0-9]+}}, %[[REG1]] {alignment = 128 : i64} : !llvm.struct<(struct<(i128, i32, array<12 x i8>)>, i32, array<12 x i8>)>, !llvm.ptr
// CHECK-ORIGIN: %[[REG1:[a-z0-9]+]] = llvm.alloca %[[REG0]] x !llvm.struct<(struct<(i128, i32, array<12 x i8>)>, i32, array<12 x i8>)> {alignment = 16 : i64} : (i64) -> !llvm.ptr
// CHECK-ORIGIN: llvm.store %{{[a-z0-9]+}}, %[[REG1]] {alignment = 16 : i64} : !llvm.struct<(struct<(i128, i32, array<12 x i8>)>, i32, array<12 x i8>)>, !llvm.ptr
%1 = reuse_ir.val2ref %0 : !test -> !reuse_ir.ref<!test, nonfreezing>
func.call @opaque (%1) : (!reuse_ir.ref<!test, nonfreezing>) -> ()
return
Expand Down

0 comments on commit c7c750d

Please sign in to comment.