[llvm] [WIP][profcheck] Codegen Prepare (PR #166857)
Mircea Trofin via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 2 14:45:05 PST 2025
https://github.com/mtrofin updated https://github.com/llvm/llvm-project/pull/166857
>From eeaae0a0db2e107cc6c2ac6e294d96ce464feda4 Mon Sep 17 00:00:00 2001
From: Mircea Trofin <mtrofin at google.com>
Date: Mon, 6 Oct 2025 17:54:52 -0700
Subject: [PATCH] [WIP][profcheck] Codegen Prepare
---
llvm/lib/CodeGen/CodeGenPrepare.cpp | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index 587c1372b19cb..fd8360cc4f0e9 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -275,6 +275,9 @@ static cl::opt<bool>
DisableDeletePHIs("disable-cgp-delete-phis", cl::Hidden, cl::init(false),
cl::desc("Disable elimination of dead PHI nodes."));
+namespace llvm {
+extern cl::opt<bool> ProfcheckDisableMetadataFixes;
+}
namespace {
enum ExtType {
@@ -7645,7 +7648,12 @@ bool CodeGenPrepare::optimizeShiftInst(BinaryOperator *Shift) {
BinaryOperator::BinaryOps Opcode = Shift->getOpcode();
Value *NewTVal = Builder.CreateBinOp(Opcode, Shift->getOperand(0), TVal);
Value *NewFVal = Builder.CreateBinOp(Opcode, Shift->getOperand(0), FVal);
- Value *NewSel = Builder.CreateSelect(Cond, NewTVal, NewFVal);
+ Value *NewSel =
+ Builder.CreateSelect(Cond, NewTVal, NewFVal, /*Name=*/"",
+ /*MDFrom=*/
+ ProfcheckDisableMetadataFixes
+ ? nullptr
+ : dyn_cast<Instruction>(Shift->getOperand(1)));
replaceAllUsesWith(Shift, NewSel, FreshBBs, IsHugeFunc);
Shift->eraseFromParent();
return true;
@@ -7680,7 +7688,12 @@ bool CodeGenPrepare::optimizeFunnelShift(IntrinsicInst *Fsh) {
Value *X = Fsh->getOperand(0), *Y = Fsh->getOperand(1);
Value *NewTVal = Builder.CreateIntrinsic(Opcode, Ty, {X, Y, TVal});
Value *NewFVal = Builder.CreateIntrinsic(Opcode, Ty, {X, Y, FVal});
- Value *NewSel = Builder.CreateSelect(Cond, NewTVal, NewFVal);
+ Value *NewSel =
+ Builder.CreateSelect(Cond, NewTVal, NewFVal, /*Name=*/"",
+ /*MDFrom=*/
+ ProfcheckDisableMetadataFixes
+ ? nullptr
+ : dyn_cast<Instruction>(Fsh->getOperand(2)));
replaceAllUsesWith(Fsh, NewSel, FreshBBs, IsHugeFunc);
Fsh->eraseFromParent();
return true;
More information about the llvm-commits
mailing list