Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions llvm/lib/Transforms/Scalar/JumpThreading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2789,6 +2789,13 @@ void JumpThreadingPass::unfoldSelectInstr(BasicBlock *Pred, BasicBlock *BB,
PredTerm->removeFromParent();
PredTerm->insertInto(NewBB, NewBB->end());
// Create a conditional branch and update PHI nodes.
//
// Note: Technically we should `freeze` the condition before using it in a
// conditional branch, unless we can prove it's not poison: select-on-on
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/select-on-on/select-on-poison?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See that's what I get when I don't have an LLM write my code. :D

// poison isn't UB, but branch-on-poison is. But doing this causes
// performance regressions, and we haven't been able to find a source-level
// correctness issue it fixes. See
// https://github.com/llvm/llvm-project/pull/199408#issuecomment-4545013881.
auto *BI = CondBrInst::Create(SI->getCondition(), NewBB, BB, Pred);
BI->applyMergedLocation(PredTerm->getDebugLoc(), SI->getDebugLoc());
BI->copyMetadata(*SI, {LLVMContext::MD_prof});
Expand Down