mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
41 lines
806 B
Plaintext
41 lines
806 B
Plaintext
// #target: macos-x64
|
|
module test;
|
|
struct Abc
|
|
{
|
|
int a;
|
|
int b;
|
|
}
|
|
|
|
const Abc X = { 2, 3 };
|
|
|
|
const int Y = X.b;
|
|
const int* Z = &X.b;
|
|
|
|
fn void main()
|
|
{
|
|
Abc x = X;
|
|
int y = Y;
|
|
int* yy = &Y;
|
|
int* z = Z;
|
|
}
|
|
|
|
/* #expect: test.ll
|
|
|
|
@test.X = constant %Abc { i32 2, i32 3 }, align 4
|
|
@test.Y = constant i32 3, align 4
|
|
@test.Z = local_unnamed_addr constant ptr getelementptr inbounds (i8, ptr @test.X, i64 4), align 8
|
|
|
|
define void @test.main() #0 {
|
|
entry:
|
|
%x = alloca %Abc, align 4
|
|
%y = alloca i32, align 4
|
|
%yy = alloca ptr, align 8
|
|
%z = alloca ptr, align 8
|
|
call void @llvm.memcpy.p0.p0.i32(ptr align 4 %x, ptr align 4 @test.X, i32 8, i1 false)
|
|
store i32 3, ptr %y, align 4
|
|
store ptr @test.Y, ptr %yy, align 8
|
|
store ptr getelementptr inbounds (i8, ptr @test.X, i64 4), ptr %z, align 8
|
|
ret void
|
|
}
|
|
|