Skip to content

Commit 81bbe19

Browse files
committed
[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.
1 parent 4512bbe commit 81bbe19

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

llvm/lib/Transforms/Vectorize/VPlan.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -954,6 +954,11 @@ class VPSingleDefRecipe : public VPRecipeBase, public VPValue {
954954
/// Return the cost of this VPSingleDefRecipe.
955955
InstructionCost computeCost(ElementCount VF,
956956
VPCostContext &Ctx) const override;
957+
958+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
959+
/// Print this VPSingleDefRecipe to dbgs() (for debugging).
960+
LLVM_DUMP_METHOD void dump() const;
961+
#endif
957962
};
958963

959964
/// Class to record LLVM IR flag for a recipe along with it.

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,10 @@ FastMathFlags VPRecipeWithIRFlags::getFastMathFlags() const {
343343
return Res;
344344
}
345345

346+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
347+
void VPSingleDefRecipe::dump() const { VPDef::dump(); }
348+
#endif
349+
346350
template <unsigned PartOpIdx>
347351
VPValue *
348352
VPUnrollPartAccessor<PartOpIdx>::getUnrollPartOperand(VPUser &U) const {

llvm/unittests/Transforms/Vectorize/VPlanTest.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,6 +1279,21 @@ TEST(VPRecipeTest, dumpRecipeInPlan) {
12791279
},
12801280
testing::ExitedWithCode(0), "WIDEN ir<%a> = add ir<1>, ir<2>");
12811281

1282+
VPDef *Def = WidenR;
1283+
EXPECT_EXIT(
1284+
{
1285+
Def->dump();
1286+
exit(0);
1287+
},
1288+
testing::ExitedWithCode(0), "WIDEN ir<%a> = add ir<1>, ir<2>");
1289+
1290+
EXPECT_EXIT(
1291+
{
1292+
WidenR->dump();
1293+
exit(0);
1294+
},
1295+
testing::ExitedWithCode(0), "WIDEN ir<%a> = add ir<1>, ir<2>");
1296+
12821297
// Test VPRecipeBase::dump().
12831298
VPRecipeBase *R = WidenR;
12841299
EXPECT_EXIT(

0 commit comments

Comments
 (0)