-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Auto merge of #117503 - kornelski:hint-try-reserved, r=<try>
Hint optimizer about try-reserved capacity This is #116568, but limited only to the less-common `try_reserve` functions to reduce bloat in debug binaries from debug info, while still addressing the main use-case #116570
- Loading branch information
Showing
3 changed files
with
29 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// compile-flags: -O | ||
|
||
#![crate_type = "lib"] | ||
|
||
// CHECK-LABEL: @should_reserve_once | ||
#[no_mangle] | ||
pub fn should_reserve_once(v: &mut Vec<u8>) { | ||
// CHECK: tail call void @llvm.assume | ||
v.try_reserve(3).unwrap(); | ||
// CHECK-NOT: call {{.*}}reserve | ||
// CHECK-NOT: call {{.*}}do_reserve_and_handle | ||
// CHECK-NOT: call {{.*}}__rust_alloc( | ||
v.extend([1, 2, 3]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
thread 'main' panicked at library/alloc/src/raw_vec.rs:535:5: | ||
thread 'main' panicked at library/alloc/src/raw_vec.rs:545:5: | ||
capacity overflow | ||
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace |