Skip to content

Commit

Permalink
test:conv:tollvm: Add test for zero initialization.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jezurko committed Oct 14, 2024
1 parent a17c9d7 commit b3cdfad
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
31 changes: 31 additions & 0 deletions test/vast/Conversion/static-var-b.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// RUN: %vast-front -vast-emit-mlir=hl -o - %s | %file-check %s -check-prefix=HL
// RUN: %check-evict-static-locals %s | %file-check %s -check-prefix=EVICTED
// RUN: %check-core-to-llvm %s | %file-check %s -check-prefix=LLVM

// HL: hl.var @zeroinit, <internal> sc_static
// HL: hl.var @x sc_static
// HL: hl.ref @x

// EVICTED-DAG: hl.var @zeroinit, <internal> sc_static
// EVICTED-DAG: hl.var @foo.x {context = 0 : i64}, <internal> sc_static
// EVICTED: ll.func @foo
// EVICTED: hl.ref @foo.x

// LLVM-DAG: llvm.mlir.global internal @zeroinit()
// LLVM-DAG: [[VAR:%[0-9]+]] = llvm.mlir.zero
// LLVM-DAG: llvm.return [[VAR]]
// LLVM-DAG: }
//
// LLVM-DAG: llvm.mlir.global internal @foo.x()
// LLVM-DAG: [[VAR:%[0-9]+]] = llvm.mlir.zero
// LLVM-DAG: llvm.return [[VAR]]
// LLVM-DAG: }
//
// LLVM: llvm.func @foo
// LLVM: llvm.mlir.addressof @foo.x

static int zeroinit;
int foo() {
static int x;
return x + zeroinit;
}
8 changes: 8 additions & 0 deletions test/vast/Conversion/zero-init-a.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// RUN: %vast-front -vast-emit-mlir=llvm -o - %s | %file-check %s

struct big { int i[sizeof (int) >= 4 && sizeof (void *) >= 4 ? 0x4000 : 4]; };
// CHECK: llvm.mlir.global external @gb()
// CHECK: [[V1:%[0-9]+]] = llvm.mlir.zero : !llvm.struct<"big"
// CHECK: llvm.return [[V1]]
struct big gb;

0 comments on commit b3cdfad

Please sign in to comment.