4

Put checks that detect UB under their own flag below debug_assertions by saethli...

 1 month ago
source link: https://github.com/rust-lang/rust/pull/123411
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Member

saethlin

commented

Apr 3, 2024

edited by RalfJung

rustbot

added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

labels

Apr 3, 2024

Collaborator

The Miri subtree was changed

cc @rust-lang/miri

Some changes occurred in compiler/rustc_codegen_cranelift

cc @bjorn3

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Comment on lines

17 to 21

// CHECK-NEXT: start:

// CHECK-NEXT: icmp ult

// CHECK-NEXT: tail call void @llvm.assume

// CHECK-NEXT: getelementptr inbounds

// CHECK-NEXT: ret ptr

Member

Author

@scottmcm Can you offer some advice on the right way to write this test? I'm not sure how exact I should be matching against the IR.

Maybe use revisions to put tests for the presence and the absence in the same file? For inspiration, maybe look at this file, where it checks the different codegen for OPT0 and OPT3 -- you could do the same kind of thing for UB-checks on and off:

And if the NOUBCHECK-NOT negative check is right next to the YESUBCHECK positive check for the same thing, it's way more likely that the negative test is actually doing something meaningful.

Maybe you can also check things like that the assume optimizes out when the ub-check is on, because it ends up unneeded as the dominating branch checks the same thing?


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK