Emit cold inline asm marker for cold_path intrinsic in LLVM backend#155272
Emit cold inline asm marker for cold_path intrinsic in LLVM backend#155272Redslayer112 wants to merge 1 commit intorust-lang:mainfrom
Conversation
The cold_path intrinsic was a no-op in the SSA layer, which meant LLVM never saw any cold hint in blocks reached through generic FnOnce::call_once boundaries. The !prof metadata emitted by find_cold_blocks was dropped by LLVM's InlinerPass when folding redundant PHI+branch patterns. This patch removes the SSA-level no-op for cold_path and adds an LLVM-specific handler that emits "asm sideeffect" with a "cold" call-site attribute. The sideeffect flag prevents any LLVM pass from removing the marker, while the cold attribute lets BranchProbabilityInfo mark the containing block as unlikely. The empty asm string produces zero machine instructions. Fixes rust-lang#155263
|
r? @nnethercote rustbot has assigned @nnethercote. Use Why was this reviewer chosen?The reviewer was selected based on:
|
|
|
The job Click to see the possible cause of the failure (guessed by this bot) |
| sym::cold_path => { | ||
| // This is a no-op. The intrinsic is just a hint to the optimizer. | ||
| return Ok(()); | ||
| } |
There was a problem hiding this comment.
I am closing this as per rust-lang/compiler-team#893.
|
@Redslayer112 This is the moderation team of the Rust project. It looks like you used an LLM without reviewing its output sufficiently. This is against our contribution guidelines, it makes reviewing patches a lot of work for us. If you would like some help with that, please ensure you're familiar with our contribution guidelines, specifically our etiquette and feel free to either reach out to moderation or ask on the Zulip stream for general help from other contributors. |
The cold_path intrinsic was a no-op in the SSA layer, which meant LLVM never saw any cold hint in blocks reached through generic FnOnce::call_once boundaries. The !prof metadata emitted by find_cold_blocks was dropped by LLVM's InlinerPass when folding redundant PHI+branch patterns.
This patch removes the SSA-level no-op for cold_path and adds an LLVM-specific handler that emits "asm sideeffect" with a "cold" call-site attribute. The sideeffect flag prevents any LLVM pass from removing the marker, while the cold attribute lets BranchProbabilityInfo mark the containing block as unlikely. The empty asm string produces zero machine instructions.
Fixes #155263
Testing
tests/codegen-llvm/hint/cold_path_propagation.rsregression testcold_path.rstest continues to passset_cold_blockhandler)