Comments (6)
I only see a single call to panic_fmt
in the linked godbolt code. This is inside the _unreachable()
function, which is never called, but still codegened as it is referenced from a public inlineable function (BytesVector::push
) and thus could be referenced if optimizations are disabled for another crate which calls BytesVector::push
. If you were to compile it as executable instead of as library (godbolt always compiles as library), then it would be removed after optimizations. Now it merely gets removed during linking due to --gc-sections
.
from rust.
Probably a LLVM thing? cc @nikic
from rust.
Doesn't reproduce on play.rust-lang.org (release, 1.78.0-nightly) with main function added.
https://play.rust-lang.org/?version=nightly&mode=release&edition=2021&gist=41cee2ecbe0b343ff62b46424ee0e0af
alloc::raw_vec::RawVec<T,A>::reserve::do_reserve_and_handle:
# ...
.LBB6_8:
callq *alloc::raw_vec::capacity_overflow@GOTPCREL(%rip)
.LBB6_6:
movq 24(%rsp), %rsi
callq *alloc::alloc::handle_alloc_error@GOTPCREL(%rip)
# -- End function
playground::foo: # @playground::foo
# %bb.0:
pushq %rbx
movq (%rdi), %rax
movq 16(%rdi), %rsi
subq %rsi, %rax
cmpq $1, %rax
jbe .LBB7_1
.LBB7_2:
movq 8(%rdi), %rax
movw $256, (%rax,%rsi) # imm = 0x100
addq $2, %rsi
movq %rsi, 16(%rdi)
popq %rbx
retq
.LBB7_1:
movq %rdi, %rbx
callq alloc::raw_vec::RawVec<T,A>::reserve::do_reserve_and_handle
movq %rbx, %rdi
movq 16(%rbx), %rsi
jmp .LBB7_2
# -- End function
playground::main: # @playground::main
# ...
from rust.
@rustbot +requires-nightly
from rust.
but still codegened as it is referenced from a public inlineable function
Oh... That makes sense... I guess a local literal panic!
in push
won't be generated because it is in the standard library?!
Still not sure why #[inline] const fn _unreachable() -> ! { ... }
isn't also generated but it probably isn't a problem with LLVM!?
from rust.
OK, thanks @bjorn3 and @ProgramCrafter
from rust.
Related Issues (20)
- ice: `error was constructed but not emitted` HOT 3
- Add `erf` and friends from `libm` ? HOT 1
- Implement collect_with_capacity for Iter? HOT 3
- Tracking Issue for Packages as (optional) namespaces HOT 9
- Large number of variables causes stack overflow (SIGSEGV) HOT 2
- Improve dead_code lint to detect unused structs which implement private traits HOT 3
- stack overflow HOT 1
- `x build unstable-book` is too lazy and doesn't reflect subsequent edits HOT 1
- `unused_qualifications` warns about global paths
- portable_simd bitmask + select generates poor code on ARM64 HOT 1
- cargo build crash HOT 3
- TAIT regression on nightly-2024-03-12 HOT 2
- on_unimplemented format strings either error or warn or ignore various formatting issues HOT 2
- Wrong suggestion for const well-formedness of bool HOT 3
- const-eval: perform validation before interning
- ICE: hir: `index out of bounds: the len is 5 but the index is 5` HOT 6
- `let else` not suggested for refutable let patterns. HOT 5
- `-Zthreads` causes cycle errors in previously passing code HOT 3
- Rust is hard :( HOT 2
- cannot compile rust project offline using nightly toolchain HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rust.