-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
backend-llvmThe LLVM backend outputs an LLVM IR Module.The LLVM backend outputs an LLVM IR Module.enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.optimization
Milestone
Description
Zig Version
0.9.0
Steps to Reproduce
Run the following code and observe the generated LLVM IR and asm
const std = @import("std");
pub var arr = blk: {
var x = std.mem.zeroes([10 * 1024]u32);
x[5] = 2;
break :blk x;
};
export fn tester(x : usize) u32 {
return arr[x];
}
Expected Behavior
The following LLVM IR is what Clang generates for similar code:
@arr = dso_local global <{ i32, i32, i32, i32, i32, i32, [10234 x i32] }> <{ i32 0, i32 0, i32 0, i32 0, i32 0, i32 2, [10234 x i32] zeroinitializer }>, align 16Actual Behavior
The following LLVM IR is generated:
@arr = internal unnamed_addr global [10240 x i32] [i32 0, i32 0, i32 0, i32 0, i32 0, i32 2, <omitting about 10000 i32 0> i32 0,i32 0, i32 0], align 4Metadata
Metadata
Assignees
Labels
backend-llvmThe LLVM backend outputs an LLVM IR Module.The LLVM backend outputs an LLVM IR Module.enhancementSolving this issue will likely involve adding new logic or components to the codebase.Solving this issue will likely involve adding new logic or components to the codebase.optimization