diff options
| author | Scott McMurray <scottmcm@users.noreply.github.com> | 2025-07-10 09:17:28 -0700 |
|---|---|---|
| committer | Scott McMurray <scottmcm@users.noreply.github.com> | 2025-07-10 09:17:28 -0700 |
| commit | f5fc8727dbbf8c9e93bb0822b2e5bfa77dbd0208 (patch) | |
| tree | 2842ed4a91fdced7c7697a575f63b0e8ba9c2d3c /compiler/rustc_codegen_ssa/src/traits/builder.rs | |
| parent | 58d7c2d5a760c1adfa4c3984eeb12787f5ad5b1d (diff) | |
| download | rust-f5fc8727dbbf8c9e93bb0822b2e5bfa77dbd0208.tar.gz rust-f5fc8727dbbf8c9e93bb0822b2e5bfa77dbd0208.zip | |
Add `BuilderMethods::unreachable_nonterminator`
So places that need `unreachable` but in the middle of a basic block can call that instead of figuring out the best way to do it.
Diffstat (limited to 'compiler/rustc_codegen_ssa/src/traits/builder.rs')
| -rw-r--r-- | compiler/rustc_codegen_ssa/src/traits/builder.rs | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/rustc_codegen_ssa/src/traits/builder.rs b/compiler/rustc_codegen_ssa/src/traits/builder.rs index 9d367748c2a..0f1358ee508 100644 --- a/compiler/rustc_codegen_ssa/src/traits/builder.rs +++ b/compiler/rustc_codegen_ssa/src/traits/builder.rs @@ -136,6 +136,16 @@ pub trait BuilderMethods<'a, 'tcx>: ) -> Self::Value; fn unreachable(&mut self); + /// Like [`Self::unreachable`], but for use in the middle of a basic block. + fn unreachable_nonterminator(&mut self) { + // This is the preferred LLVM incantation for this per + // https://llvm.org/docs/Frontend/PerformanceTips.html#other-things-to-consider + // Other backends may override if they have a better way. + let const_true = self.cx().const_bool(true); + let poison_ptr = self.const_poison(self.cx().type_ptr()); + self.store(const_true, poison_ptr, Align::ONE); + } + fn add(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; fn fadd(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; fn fadd_fast(&mut self, lhs: Self::Value, rhs: Self::Value) -> Self::Value; |
