|
| 1 | +// RUN: mlir-opt %s -o - | FileCheck %s |
| 2 | + |
| 3 | +module { |
| 4 | + llvm.func @foo(%arg0: i32) -> i32 attributes {dso_local} { |
| 5 | + %0 = llvm.mlir.constant(1 : i32) : i32 |
| 6 | + %1 = llvm.mlir.constant(0 : i32) : i32 |
| 7 | + // CHECK: !llvm.struct<"struct.S", (i32)> |
| 8 | + %2 = llvm.alloca %0 x !llvm.struct<"struct.S", (i32)> {alignment = 4 : i64} : (i32) -> !llvm.ptr |
| 9 | + %3 = llvm.getelementptr inbounds %2[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.S", (i32)> |
| 10 | + llvm.store %arg0, %3 {alignment = 4 : i64} : i32, !llvm.ptr |
| 11 | + %4 = llvm.getelementptr inbounds %2[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.S", (i32)> |
| 12 | + %5 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> i32 |
| 13 | + llvm.return %5 : i32 |
| 14 | + } |
| 15 | +} |
| 16 | + |
| 17 | +module { |
| 18 | + llvm.func @getX(%arg0: !llvm.struct<"struct.S", (i32, i1, i32)>) -> i32 attributes {dso_local} { |
| 19 | + %0 = llvm.mlir.constant(1 : i32) : i32 |
| 20 | + %1 = llvm.mlir.constant(0 : i32) : i32 |
| 21 | + // CHECK: !llvm.struct<"struct.S.1", (i32, i1, i32)> |
| 22 | + %2 = llvm.alloca %0 x !llvm.struct<"struct.S", (i32, i1, i32)> {alignment = 4 : i64} : (i32) -> !llvm.ptr |
| 23 | + %3 = llvm.getelementptr inbounds %2[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.S", (i32, i1, i32)> |
| 24 | + llvm.store %arg0, %3 {alignment = 4 : i64} : !llvm.struct<"struct.S", (i32, i1, i32)>, !llvm.ptr |
| 25 | + %4 = llvm.getelementptr inbounds %2[%1, 0] : (!llvm.ptr, i32) -> !llvm.ptr, !llvm.struct<"struct.S", (i32, i1, i32)> |
| 26 | + %5 = llvm.load %4 {alignment = 4 : i64} : !llvm.ptr -> i32 |
| 27 | + llvm.return %5 : i32 |
| 28 | + } |
| 29 | +} |
0 commit comments