Skip to content

Use mangled name for intrinsic symbols #85

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 12 commits into
base: master
Choose a base branch
from
Draft

Conversation

ehildenb
Copy link
Member

No description provided.

@ehildenb ehildenb self-assigned this May 23, 2025
src/printer.rs Outdated
Comment on lines 415 to 416
} else if let Some(intrinsic_name) = inst.intrinsic_name() {
IntrinsicSym(intrinsic_name)
} else if let Some(_intrinsic_name) = inst.intrinsic_name() {
IntrinsicSym(inst.mangled_name())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we are trying to dump the mangled name of the intrinsics instead of just the short name.

"IntrinsicSym": "black_box"
"IntrinsicSym": "_ZN4core10intrinsics9black_box17h422cafb34137ccebE"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the change that dumping the mangled name makes.

Comment on lines +1 to +21
fn main() {
checked_add_i32(1,2);
}

/// If the precondition is not met, the program is not executed (exits cleanly, ex falso quodlibet)
macro_rules! precondition {
($pre:expr, $block:expr) => {
if $pre { $block }
};
}

fn checked_add_i32(a: i32, b: i32) {

precondition!(
a.checked_add(b).is_some(),
unsafe {
let result = a.unchecked_add(b);
assert!(result as i64 == a as i64 + b as i64)
}
);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Example we are trying.

Comment on lines 177 to 181
[
{
"IntrinsicSym": "_ZN4core10intrinsics9cold_path17hf51dae334946aea4E"
}
],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we have the symbol name for cold_path dumped.

Comment on lines 1852 to 1880
"MonoItemFn": {
"body": {
"arg_count": 0,
"blocks": [
{
"statements": [],
"terminator": {
"kind": "Return",
"span": 43
}
}
],
"locals": [
{
"mutability": "Mut",
"span": 44,
"ty": 1
}
],
"span": 45,
"spread_arg": null,
"var_debug_info": []
},
"id": 3,
"name": "std::intrinsics::cold_path"
}
},
"symbol_name": "_ZN4core10intrinsics9cold_path17h"
},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here is the implementation we are missing when loading into the KMIR state (even though it's here), because the last 20 characters (some sort of hash) do not match.

In this golden/expected file, this is truncated (missing the last 20 characters), because the output is non-deterministic.

How should we be looking up the needed MonoItemFn to execute this IntrinsicSym? Should it just be comparing the first 30 characters?

@ehildenb ehildenb force-pushed the cold-path-intrinsic branch from e290eca to e3ecb71 Compare May 23, 2025 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants