@@ -275,6 +275,9 @@ static cl::opt<bool>
275275 DisableDeletePHIs (" disable-cgp-delete-phis" , cl::Hidden, cl::init(false ),
276276 cl::desc(" Disable elimination of dead PHI nodes." ));
277277
278+ namespace llvm {
279+ extern cl::opt<bool > ProfcheckDisableMetadataFixes;
280+ }
278281namespace {
279282
280283enum ExtType {
@@ -7450,7 +7453,12 @@ bool CodeGenPrepare::optimizeShiftInst(BinaryOperator *Shift) {
74507453 BinaryOperator::BinaryOps Opcode = Shift->getOpcode ();
74517454 Value *NewTVal = Builder.CreateBinOp (Opcode, Shift->getOperand (0 ), TVal);
74527455 Value *NewFVal = Builder.CreateBinOp (Opcode, Shift->getOperand (0 ), FVal);
7453- Value *NewSel = Builder.CreateSelect (Cond, NewTVal, NewFVal);
7456+ Value *NewSel =
7457+ Builder.CreateSelect (Cond, NewTVal, NewFVal, /* Name=*/ " " ,
7458+ /* MDFrom=*/
7459+ ProfcheckDisableMetadataFixes
7460+ ? nullptr
7461+ : dyn_cast<Instruction>(Shift->getOperand (1 )));
74547462 replaceAllUsesWith (Shift, NewSel, FreshBBs, IsHugeFunc);
74557463 Shift->eraseFromParent ();
74567464 return true ;
@@ -7485,7 +7493,12 @@ bool CodeGenPrepare::optimizeFunnelShift(IntrinsicInst *Fsh) {
74857493 Value *X = Fsh->getOperand (0 ), *Y = Fsh->getOperand (1 );
74867494 Value *NewTVal = Builder.CreateIntrinsic (Opcode, Ty, {X, Y, TVal});
74877495 Value *NewFVal = Builder.CreateIntrinsic (Opcode, Ty, {X, Y, FVal});
7488- Value *NewSel = Builder.CreateSelect (Cond, NewTVal, NewFVal);
7496+ Value *NewSel =
7497+ Builder.CreateSelect (Cond, NewTVal, NewFVal, /* Name=*/ " " ,
7498+ /* MDFrom=*/
7499+ ProfcheckDisableMetadataFixes
7500+ ? nullptr
7501+ : dyn_cast<Instruction>(Fsh->getOperand (2 )));
74897502 replaceAllUsesWith (Fsh, NewSel, FreshBBs, IsHugeFunc);
74907503 Fsh->eraseFromParent ();
74917504 return true ;
0 commit comments