Skip to content

Instantly share code, notes, and snippets.

View saethlin's full-sized avatar
🦀

Ben Kimock saethlin

🦀
View GitHub Profile
@saethlin
saethlin / reduced.ll
Created August 19, 2023 22:44
Reduced LLVM reproducer for "conflicting locations for variable" assertion
; ModuleID = 'reduced.bc'
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
define void @_ZN8scratch211find_frames17hd54c2d9c7be04b4aE() !dbg !16 {
%1 = alloca { ptr, ptr, i64 }, i32 0, align 8
%2 = alloca [7 x i8], i32 0, align 1
call void @llvm.dbg.declare(metadata ptr %2, metadata !20, metadata !DIExpression(DW_OP_LLVM_fragment, 456, 56)), !dbg !25
call void @llvm.dbg.declare(metadata ptr %1, metadata !20, metadata !DIExpression()), !dbg !25
store i64 0, ptr null, align 8, !dbg !26
@saethlin
saethlin / mir-opts.md
Last active May 23, 2023 22:34
Summary of the effect of MIR opts
Pass PR Check avg% Debug avg% Opt avg% Range Regressions / Improvements
Inline rust-lang/rust#111782 -0.39% +1.55% +3.44% -19.21%, +72.56% 173/184
SimplifyCfg rust-lang/rust#111783 +0.33% +0.43% +0.41% -1.65%, +2.63% 236/9
CopyProp rust-lang/rust#111784 +0.61% +1.65% +2.08% -0.93%, +7.23% 276/8
InstSimplify rust-lang/rust#111785 +0.28% +0.46% +0.52% -0.67%, +4.60% 188/8
LowerSliceLenCalls rust-lang/rust#111786 +0.38% +1.03% +1.18% -0.75%, +4.55% 26/5
UninhabitedEnumBranching rust-lang/rust#111787 -0.03% -0.05% -0.05% 0.00%,0.00% 0/0
RemoveStorageMarkers rust-lang/rust#111788 +0.03% +0.53% -0.04% -1.18%, +3.22% 70/1
RemoveZsts ht
fn slice_iter_next(_1: &mut std::slice::Iter<'_, u8>) -> Option<&u8> {
debug it => _1; // in scope 0 at src/main.rs:8:28: 8:30
let mut _0: std::option::Option<&u8>; // return place in scope 0 at src/main.rs:8:66: 8:80
scope 1 (inlined <std::slice::Iter<'_, u8> as Iterator>::next) { // at src/main.rs:9:8: 9:14
debug self => _1; // in scope 1 at /home/ben/rust/library/core/src/slice/iter/macros.rs:126:21: 126:30
let mut _2: *const u8; // in scope 1 at /home/ben/rust/library/core/src/slice/iter/macros.rs:135:41: 135:49
let mut _3: bool; // in scope 1 at /home/ben/rust/library/core/src/slice/iter/macros.rs:8:9: 8:46
let mut _4: *const u8; // in scope 1 at /home/ben/rust/library/core/src/slice/iter/macros.rs:8:9: 8:33
let mut _5: std::ptr::NonNull<u8>; // in scope 1 at /home/ben/rust/library/core/src/slice/iter/macros.rs:8:9: 8:18
let mut _6: *const u8; // in scope 1 at /home
@saethlin
saethlin / encoded-integer-bit-lengths
Created April 15, 2023 15:54
Distribution of the number of used bits in unsigned integers encoded by a stage2+incremental rustc build
( 1) 136080869 (17.6%, 17.6%): 0
( 2) 87979291 (11.4%, 28.9%): 1
( 3) 47832545 ( 6.2%, 35.1%): 19
( 4) 46289353 ( 6.0%, 41.1%): 2
( 5) 44090173 ( 5.7%, 46.8%): 18
( 6) 39202406 ( 5.1%, 51.8%): 20
( 7) 38849448 ( 5.0%, 56.8%): 3
( 8) 31629246 ( 4.1%, 60.9%): 17
( 9) 30776739 ( 4.0%, 64.9%): 16
( 10) 30372289 ( 3.9%, 68.8%): 8
@saethlin
saethlin / core-f9e13466efafd2d3.mir
Created January 10, 2023 14:20
ptr::read MIR for Rust 1.66
fn ptr::read(_1: *const T) -> T {
debug src => _1; // in scope 0 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1119:29: 1119:32
let mut _0: T; // return place in scope 0 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1119:47: 1119:48
let mut _2: mem::maybe_uninit::MaybeUninit<T>; // in scope 0 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1127:9: 1127:16
let mut _3: *const T; // in scope 0 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1139:29: 1139:32
let mut _4: *mut T; // in scope 0 at /home/ben/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:1139:34: 1139:50
let mut _5: &mut mem::maybe_uninit::May
diplomatic-bag 0.3.1
rsspls 0.3.0
rafx-base 0.0.15
steamguard 0.5.0
scope-guard 1.1.0
component_group 3.0.0
boilerpipe 0.6.0
symbol-map 1.0.2
ouroboros_examples 0.15.5
tokio-linux-aio 0.1.11
@saethlin
saethlin / gist:7337b32a82d352659ed758a0ecded69d
Created October 13, 2022 04:26
Crates with tests that report UB with -Zmiri-retag-fields
spin 0.9.4
criterion 0.4.0
alloc-stdlib 0.2.2
widestring 1.0.2
ouroboros 0.15.5
deadpool 0.9.5
num-format 0.4.3
cbc 0.1.2
glib 0.15.12
clear_on_drop 0.2.5
test test_cancellations ... error: Undefined Behavior: not granting access to tag <4173394> because incompatible item [Unique for <4173405>] is protected by call 1061456
--> /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/core/src/sync/atomic.rs:2964:24
|
2964 | Acquire => intrinsics::atomic_load_acquire(dst),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not granting access to tag <4173394> because incompatible item [Unique for <4173405>] is protected by call 1061456
|
= help: this indicates a potential bug in the program: it performed an invalid operation, but the Stacked Borrows rules it violated are still experimental
= help: see https://github.com/rust-lang/unsafe-code-guidelines/blob/master/wip/stacked-borrows.md for further information
help: <4173394> was created by a SharedReadWrite retag at offsets [0x1c..0x1e]
--> /home/ben/.rustup/toolchains/miri/lib/rustlib/src/rust/library/std/src/sys/unix/thread.rs:108:17
; Inspecting 6062 Redis values
; Discarding 3506 not-optimizations leaving 154 optimizations
%0:i1 = var
%1:i64 = select %0, 1:i64, 0:i64
infer %1
%2:i64 = zext %0
result %2
This file has been truncated, but you can view the full file.
<%0 = block 12
%1:i1 = phi %0, 0:i1, 0:i1, 0:i1, 0:i1, 0:i1, 0:i1, 0:i1, 0:i1, 0:i1, 0:i1, 1:i1, 1:i1
%2:i64 = phi %0, 0:i64, 1:i64, 2:i64, 3:i64, 4:i64, 5:i64, 6:i64, 7:i64, 8:i64, 9:i64, 10:i64, 11:i64
%3:i64 = addnw 4294967284:i64, %2
%4:i64 = select %1, %3, %2
%5:i32 = trunc %4
%6:i32 = add 2:i32, %5
infer %6
>
<noinfer> <>