@@ -709,13 +709,18 @@ class VPRecipeBase : public ilist_node_with_parent<VPRecipeBase, VPBasicBlock>,
709709 // / Each VPRecipe belongs to a single VPBasicBlock.
710710 VPBasicBlock *Parent = nullptr ;
711711
712+ // / The debug location for the recipe.
713+ DebugLoc DL;
714+
712715public:
713- VPRecipeBase (const unsigned char SC, ArrayRef<VPValue *> Operands)
714- : VPDef(SC), VPUser(Operands, VPUser::VPUserID::Recipe) {}
716+ VPRecipeBase (const unsigned char SC, ArrayRef<VPValue *> Operands,
717+ DebugLoc DL = {})
718+ : VPDef(SC), VPUser(Operands, VPUser::VPUserID::Recipe), DL(DL) {}
715719
716720 template <typename IterT>
717- VPRecipeBase (const unsigned char SC, iterator_range<IterT> Operands)
718- : VPDef(SC), VPUser(Operands, VPUser::VPUserID::Recipe) {}
721+ VPRecipeBase (const unsigned char SC, iterator_range<IterT> Operands,
722+ DebugLoc DL = {})
723+ : VPDef(SC), VPUser(Operands, VPUser::VPUserID::Recipe), DL(DL) {}
719724 virtual ~VPRecipeBase () = default ;
720725
721726 // / \return the VPBasicBlock which this VPRecipe belongs to.
@@ -792,6 +797,9 @@ class VPRecipeBase : public ilist_node_with_parent<VPRecipeBase, VPBasicBlock>,
792797 bool mayReadOrWriteMemory () const {
793798 return mayReadFromMemory () || mayWriteToMemory ();
794799 }
800+
801+ // / Returns the debug location of the recipe.
802+ DebugLoc getDebugLoc () const { return DL; }
795803};
796804
797805// Helper macro to define common classof implementations for recipes.
@@ -862,15 +870,15 @@ class VPRecipeWithIRFlags : public VPRecipeBase {
862870
863871public:
864872 template <typename IterT>
865- VPRecipeWithIRFlags (const unsigned char SC, IterT Operands)
866- : VPRecipeBase(SC, Operands) {
873+ VPRecipeWithIRFlags (const unsigned char SC, IterT Operands, DebugLoc DL = {} )
874+ : VPRecipeBase(SC, Operands, DL ) {
867875 OpType = OperationType::Other;
868876 AllFlags = 0 ;
869877 }
870878
871879 template <typename IterT>
872880 VPRecipeWithIRFlags (const unsigned char SC, IterT Operands, Instruction &I)
873- : VPRecipeWithIRFlags(SC, Operands) {
881+ : VPRecipeWithIRFlags(SC, Operands, I.getDebugLoc() ) {
874882 if (auto *Op = dyn_cast<CmpInst>(&I)) {
875883 OpType = OperationType::Cmp;
876884 CmpPredicate = Op->getPredicate ();
@@ -891,20 +899,20 @@ class VPRecipeWithIRFlags : public VPRecipeBase {
891899
892900 template <typename IterT>
893901 VPRecipeWithIRFlags (const unsigned char SC, IterT Operands,
894- CmpInst::Predicate Pred)
895- : VPRecipeBase(SC, Operands), OpType(OperationType::Cmp),
902+ CmpInst::Predicate Pred, DebugLoc DL = {} )
903+ : VPRecipeBase(SC, Operands, DL ), OpType(OperationType::Cmp),
896904 CmpPredicate (Pred) {}
897905
898906 template <typename IterT>
899907 VPRecipeWithIRFlags (const unsigned char SC, IterT Operands,
900- WrapFlagsTy WrapFlags)
901- : VPRecipeBase(SC, Operands), OpType(OperationType::OverflowingBinOp),
908+ WrapFlagsTy WrapFlags, DebugLoc DL = {} )
909+ : VPRecipeBase(SC, Operands, DL ), OpType(OperationType::OverflowingBinOp),
902910 WrapFlags(WrapFlags) {}
903911
904912 template <typename IterT>
905913 VPRecipeWithIRFlags (const unsigned char SC, IterT Operands,
906- FastMathFlags FMFs)
907- : VPRecipeBase(SC, Operands), OpType(OperationType::FPMathOp),
914+ FastMathFlags FMFs, DebugLoc DL = {} )
915+ : VPRecipeBase(SC, Operands, DL ), OpType(OperationType::FPMathOp),
908916 FMFs(FMFs) {}
909917
910918 static inline bool classof (const VPRecipeBase *R) {
@@ -1030,7 +1038,6 @@ class VPInstruction : public VPRecipeWithIRFlags, public VPValue {
10301038private:
10311039 typedef unsigned char OpcodeTy;
10321040 OpcodeTy Opcode;
1033- DebugLoc DL;
10341041
10351042 // / An optional name that can be used for the generated IR instruction.
10361043 const std::string Name;
@@ -1053,8 +1060,8 @@ class VPInstruction : public VPRecipeWithIRFlags, public VPValue {
10531060public:
10541061 VPInstruction (unsigned Opcode, ArrayRef<VPValue *> Operands, DebugLoc DL,
10551062 const Twine &Name = " " )
1056- : VPRecipeWithIRFlags(VPDef::VPInstructionSC, Operands), VPValue( this ),
1057- Opcode (Opcode ), DL(DL ), Name(Name.str()) {}
1063+ : VPRecipeWithIRFlags(VPDef::VPInstructionSC, Operands, DL ),
1064+ VPValue ( this ), Opcode(Opcode ), Name(Name.str()) {}
10581065
10591066 VPInstruction (unsigned Opcode, std::initializer_list<VPValue *> Operands,
10601067 DebugLoc DL = {}, const Twine &Name = " " )
@@ -1065,8 +1072,8 @@ class VPInstruction : public VPRecipeWithIRFlags, public VPValue {
10651072
10661073 VPInstruction (unsigned Opcode, std::initializer_list<VPValue *> Operands,
10671074 WrapFlagsTy WrapFlags, DebugLoc DL = {}, const Twine &Name = " " )
1068- : VPRecipeWithIRFlags(VPDef::VPInstructionSC, Operands, WrapFlags),
1069- VPValue(this ), Opcode(Opcode), DL(DL), Name(Name.str()) {}
1075+ : VPRecipeWithIRFlags(VPDef::VPInstructionSC, Operands, WrapFlags, DL ),
1076+ VPValue(this ), Opcode(Opcode), Name(Name.str()) {}
10701077
10711078 VPInstruction (unsigned Opcode, std::initializer_list<VPValue *> Operands,
10721079 FastMathFlags FMFs, DebugLoc DL = {}, const Twine &Name = " " );
@@ -1238,7 +1245,8 @@ class VPWidenCallRecipe : public VPRecipeBase, public VPValue {
12381245struct VPWidenSelectRecipe : public VPRecipeBase , public VPValue {
12391246 template <typename IterT>
12401247 VPWidenSelectRecipe (SelectInst &I, iterator_range<IterT> Operands)
1241- : VPRecipeBase(VPDef::VPWidenSelectSC, Operands), VPValue(this , &I) {}
1248+ : VPRecipeBase(VPDef::VPWidenSelectSC, Operands, I.getDebugLoc()),
1249+ VPValue (this , &I) {}
12421250
12431251 ~VPWidenSelectRecipe () override = default ;
12441252
@@ -1324,8 +1332,8 @@ class VPWidenGEPRecipe : public VPRecipeWithIRFlags, public VPValue {
13241332class VPHeaderPHIRecipe : public VPRecipeBase , public VPValue {
13251333protected:
13261334 VPHeaderPHIRecipe (unsigned char VPDefID, Instruction *UnderlyingInstr,
1327- VPValue *Start = nullptr )
1328- : VPRecipeBase(VPDefID, {}), VPValue(this , UnderlyingInstr) {
1335+ VPValue *Start = nullptr , DebugLoc DL = {} )
1336+ : VPRecipeBase(VPDefID, {}, DL ), VPValue(this , UnderlyingInstr) {
13291337 if (Start)
13301338 addOperand (Start);
13311339 }
@@ -1607,14 +1615,13 @@ class VPReductionPHIRecipe : public VPHeaderPHIRecipe {
16071615// / A recipe for vectorizing a phi-node as a sequence of mask-based select
16081616// / instructions.
16091617class VPBlendRecipe : public VPRecipeBase , public VPValue {
1610- PHINode *Phi;
1611-
16121618public:
16131619 // / The blend operation is a User of the incoming values and of their
16141620 // / respective masks, ordered [I0, M0, I1, M1, ...]. Note that a single value
16151621 // / might be incoming with a full mask for which there is no VPValue.
16161622 VPBlendRecipe (PHINode *Phi, ArrayRef<VPValue *> Operands)
1617- : VPRecipeBase(VPDef::VPBlendSC, Operands), VPValue(this , Phi), Phi(Phi) {
1623+ : VPRecipeBase(VPDef::VPBlendSC, Operands, Phi->getDebugLoc ()),
1624+ VPValue(this , Phi) {
16181625 assert (Operands.size () > 0 &&
16191626 ((Operands.size () == 1 ) || (Operands.size () % 2 == 0 )) &&
16201627 " Expected either a single incoming value or a positive even number "
@@ -2047,11 +2054,9 @@ class VPExpandSCEVRecipe : public VPRecipeBase, public VPValue {
20472054// / loop). VPWidenCanonicalIVRecipe represents the vector version of the
20482055// / canonical induction variable.
20492056class VPCanonicalIVPHIRecipe : public VPHeaderPHIRecipe {
2050- DebugLoc DL;
2051-
20522057public:
20532058 VPCanonicalIVPHIRecipe (VPValue *StartV, DebugLoc DL)
2054- : VPHeaderPHIRecipe(VPDef::VPCanonicalIVPHISC, nullptr , StartV), DL( DL) {}
2059+ : VPHeaderPHIRecipe(VPDef::VPCanonicalIVPHISC, nullptr , StartV, DL) {}
20552060
20562061 ~VPCanonicalIVPHIRecipe () override = default ;
20572062
@@ -2094,12 +2099,10 @@ class VPCanonicalIVPHIRecipe : public VPHeaderPHIRecipe {
20942099// / TODO: It would be good to use the existing VPWidenPHIRecipe instead and
20952100// / remove VPActiveLaneMaskPHIRecipe.
20962101class VPActiveLaneMaskPHIRecipe : public VPHeaderPHIRecipe {
2097- DebugLoc DL;
2098-
20992102public:
21002103 VPActiveLaneMaskPHIRecipe (VPValue *StartMask, DebugLoc DL)
2101- : VPHeaderPHIRecipe(VPDef::VPActiveLaneMaskPHISC, nullptr , StartMask) ,
2102- DL ( DL) {}
2104+ : VPHeaderPHIRecipe(VPDef::VPActiveLaneMaskPHISC, nullptr , StartMask,
2105+ DL) {}
21032106
21042107 ~VPActiveLaneMaskPHIRecipe () override = default ;
21052108
0 commit comments