Skip to content

Instantly share code, notes, and snippets.

@andrewrk

andrewrk/example.zig

Last active Jan 1, 2020
Embed
What would you like to do?
how to create a small zig file for viewing IR
// trick #1 export a void function and put your logic here
// using std lib functions creates a lot of IR
export fn entry() void {
var x: i32 = 1;
x += 1;
}
// trick #2, override the default panic handler to something trivial
const std = @import("std");
pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace) noreturn {
@breakpoint(); unreachable;
}
// build this with:
// zig build-obj example.zig --verbose-ir
// or
// zig build-obj example.zig --verbose-llvm-ir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.