Last active
April 13, 2020 02:06
-
-
Save mikdusan/f6b52669b5eb7971b94e37fb772f5848 to your computer and use it in GitHub Desktop.
IR fun
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export fn entry() void { | |
comptime { | |
var aaa: ?u64 = 333; | |
var answer: u64 = undefined; | |
answer = aaa.?; | |
} | |
} | |
pub fn panic(msg: []const u8, error_return_trace: ?*@import("builtin").StackTrace) noreturn { | |
while (true) {} | |
} |
Advanced IR Debugging
Andrew added native-debug helper functions for the Zig compiler.
Print triplet of (source:line:col) by calling member function src() for types IrExecutable{Src,Gen}, AstNode, IrInst, IrInst{Src,Gen} .
Dump IR segment by calling member function dump() for types IrExecutable{Src,Gen}, AstNode, IrInst, IrInst{Src,Gen} .
Dump ZigValue type-as-string by calling member function Dump .
When --verbose-ir is enabled, call dbg_ir_break(src_file_zig, line) to breakpoint inside ir_analyze() .
Call dbg_ir_clear() to clear all breakpoints.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
zig build-obj -fno-emit-h -fno-emit-bin unwrap.zig --verbose-ir |& less