Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve global variable lowering #736

Merged
merged 4 commits into from
Oct 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion include/vast/Dialect/HighLevel/HighLevelVar.td
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def HighLevel_VarDeclOp
TypeAttr:$type,
Core_StorageClass:$storageClass,
Core_ThreadStorage:$threadStorageClass,
UnitAttr:$constant,
OptionalAttr<Core_GlobalLinkageKind>:$linkage
);

Expand All @@ -38,14 +39,15 @@ def HighLevel_VarDeclOp
"llvm::StringRef":$sym_name,
"core::StorageClass":$storageClass,
"core::TSClass":$threadStorageClass,
"bool":$constant,
CArg< "std::optional< core::GlobalLinkageKind >", "std::nullopt">:$linkage,
CArg< "maybe_builder_callback_ref", "std::nullopt" >:$initBuilder,
CArg< "maybe_builder_callback_ref", "std::nullopt" >:$allocaBuilder
)>
];

let assemblyFormat = [{
$sym_name attr-dict (`,`$linkage^)? custom< StorageClasses >($storageClass, $threadStorageClass)
$sym_name attr-dict (`,`$linkage^)? (`constant` $constant^):(``)? custom< StorageClasses >($storageClass, $threadStorageClass)
`:` $type
(`=` $initializer^)?
(`allocation_size` $allocation_size^)?
Expand Down
1 change: 1 addition & 0 deletions lib/vast/CodeGen/DefaultDeclVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ namespace vast::cg {
.bind(self.symbol(decl))
.bind_always(storage_class(decl))
.bind_always(thread_storage_class(decl))
.bind_always(decl->getType().isConstQualified())
.bind_choose(is_global, std::optional(linkage_builder(decl)), std::nullopt)
// FIXME: The initializer region is filled later as it might
// have references to the VarDecl we are currently
Expand Down
12 changes: 10 additions & 2 deletions lib/vast/Conversion/ToLLVM/IRsToLLVM.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2021-present, Trail of Bits, Inc.

Check notice on line 1 in lib/vast/Conversion/ToLLVM/IRsToLLVM.cpp

View workflow job for this annotation

GitHub Actions / cpp-linter (19, 22.04)

Run clang-format on lib/vast/Conversion/ToLLVM/IRsToLLVM.cpp

File lib/vast/Conversion/ToLLVM/IRsToLLVM.cpp does not conform to Custom style guidelines. (lines 373, 387, 388, 391)

#include "vast/Conversion/Passes.hpp"

Expand Down Expand Up @@ -370,8 +370,7 @@
auto gop = rewriter.create< mlir::LLVM::GlobalOp >(
op.getLoc(),
target_type,
// TODO(conv:irstollvm): Constant.
false,
op.getConstant(),
core::convert_linkage_to_llvm(linkage.value()),
op.getSymbolName(),
mlir::Attribute()
Expand All @@ -383,6 +382,15 @@
auto &region = gop.getInitializerRegion();
rewriter.inlineRegionBefore(op.getInitializer(),
region, region.begin());

auto &gop_init = gop.getInitializer();
if (gop_init.empty() && op.getStorageDuration() == core::StorageDuration::sd_static) {
auto guard = insertion_guard(rewriter);
auto &init_block = gop_init.emplaceBlock();
rewriter.setInsertionPoint(&init_block, init_block.begin());
auto zero_init = rewriter.create< mlir::LLVM::ZeroOp >(op.getLoc(), gop.getType());
rewriter.create< mlir::LLVM::ReturnOp >(op.getLoc(), zero_init);
}
rewriter.eraseOp(op);
return logical_result::success();
}
Expand Down
1 change: 1 addition & 0 deletions lib/vast/Conversion/ToMem/EvictStaticLocals.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ namespace vast::conv {
(fn_symbol.getSymbolName() + "." + op.getSymName()).str(),
op.getStorageClass(),
op.getThreadStorageClass(),
op.getConstant(),
std::optional(core::GlobalLinkageKind::InternalLinkage)
);

Expand Down
4 changes: 4 additions & 0 deletions lib/vast/Dialect/HighLevel/HighLevelOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ namespace vast::hl
llvm::StringRef name,
core::StorageClass storage_class,
core::TSClass thread_storage_class,
bool constant,
std::optional< core::GlobalLinkageKind > linkage,
maybe_builder_callback_ref init,
maybe_builder_callback_ref alloc
Expand All @@ -352,6 +353,9 @@ namespace vast::hl
st.addAttribute("type", mlir::TypeAttr::get(type));
st.addAttribute("storageClass", core::StorageClassAttr::get(ctx, storage_class));
st.addAttribute("threadStorageClass", core::TSClassAttr::get(ctx, thread_storage_class));
if (constant) {
st.addAttribute(getConstantAttrName(st.name), bld.getUnitAttr());
}
if (linkage) {
st.addAttribute("linkage", core::GlobalLinkageKindAttr::get(ctx, linkage.value()));
}
Expand Down
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;

6 changes: 3 additions & 3 deletions test/vast/Dialect/HighLevel/array-a.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
// CHECK: hl.var @ai, <external> : !hl.lvalue<!hl.array<10, !hl.int>>
int ai[10];

// CHECK: hl.var @aci, <external> : !hl.lvalue<!hl.array<5, !hl.int< const >>>
// CHECK: hl.var @aci, <external> constant : !hl.lvalue<!hl.array<5, !hl.int< const >>>
const int aci[5];

// CHECK: hl.var @avi, <external> : !hl.lvalue<!hl.array<5, !hl.int< volatile >>>
volatile int avi[5];

// CHECK: hl.var @acvi, <external> : !hl.lvalue<!hl.array<5, !hl.int< const, volatile >>>
// CHECK: hl.var @acvi, <external> constant : !hl.lvalue<!hl.array<5, !hl.int< const, volatile >>>
const volatile int acvi[5];

// CHECK: hl.var @acvui, <external> : !hl.lvalue<!hl.array<5, !hl.int< unsigned, const, volatile >>>
// CHECK: hl.var @acvui, <external> constant : !hl.lvalue<!hl.array<5, !hl.int< unsigned, const, volatile >>>
const volatile unsigned int acvui[5];

// CHECK: hl.var @af, <external> : !hl.lvalue<!hl.array<10, !hl.float>>
Expand Down
2 changes: 1 addition & 1 deletion test/vast/Dialect/HighLevel/array-c.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// RUN: %vast-cc1 -vast-emit-mlir=hl %s -o - | %file-check %s
// RUN: %vast-cc1 -vast-emit-mlir=hl %s -o %t && %vast-opt %t | diff -B %t -

// CHECK: hl.var @cai, <external> : !hl.lvalue<!hl.array<3, !hl.int< const >>> = {
// CHECK: hl.var @cai, <external> constant : !hl.lvalue<!hl.array<3, !hl.int< const >>> = {
// CHECK: [[V1:%[0-9]+]] = hl.const #core.integer<1> : !hl.int
// CHECK: [[V2:%[0-9]+]] = hl.const #core.integer<2> : !hl.int
// CHECK: [[V3:%[0-9]+]] = hl.const #core.integer<3> : !hl.int
Expand Down
2 changes: 1 addition & 1 deletion test/vast/Dialect/HighLevel/autotype-a.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ int main() {
int x = 0;
//CHECK: hl.var @_a : !hl.lvalue<!hl.auto<!hl.int>>
int y = auto_t(x);
//CHECK: hl.var @_a : !hl.lvalue<!hl.auto<!hl.int, const >>
//CHECK: hl.var @_a constant : !hl.lvalue<!hl.auto<!hl.int, const >>
int z = auto_tc(x);
//CHECK: hl.var @u : !hl.lvalue<!hl.auto<!hl.int>>
__auto_type u = z;
Expand Down
2 changes: 1 addition & 1 deletion test/vast/Dialect/HighLevel/constants-a.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ double d = 0.0;
// CHECK: hl.const "hello" : !hl.lvalue<!hl.array<6, !hl.char>>
const char *str = "hello";

// CHECK: hl.var @arr, <external> : !hl.lvalue<!hl.array<3, !hl.int< const >>>
// CHECK: hl.var @arr, <external> constant : !hl.lvalue<!hl.array<3, !hl.int< const >>>
// CHECK: hl.const #core.integer<1> : !hl.int
// CHECK: hl.const #core.integer<2> : !hl.int
// CHECK: hl.const #core.integer<3> : !hl.int
Expand Down
20 changes: 10 additions & 10 deletions test/vast/Dialect/HighLevel/literals-a.c
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
// // RUN: %vast-cc1 -vast-emit-mlir=hl %s -o - | %file-check %s
// // RUN: %vast-cc1 -vast-emit-mlir=hl %s -o %t && %vast-opt %t | diff -B %t -

// CHECK: hl.var @li, <external> : !hl.lvalue<!hl.int< const >>
// CHECK: hl.var @li, <external> constant : !hl.lvalue<!hl.int< const >>
// CHECK: hl.const #core.integer<10> : !hl.int
const int li = 10;

// CHECK: hl.var @lui, <external> : !hl.lvalue<!hl.int< unsigned, const >>
// CHECK: hl.var @lui, <external> constant : !hl.lvalue<!hl.int< unsigned, const >>
// CHECK: hl.const #core.integer<10> : !hl.int< unsigned >
const unsigned int lui = 10u;

// CHECK: hl.var @ll, <external> : !hl.lvalue<!hl.long< const >>
// CHECK: hl.var @ll, <external> constant : !hl.lvalue<!hl.long< const >>
// CHECK: hl.const #core.integer<10> : !hl.long
const long ll = 10l;

// CHECK: hl.var @lf, <external> : !hl.lvalue<!hl.float< const >>
// CHECK: hl.var @lf, <external> constant : !hl.lvalue<!hl.float< const >>
// CHECK: hl.const #core.float<5.000000e-01> : !hl.float
const float lf = 0.5f;

// CHECK: hl.var @ld, <external> : !hl.lvalue<!hl.double< const >>
// CHECK: hl.var @ld, <external> constant : !hl.lvalue<!hl.double< const >>
// CHECK: hl.const #core.float<5.000000e-01> : !hl.double
const double ld = 0.5;

// CHECK: hl.var @lc, <external> : !hl.lvalue<!hl.char< const >>
// CHECK: hl.var @lc, <external> constant : !hl.lvalue<!hl.char< const >>
// CHECK: hl.const #core.integer<97> : !hl.int
// CHECK: IntegralCast : !hl.int -> !hl.char
const char lc = 'a';
Expand All @@ -31,25 +31,25 @@ const char lc = 'a';
// CHECK: NullToPointer : !hl.int -> !hl.ptr<!hl.void< const >>
const void *null = 0;

// CHECK: hl.var @lb, <external> : !hl.lvalue<!hl.bool< const >>
// CHECK: hl.var @lb, <external> constant : !hl.lvalue<!hl.bool< const >>
// CHECK: hl.const #core.integer<1> : !hl.int
// CHECK: IntegralToBoolean : !hl.int -> !hl.bool
const _Bool lb = 1;

#define SCHAR_MIN (-128)
#define SCHAR_MAX 127

// CHECK: hl.var @scmin, <external> : !hl.lvalue<!hl.char< const >>
// CHECK: hl.var @scmin, <external> constant : !hl.lvalue<!hl.char< const >>
// CHECK: hl.const #core.integer<128> : !hl.int
// CHECK: hl.minus
const char scmin = SCHAR_MIN;

// CHECK: hl.var @scmax, <external> : !hl.lvalue<!hl.char< const >>
// CHECK: hl.var @scmax, <external> constant : !hl.lvalue<!hl.char< const >>
// CHECK: hl.const #core.integer<127> : !hl.int
const char scmax = SCHAR_MAX;

#define UCHAR_MAX 255

// CHECK: hl.var @ucmax, <external> : !hl.lvalue<!hl.char< unsigned, const >>
// CHECK: hl.var @ucmax, <external> constant : !hl.lvalue<!hl.char< unsigned, const >>
// CHECK: hl.const #core.integer<255> : !hl.int
const unsigned char ucmax = UCHAR_MAX;
10 changes: 5 additions & 5 deletions test/vast/Dialect/HighLevel/pointers-a.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ int const * icp = 0;
// CHECK: hl.var @cip, <external> : !hl.lvalue<!hl.ptr<!hl.int< const >>>
const int * cip = 0;

// CHECK: hl.var @ipc, <external> : !hl.lvalue<!hl.ptr<!hl.int, const >>
// CHECK: hl.var @ipc, <external> constant : !hl.lvalue<!hl.ptr<!hl.int, const >>
int * const ipc = 0;

// CHECK: hl.var @icpc, <external> : !hl.lvalue<!hl.ptr<!hl.int< const >, const >>
// CHECK: hl.var @icpc, <external> constant : !hl.lvalue<!hl.ptr<!hl.int< const >, const >>
int const * const icpc = 0;

// CHECK: hl.var @cipc, <external> : !hl.lvalue<!hl.ptr<!hl.int< const >, const >>
// CHECK: hl.var @cipc, <external> constant : !hl.lvalue<!hl.ptr<!hl.int< const >, const >>
const int * const cipc = 0;

// CHECK: hl.var @ipp, <external> : !hl.lvalue<!hl.ptr<!hl.ptr<!hl.int>>>
int ** ipp = 0;

// CHECK: hl.var @ippc, <external> : !hl.lvalue<!hl.ptr<!hl.ptr<!hl.int>, const >>
// CHECK: hl.var @ippc, <external> constant : !hl.lvalue<!hl.ptr<!hl.ptr<!hl.int>, const >>
int ** const ippc = 0;

// CHECK: hl.var @ipcp, <external> : !hl.lvalue<!hl.ptr<!hl.ptr<!hl.int, const >>>
Expand All @@ -37,7 +37,7 @@ int * const * ipcp = 0;
// CHECK: hl.var @icpp, <external> : !hl.lvalue<!hl.ptr<!hl.ptr<!hl.int< const >>>>
int const ** icpp = 0;

// CHECK: hl.var @ipcpc, <external> : !hl.lvalue<!hl.ptr<!hl.ptr<!hl.int, const >, const >>
// CHECK: hl.var @ipcpc, <external> constant : !hl.lvalue<!hl.ptr<!hl.ptr<!hl.int, const >, const >>
int * const * const ipcpc = 0;

// CHECK: hl.var @ippp, <external> : !hl.lvalue<!hl.ptr<!hl.ptr<!hl.ptr<!hl.int>>>>
Expand Down
2 changes: 1 addition & 1 deletion test/vast/Dialect/HighLevel/pointers-b.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int (*fp)(int); // fp is a pointer to function with type int(int)
int n;
const int * pc = &n; // pc is a non-const pointer to a const int

// CHECK: hl.var @cp, <external> : !hl.lvalue<!hl.ptr<!hl.int, const >>
// CHECK: hl.var @cp, <external> constant : !hl.lvalue<!hl.ptr<!hl.int, const >>
int * const cp = &n; // cp is a const pointer to a non-const int

// CHECK: hl.var @pcp, <external> : !hl.lvalue<!hl.ptr<!hl.ptr<!hl.int, const >>>
Expand Down
12 changes: 6 additions & 6 deletions test/vast/Dialect/HighLevel/qualifiers-a.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ void scope() {
// CHECK: hl.var @us : !hl.lvalue<!hl.short< unsigned >>
unsigned short us;

// CHECK: hl.var @ci : !hl.lvalue<!hl.int< const >> = {
// CHECK: hl.var @ci constant : !hl.lvalue<!hl.int< const >> = {
// CHECK: [[C1:%[0-9]+]] = hl.const #core.integer<0> : !hl.int
// CHECK: hl.value.yield [[C1]]
const int ci = 0;

// CHECK: hl.var @cui : !hl.lvalue<!hl.int< unsigned, const >> = {
// CHECK: hl.var @cui constant : !hl.lvalue<!hl.int< unsigned, const >> = {
// CHECK: [[C2:%[0-9]+]] = hl.const #core.integer<0> : !hl.int< unsigned >
// CHECK: hl.value.yield [[C2]]
const unsigned cui = 0U;
Expand All @@ -33,12 +33,12 @@ void scope() {
// CHECK: hl.var @vui : !hl.lvalue<!hl.int< unsigned, volatile >>
volatile unsigned vui;

// CHECK: hl.var @cvi : !hl.lvalue<!hl.int< const, volatile >> = {
// CHECK: hl.var @cvi constant : !hl.lvalue<!hl.int< const, volatile >> = {
// CHECK: [[C3:%[0-9]+]] = hl.const #core.integer<0> : !hl.int
// CHECK: hl.value.yield [[C3]]
const volatile int cvi = 0;

// CHECK: hl.var @cvui : !hl.lvalue<!hl.int< unsigned, const, volatile >> = {
// CHECK: hl.var @cvui constant : !hl.lvalue<!hl.int< unsigned, const, volatile >> = {
// CHECK: [[C4:%[0-9]+]] = hl.const #core.integer<0> : !hl.int< unsigned >
// CHECK: hl.value.yield [[C4]]
const volatile unsigned int cvui = 0U;
Expand All @@ -49,12 +49,12 @@ void scope() {
// CHECK: hl.var @vb : !hl.lvalue<!hl.bool< volatile >>
volatile bool vb;

// CHECK: hl.var @cb : !hl.lvalue<!hl.bool< const >> = {
// CHECK: hl.var @cb constant : !hl.lvalue<!hl.bool< const >> = {
// CHECK: [[C5:%[0-9]+]] = hl.const #false
// CHECK: hl.value.yield [[C5]]
const bool cb = false;

// CHECK: hl.var @cvb : !hl.lvalue<!hl.bool< const, volatile >> = {
// CHECK: hl.var @cvb constant : !hl.lvalue<!hl.bool< const, volatile >> = {
// CHECK: [[C6:%[0-9]+]] = hl.const #true
// CHECK: hl.value.yield [[C6]]
const volatile bool cvb = true;
Expand Down
4 changes: 2 additions & 2 deletions test/vast/Dialect/HighLevel/qualifiers-e.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
// CHECK: hl.var @ia, <external> : !hl.lvalue<!hl.array<10, !hl.int>>
int ia[10];

// CHECK: hl.var @cia, <external> : !hl.lvalue<!hl.array<10, !hl.int< const >>>
// CHECK: hl.var @cia, <external> constant : !hl.lvalue<!hl.array<10, !hl.int< const >>>
const int cia[10];

// CHECK: hl.var @via, <external> : !hl.lvalue<!hl.array<10, !hl.int< volatile >>>
volatile int via[10];

// CHECK: hl.var @cvia, <external> : !hl.lvalue<!hl.array<10, !hl.int< const, volatile >>>
// CHECK: hl.var @cvia, <external> constant : !hl.lvalue<!hl.array<10, !hl.int< const, volatile >>>
const volatile int cvia[10];
8 changes: 4 additions & 4 deletions test/vast/Dialect/HighLevel/qualifiers-h.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ enum e { a, b, c };
// CHECK: hl.var @v, <external> : !hl.lvalue<!hl.elaborated<!hl.enum<@e>>>
enum e v;

// CHECK: hl.var @cv, <external> : !hl.lvalue<!hl.elaborated<!hl.enum<@e>, const >>
// CHECK: hl.var @cv, <external> constant : !hl.lvalue<!hl.elaborated<!hl.enum<@e>, const >>
const enum e cv;

// CHECK: hl.var @cvv, <external> : !hl.lvalue<!hl.elaborated<!hl.enum<@e>, const, volatile >>
// CHECK: hl.var @cvv, <external> constant : !hl.lvalue<!hl.elaborated<!hl.enum<@e>, const, volatile >>
const volatile enum e cvv;

// CHECK: hl.typedef @def : !hl.elaborated<!hl.enum<@e>>
Expand All @@ -19,11 +19,11 @@ typedef enum e def;
// CHECK: hl.var @d, <external> : !hl.lvalue<!hl.elaborated<!hl.typedef<@def>>>
def d;

// CHECK: hl.var @cd, <external> : !hl.lvalue<!hl.elaborated<!hl.typedef<@def>, const >>
// CHECK: hl.var @cd, <external> constant : !hl.lvalue<!hl.elaborated<!hl.typedef<@def>, const >>
const def cd;

// CHECK: hl.var @vd, <external> : !hl.lvalue<!hl.elaborated<!hl.typedef<@def>, volatile >>
volatile def vd;

// CHECK: hl.var @cvd, <external> : !hl.lvalue<!hl.elaborated<!hl.typedef<@def>, const, volatile >>
// CHECK: hl.var @cvd, <external> constant : !hl.lvalue<!hl.elaborated<!hl.typedef<@def>, const, volatile >>
const volatile def cvd;
8 changes: 4 additions & 4 deletions test/vast/Dialect/HighLevel/qualifiers-i.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ union u { int i; double d; };
// CHECK: hl.var @v, <external> : !hl.lvalue<!hl.elaborated<!hl.record<@u>>>
union u v;

// CHECK: hl.var @cv, <external> : !hl.lvalue<!hl.elaborated<!hl.record<@u>, const >>
// CHECK: hl.var @cv, <external> constant : !hl.lvalue<!hl.elaborated<!hl.record<@u>, const >>
const union u cv;

// CHECK: hl.var @cvv, <external> : !hl.lvalue<!hl.elaborated<!hl.record<@u>, const, volatile >>
// CHECK: hl.var @cvv, <external> constant : !hl.lvalue<!hl.elaborated<!hl.record<@u>, const, volatile >>
const volatile union u cvv;

// CHECK: hl.typedef @e : !hl.elaborated<!hl.record<@u>>
Expand All @@ -19,11 +19,11 @@ typedef union u e;
// CHECK: hl.var @v, <external> : !hl.lvalue<!hl.elaborated<!hl.typedef<@e>>>
e v;

// CHECK: hl.var @cv, <external> : !hl.lvalue<!hl.elaborated<!hl.typedef<@e>, const >>
// CHECK: hl.var @cv, <external> constant : !hl.lvalue<!hl.elaborated<!hl.typedef<@e>, const >>
const e cv;

// CHECK: hl.var @vv, <external> : !hl.lvalue<!hl.elaborated<!hl.typedef<@e>, volatile >>
volatile e vv;

// CHECK: hl.var @cvv, <external> : !hl.lvalue<!hl.elaborated<!hl.typedef<@e>, const, volatile >>
// CHECK: hl.var @cvv, <external> constant : !hl.lvalue<!hl.elaborated<!hl.typedef<@e>, const, volatile >>
const volatile e cvv;
Loading