mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
Merge pull request #2982 from rtfeldman/more-debug-flags
Add more debug flags
This commit is contained in:
commit
2ab0bc1226
8 changed files with 57 additions and 28 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -3366,6 +3366,7 @@ version = "0.1.0"
|
|||
dependencies = [
|
||||
"morphic_lib",
|
||||
"roc_collections",
|
||||
"roc_debug_flags",
|
||||
"roc_module",
|
||||
"roc_mono",
|
||||
]
|
||||
|
@ -3683,6 +3684,7 @@ dependencies = [
|
|||
"roc_alias_analysis",
|
||||
"roc_builtins",
|
||||
"roc_collections",
|
||||
"roc_debug_flags",
|
||||
"roc_error_macros",
|
||||
"roc_module",
|
||||
"roc_mono",
|
||||
|
|
|
@ -10,4 +10,4 @@ morphic_lib = {path = "../../vendor/morphic_lib"}
|
|||
roc_collections = {path = "../collections"}
|
||||
roc_module = {path = "../module"}
|
||||
roc_mono = {path = "../mono"}
|
||||
|
||||
roc_debug_flags = {path = "../debug_flags"}
|
||||
|
|
|
@ -26,8 +26,16 @@ pub fn func_name_bytes(proc: &Proc) -> [u8; SIZE] {
|
|||
func_name_bytes_help(proc.name, proc.args.iter().map(|x| x.0), &proc.ret_layout)
|
||||
}
|
||||
|
||||
const DEBUG: bool = false;
|
||||
const SIZE: usize = if DEBUG { 50 } else { 16 };
|
||||
#[inline(always)]
|
||||
fn debug() -> bool {
|
||||
use roc_debug_flags::{dbg_do, ROC_DEBUG_ALIAS_ANALYSIS};
|
||||
dbg_do!(ROC_DEBUG_ALIAS_ANALYSIS, {
|
||||
return true;
|
||||
});
|
||||
false
|
||||
}
|
||||
|
||||
const SIZE: usize = 16;
|
||||
|
||||
#[derive(Debug, Clone, Copy, Hash)]
|
||||
struct TagUnionId(u64);
|
||||
|
@ -87,7 +95,7 @@ where
|
|||
*target = *source;
|
||||
}
|
||||
|
||||
if DEBUG {
|
||||
if debug() {
|
||||
for (i, c) in (format!("{:?}", symbol)).chars().take(25).enumerate() {
|
||||
name_bytes[25 + i] = c as u8;
|
||||
}
|
||||
|
@ -175,7 +183,7 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
if DEBUG {
|
||||
if debug() {
|
||||
eprintln!(
|
||||
"{:?}: {:?} with {:?} args",
|
||||
proc.name,
|
||||
|
@ -239,7 +247,7 @@ where
|
|||
p.build()?
|
||||
};
|
||||
|
||||
if DEBUG {
|
||||
if debug() {
|
||||
eprintln!("{}", program.to_source_string());
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ macro_rules! dbg_do {
|
|||
($flag:path, $expr:expr) => {
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
if std::env::var($flag).unwrap_or("0".to_string()) != "0" {
|
||||
if std::env::var($flag).as_ref() == Ok(&"0".to_string()) {
|
||||
$expr
|
||||
}
|
||||
}
|
||||
|
@ -64,16 +64,27 @@ flags! {
|
|||
|
||||
// ===Mono===
|
||||
|
||||
/// Writes the mono IR to stderr after function specialization
|
||||
/// Writes a pretty-printed mono IR to stderr after function specialization.
|
||||
ROC_PRINT_IR_AFTER_SPECIALIZATION
|
||||
|
||||
/// Writes the mono IR to stderr after insertion of reset/reuse instructions
|
||||
/// Writes a pretty-printed mono IR to stderr after insertion of reset/reuse
|
||||
/// instructions.
|
||||
ROC_PRINT_IR_AFTER_RESET_REUSE
|
||||
|
||||
/// Writes the mono IR to stderr after insertion of refcount instructions
|
||||
/// Writes a pretty-printed mono IR to stderr after insertion of refcount
|
||||
/// instructions.
|
||||
ROC_PRINT_IR_AFTER_REFCOUNT
|
||||
|
||||
/// Instructs the mono IR pretty printer to dump pretty symbols and verbose
|
||||
/// layout information
|
||||
ROC_PRETTY_PRINT_IR_SYMBOLS
|
||||
/// Prints debug information during the alias analysis pass.
|
||||
ROC_DEBUG_ALIAS_ANALYSIS
|
||||
|
||||
// ===LLVM Gen===
|
||||
|
||||
/// Prints LLVM function verification output.
|
||||
ROC_PRINT_LLVM_FN_VERIFICATION
|
||||
|
||||
// ===Load===
|
||||
|
||||
/// Print load phases as they complete.
|
||||
ROC_PRINT_LOAD_LOG
|
||||
}
|
||||
|
|
|
@ -15,6 +15,7 @@ roc_error_macros = { path = "../../error_macros" }
|
|||
roc_mono = { path = "../mono" }
|
||||
roc_target = { path = "../roc_target" }
|
||||
roc_std = { path = "../../roc_std", default-features = false }
|
||||
roc_debug_flags = { path = "../debug_flags" }
|
||||
morphic_lib = { path = "../../vendor/morphic_lib" }
|
||||
bumpalo = { version = "3.8.0", features = ["collections"] }
|
||||
inkwell = { path = "../../vendor/inkwell" }
|
||||
|
|
|
@ -56,6 +56,7 @@ use morphic_lib::{
|
|||
use roc_builtins::bitcode::{self, FloatWidth, IntWidth, IntrinsicName};
|
||||
use roc_builtins::{float_intrinsic, llvm_int_intrinsic};
|
||||
use roc_collections::all::{ImMap, MutMap, MutSet};
|
||||
use roc_debug_flags::{dbg_do, ROC_PRINT_LLVM_FN_VERIFICATION};
|
||||
use roc_error_macros::internal_error;
|
||||
use roc_module::low_level::LowLevel;
|
||||
use roc_module::symbol::{Interns, ModuleId, Symbol};
|
||||
|
@ -67,13 +68,13 @@ use roc_mono::layout::{Builtin, LambdaSet, Layout, LayoutIds, TagIdIntType, Unio
|
|||
use roc_target::{PtrWidth, TargetInfo};
|
||||
use target_lexicon::{Architecture, OperatingSystem, Triple};
|
||||
|
||||
/// This is for Inkwell's FunctionValue::verify - we want to know the verification
|
||||
/// output in debug builds, but we don't want it to print to stdout in release builds!
|
||||
#[cfg(debug_assertions)]
|
||||
const PRINT_FN_VERIFICATION_OUTPUT: bool = true;
|
||||
|
||||
#[cfg(not(debug_assertions))]
|
||||
const PRINT_FN_VERIFICATION_OUTPUT: bool = false;
|
||||
#[inline(always)]
|
||||
fn print_fn_verification_output() -> bool {
|
||||
dbg_do!(ROC_PRINT_LLVM_FN_VERIFICATION, {
|
||||
return true;
|
||||
});
|
||||
false
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! debug_info_init {
|
||||
|
@ -4513,7 +4514,7 @@ pub fn build_proc<'a, 'ctx, 'env>(
|
|||
}
|
||||
|
||||
pub fn verify_fn(fn_val: FunctionValue<'_>) {
|
||||
if !fn_val.verify(PRINT_FN_VERIFICATION_OUTPUT) {
|
||||
if !fn_val.verify(print_fn_verification_output()) {
|
||||
unsafe {
|
||||
fn_val.delete();
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ use roc_constrain::module::{
|
|||
};
|
||||
use roc_debug_flags::{
|
||||
dbg_do, ROC_PRINT_IR_AFTER_REFCOUNT, ROC_PRINT_IR_AFTER_RESET_REUSE,
|
||||
ROC_PRINT_IR_AFTER_SPECIALIZATION,
|
||||
ROC_PRINT_IR_AFTER_SPECIALIZATION, ROC_PRINT_LOAD_LOG,
|
||||
};
|
||||
use roc_error_macros::internal_error;
|
||||
use roc_module::ident::{Ident, ModuleName, QualifiedModuleName};
|
||||
|
@ -74,13 +74,10 @@ const PKG_CONFIG_FILE_NAME: &str = "Package-Config";
|
|||
/// The . in between module names like Foo.Bar.Baz
|
||||
const MODULE_SEPARATOR: char = '.';
|
||||
|
||||
const SHOW_MESSAGE_LOG: bool = false;
|
||||
|
||||
const EXPANDED_STACK_SIZE: usize = 8 * 1024 * 1024;
|
||||
|
||||
macro_rules! log {
|
||||
() => (if SHOW_MESSAGE_LOG { println!()} else {});
|
||||
($($arg:tt)*) => (if SHOW_MESSAGE_LOG { println!($($arg)*); } else {})
|
||||
($($arg:tt)*) => (dbg_do!(ROC_PRINT_LOAD_LOG, println!($($arg)*)))
|
||||
}
|
||||
|
||||
/// Struct storing various intermediate stages by their ModuleId
|
||||
|
|
|
@ -10,7 +10,10 @@ use roc_builtins::bitcode::{FloatWidth, IntWidth};
|
|||
use roc_can::abilities::AbilitiesStore;
|
||||
use roc_can::expr::{AnnotatedMark, ClosureData, IntValue};
|
||||
use roc_collections::all::{default_hasher, BumpMap, BumpMapDefault, MutMap};
|
||||
use roc_debug_flags::{dbg_do, ROC_PRETTY_PRINT_IR_SYMBOLS};
|
||||
use roc_debug_flags::{
|
||||
dbg_do, ROC_PRINT_IR_AFTER_REFCOUNT, ROC_PRINT_IR_AFTER_RESET_REUSE,
|
||||
ROC_PRINT_IR_AFTER_SPECIALIZATION,
|
||||
};
|
||||
use roc_exhaustive::{Ctor, CtorName, Guard, RenderAs, TagId};
|
||||
use roc_module::ident::{ForeignSymbol, Lowercase, TagName};
|
||||
use roc_module::low_level::LowLevel;
|
||||
|
@ -28,7 +31,13 @@ use ven_pretty::{BoxAllocator, DocAllocator, DocBuilder};
|
|||
|
||||
#[inline(always)]
|
||||
pub fn pretty_print_ir_symbols() -> bool {
|
||||
dbg_do!(ROC_PRETTY_PRINT_IR_SYMBOLS, {
|
||||
dbg_do!(ROC_PRINT_IR_AFTER_SPECIALIZATION, {
|
||||
return true;
|
||||
});
|
||||
dbg_do!(ROC_PRINT_IR_AFTER_RESET_REUSE, {
|
||||
return true;
|
||||
});
|
||||
dbg_do!(ROC_PRINT_IR_AFTER_REFCOUNT, {
|
||||
return true;
|
||||
});
|
||||
false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue