[VPlan] Add VPSingleDefRecipe::dump() to resolve ambigous lookup (NFC).

This allows calling ::dump() on various sub-classes of VPSingleDefRecipe
directly, as it resolves an ambigous name lookup.

Previously, calling VPWidenRecipe::dump() (and others), would result in

the following errors:
llvm/unittests/Transforms/Vectorize/VPlanTest.cpp:1284:19: error: member 'dump' found in multiple base classes of different types
 1284 |           WidenR->dump();
      |                   ^
llvm/include/../lib/Transforms/Vectorize/VPlanValue.h:434:8: note: member found by ambiguous name lookup
  434 |   void dump() const;
      |        ^
llvm/include/../lib/Transforms/Vectorize/VPlanValue.h:108:8: note: member found by ambiguous name lookup
  108 |   void dump() const;
      |        ^
1 error generated.
This commit is contained in:
Florian Hahn 2024-10-17 05:31:28 +01:00
parent 4512bbe746
commit 81bbe19383
No known key found for this signature in database
GPG Key ID: 9E54DEA47A8F4434
3 changed files with 24 additions and 0 deletions

View File

@ -954,6 +954,11 @@ public:
/// Return the cost of this VPSingleDefRecipe.
InstructionCost computeCost(ElementCount VF,
VPCostContext &Ctx) const override;
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
/// Print this VPSingleDefRecipe to dbgs() (for debugging).
LLVM_DUMP_METHOD void dump() const;
#endif
};
/// Class to record LLVM IR flag for a recipe along with it.

View File

@ -343,6 +343,10 @@ FastMathFlags VPRecipeWithIRFlags::getFastMathFlags() const {
return Res;
}
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
void VPSingleDefRecipe::dump() const { VPDef::dump(); }
#endif
template <unsigned PartOpIdx>
VPValue *
VPUnrollPartAccessor<PartOpIdx>::getUnrollPartOperand(VPUser &U) const {

View File

@ -1279,6 +1279,21 @@ TEST(VPRecipeTest, dumpRecipeInPlan) {
},
testing::ExitedWithCode(0), "WIDEN ir<%a> = add ir<1>, ir<2>");
VPDef *Def = WidenR;
EXPECT_EXIT(
{
Def->dump();
exit(0);
},
testing::ExitedWithCode(0), "WIDEN ir<%a> = add ir<1>, ir<2>");
EXPECT_EXIT(
{
WidenR->dump();
exit(0);
},
testing::ExitedWithCode(0), "WIDEN ir<%a> = add ir<1>, ir<2>");
// Test VPRecipeBase::dump().
VPRecipeBase *R = WidenR;
EXPECT_EXIT(