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
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/printer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,8 @@ fn fn_inst_sym<'tcx>(
let internal_inst = rustc_internal::internal(tcx, inst);
let sym_type = if inst.is_empty_shim() {
NoOpSym(String::from(""))
} 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.

} else {
NormalSym(inst.mangled_name())
};
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/programs/assert_eq.smir.json.expected
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
],
[
{
"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.

}
],
[
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/programs/binop.smir.json.expected
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,7 @@
],
[
{
"IntrinsicSym": "black_box"
"IntrinsicSym": "_ZN4core10intrinsics9black_box17h241585995e0a474bE"
}
],
[
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/programs/char-trivial.smir.json.expected
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
],
[
{
"IntrinsicSym": "black_box"
"IntrinsicSym": "_ZN4core10intrinsics9black_box17ha16ea91007d49fe5E"
}
],
[
Expand Down
21 changes: 21 additions & 0 deletions tests/integration/programs/checked_arithmetic.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,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)
}
);
}
Comment on lines +1 to +21
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.

Loading
Loading