Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 9b4768a

Browse files
committed
Auto merge of rust-lang#127740 - DianQK:assume-false, r=<try>
Emit `assume(false)` as `store i1 true, ptr poison, align 1` Store to poison is the canonical form for non-terminator unreachable. r? ghost
2 parents d9284af + ecd7d6e commit 9b4768a

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

compiler/rustc_codegen_llvm/src/intrinsic.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,19 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
566566
}
567567

568568
fn assume(&mut self, val: Self::Value) {
569-
self.call_intrinsic("llvm.assume", &[val]);
569+
match self.const_to_opt_uint(val) {
570+
Some(0) => {
571+
self.store(
572+
self.const_bool(true),
573+
self.const_poison(self.type_ptr()),
574+
self.tcx().data_layout.i1_align.abi,
575+
);
576+
}
577+
Some(_) => {}
578+
None => {
579+
self.call_intrinsic("llvm.assume", &[val]);
580+
}
581+
}
570582
}
571583

572584
fn expect(&mut self, cond: Self::Value, expected: bool) -> Self::Value {

0 commit comments

Comments
 (0)