@@ -470,15 +470,24 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
470470 Value *simplifyNonNullOperand (Value *V, bool HasDereferenceable,
471471 unsigned Depth = 0 );
472472
473+ // / Create `select C, S1, S2` and copy metadata from MDFrom.
473474 SelectInst *createSelectInst (Value *C, Value *S1, Value *S2,
475+ const Instruction &MDFrom,
474476 const Twine &NameStr = " " ,
475- InsertPosition InsertBefore = nullptr ,
476- Instruction *MDFrom = nullptr ) {
477- SelectInst *SI =
478- SelectInst::Create (C, S1, S2, NameStr, InsertBefore, MDFrom);
479- if (!MDFrom)
480- setExplicitlyUnknownBranchWeightsIfProfiled (*SI, F, DEBUG_TYPE);
481- return SI;
477+ InsertPosition InsertBefore = nullptr ) {
478+ return SelectInst::Create (C, S1, S2, NameStr, InsertBefore, &MDFrom);
479+ }
480+
481+ // / Use instead of createSelectInst if the profile cannot be calculated from
482+ // / existing profile metadata. If the Function has profiles, set the profile
483+ // / of this select to "unknown".
484+ SelectInst *
485+ createSelectInstWithUnknownProfile (Value *C, Value *S1, Value *S2,
486+ const Twine &NameStr = " " ,
487+ InsertPosition InsertBefore = nullptr ) {
488+ auto *Sel = SelectInst::Create (C, S1, S2, NameStr, InsertBefore, nullptr );
489+ setExplicitlyUnknownBranchWeightsIfProfiled (*Sel, F, DEBUG_TYPE);
490+ return Sel;
482491 }
483492
484493public:
0 commit comments