mirror of
https://github.com/Noratrieb/rlo-issue-112061.git
synced 2026-01-14 16:35:04 +01:00
more
This commit is contained in:
parent
3e1215e870
commit
096d0e78ac
6 changed files with 44 additions and 10 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
|
@ -1,5 +1,8 @@
|
||||||
/good
|
/good
|
||||||
/bad
|
/bad
|
||||||
|
*.ll
|
||||||
|
*.s
|
||||||
|
a.out
|
||||||
|
|
||||||
# Added by cargo
|
# Added by cargo
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ edition = "2021"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[[bin]]
|
[lib]
|
||||||
name = "code"
|
name = "code"
|
||||||
path = "./code.rs"
|
path = "./code.rs"
|
||||||
|
|
||||||
|
|
|
||||||
4
check.sh
4
check.sh
|
|
@ -1,7 +1,7 @@
|
||||||
#/usr/bin/env bash
|
#/usr/bin/env bash
|
||||||
|
|
||||||
rustc code.rs --crate-name bad -Zmir-enable-passes=-ConstProp -Copt-level=3
|
rustc code.rs --crate-name bad -Zmir-enable-passes=-ConstProp -Copt-level=3 --cfg pure_rust
|
||||||
rustc code.rs --crate-name good -Zmir-enable-passes=+ConstProp -Copt-level=3
|
rustc code.rs --crate-name good -Zmir-enable-passes=+ConstProp -Copt-level=3 --cfg pure_rust
|
||||||
|
|
||||||
bad=$(./bad)
|
bad=$(./bad)
|
||||||
good=$(./good)
|
good=$(./good)
|
||||||
|
|
|
||||||
7
checkllvm.sh
Executable file
7
checkllvm.sh
Executable file
|
|
@ -0,0 +1,7 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
rustc code.rs --crate-name ll -Zmir-enable-passes=-ConstProp --emit llvm-ir -Cno-prepopulate-passes --crate-type=lib
|
||||||
|
|
||||||
|
clang ll.ll helper.c
|
||||||
|
|
||||||
|
./a.out
|
||||||
24
code.rs
24
code.rs
|
|
@ -1,9 +1,18 @@
|
||||||
use std::ptr;
|
use std::ptr;
|
||||||
#[inline(never)]
|
|
||||||
pub fn print_var(v: u8) {
|
extern "C" {
|
||||||
println!("{v}");
|
pub fn print_var(v: u8);
|
||||||
}
|
}
|
||||||
pub unsafe fn fn12_rs() {
|
#[cfg(pure_rust)]
|
||||||
|
mod impl_ {
|
||||||
|
#[no_mangle]
|
||||||
|
pub extern "C" fn print_var(v: u8) {
|
||||||
|
println!("{v}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[no_mangle]
|
||||||
|
pub unsafe extern "C" fn fn12_rs() {
|
||||||
let mut bool_storage: bool = false;
|
let mut bool_storage: bool = false;
|
||||||
let mut v9: usize = 0;
|
let mut v9: usize = 0;
|
||||||
|
|
||||||
|
|
@ -12,7 +21,8 @@ pub unsafe fn fn12_rs() {
|
||||||
let v20_ptr = ptr::addr_of_mut!(v20);
|
let v20_ptr = ptr::addr_of_mut!(v20);
|
||||||
let mut v12: *mut u8 = core::ptr::addr_of_mut!((*v20_ptr)[v9]);
|
let mut v12: *mut u8 = core::ptr::addr_of_mut!((*v20_ptr)[v9]);
|
||||||
v9 = 2_usize; // unused but necessary write
|
v9 = 2_usize; // unused but necessary write
|
||||||
loop { // only runs once, but necessary
|
loop {
|
||||||
|
// only runs once, but necessary
|
||||||
match *v12 {
|
match *v12 {
|
||||||
197 => {
|
197 => {
|
||||||
let mut match_condition: u64 = 0;
|
let mut match_condition: u64 = 0;
|
||||||
|
|
@ -60,7 +70,9 @@ pub unsafe fn fn12_rs() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn main() {
|
|
||||||
|
#[cfg(pure_rust)]
|
||||||
|
fn main() {
|
||||||
unsafe {
|
unsafe {
|
||||||
fn12_rs();
|
fn12_rs();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
12
helper.c
Normal file
12
helper.c
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
void print_var(uint8_t x) {
|
||||||
|
printf("%d", x);
|
||||||
|
}
|
||||||
|
|
||||||
|
void fn12_rs();
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
fn12_rs();
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue