-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[VPlan] Implement printing VPIRMetadata. #168385
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -507,6 +507,11 @@ void VPRecipeBase::print(raw_ostream &O, const Twine &Indent, | |
| O << ", !dbg "; | ||
| DL.print(O); | ||
| } | ||
|
|
||
| if (auto *Metadata = dyn_cast<VPIRMetadata>(this)) { | ||
| if (const VPBasicBlock *Parent = getParent()) | ||
| Metadata->print(O, Parent->getPlan()); | ||
| } | ||
| } | ||
| #endif | ||
|
|
||
|
|
@@ -1706,6 +1711,28 @@ void VPIRMetadata::intersect(const VPIRMetadata &Other) { | |
| Metadata = std::move(MetadataIntersection); | ||
| } | ||
|
|
||
| #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) | ||
| void VPIRMetadata::print(raw_ostream &O, const VPlan *Plan) const { | ||
| if (Metadata.empty() || !Plan) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we ever be in a situation where |
||
| return; | ||
|
|
||
| const Module &M = Plan->getModule(); | ||
| SmallVector<StringRef, 8> MDNames; | ||
| M.getContext().getMDKindNames(MDNames); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't this quite an expensive operation? Would be great if there was a way to only do this once, although I realise that might be tricky. |
||
|
|
||
| O << " ("; | ||
| interleaveComma(Metadata, O, [&](const auto &KindNodePair) { | ||
| auto [Kind, Node] = KindNodePair; | ||
| assert(Kind != 0 && "Debug metadata should not be managed by VPIRMetadata"); | ||
| assert(Kind < MDNames.size() && !MDNames[Kind].empty() && | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if these checks should actually live somewhere in the vplan verifier, rather than only checking when someone is dumping the recipe? |
||
| "Unexpected unnamed metadata kind"); | ||
| O << "!" << MDNames[Kind] << " "; | ||
| Node->printAsOperand(O, &M); | ||
| }); | ||
| O << ")"; | ||
| } | ||
| #endif | ||
|
|
||
| void VPWidenCallRecipe::execute(VPTransformState &State) { | ||
| assert(State.VF.isVector() && "not widening"); | ||
| assert(Variant != nullptr && "Can't create vector function."); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,11 +7,11 @@ define void @test_widen_metadata(ptr noalias %A, ptr noalias %B, i32 %n) { | |
| ; CHECK: VPlan 'Initial VPlan for VF={4},UF>=1' { | ||
| ; CHECK: <x1> vector loop: { | ||
| ; CHECK: vector.body: | ||
| ; CHECK: WIDEN ir<%lv> = load vp<{{.*}}> | ||
| ; CHECK: WIDEN-CAST ir<%conv> = sitofp ir<%lv> to float | ||
| ; CHECK: WIDEN ir<%mul> = fmul ir<%conv>, ir<2.000000e+00> | ||
| ; CHECK: WIDEN ir<%lv> = load vp<{{.*}}> (!tbaa !{{[0-9]+}}) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is it worth also changing the RUN line to generate CHECK lines for the attributes so that we can verify they are as expected? |
||
| ; CHECK: WIDEN-CAST ir<%conv> = sitofp ir<%lv> to float (!fpmath !{{[0-9]+}}) | ||
| ; CHECK: WIDEN ir<%mul> = fmul ir<%conv>, ir<2.000000e+00> (!fpmath !{{[0-9]+}}) | ||
| ; CHECK: WIDEN-CAST ir<%conv.back> = fptosi ir<%mul> to i32 | ||
| ; CHECK: WIDEN store vp<{{.*}}>, ir<%conv.back> | ||
| ; CHECK: WIDEN store vp<{{.*}}>, ir<%conv.back> (!tbaa !{{[0-9]+}}) | ||
| ; | ||
| entry: | ||
| br label %loop | ||
|
|
@@ -40,9 +40,9 @@ define void @test_intrinsic_with_metadata(ptr noalias %A, ptr noalias %B, i32 %n | |
| ; CHECK: VPlan 'Initial VPlan for VF={4},UF>=1' { | ||
| ; CHECK: <x1> vector loop: { | ||
| ; CHECK: vector.body: | ||
| ; CHECK: WIDEN ir<%lv> = load vp<{{.*}}> | ||
| ; CHECK: WIDEN-INTRINSIC ir<%sqrt> = call llvm.sqrt(ir<%lv>) | ||
| ; CHECK: WIDEN store vp<{{.*}}>, ir<%sqrt> | ||
| ; CHECK: WIDEN ir<%lv> = load vp<{{.*}}> (!tbaa !{{[0-9]+}}) | ||
| ; CHECK: WIDEN-INTRINSIC ir<%sqrt> = call llvm.sqrt(ir<%lv>) (!fpmath !{{[0-9]+}}) | ||
| ; CHECK: WIDEN store vp<{{.*}}>, ir<%sqrt> (!tbaa !{{[0-9]+}}) | ||
| ; | ||
| entry: | ||
| br label %loop | ||
|
|
@@ -67,11 +67,11 @@ define void @test_widen_with_multiple_metadata(ptr noalias %A, ptr noalias %B, i | |
| ; CHECK: VPlan 'Initial VPlan for VF={4},UF>=1' { | ||
| ; CHECK: <x1> vector loop: { | ||
| ; CHECK: vector.body: | ||
| ; CHECK: WIDEN ir<%lv> = load vp<{{.*}}> | ||
| ; CHECK: WIDEN ir<%lv> = load vp<{{.*}}> (!tbaa !{{[0-9]+}}) | ||
| ; CHECK: WIDEN-CAST ir<%conv> = sitofp ir<%lv> to float | ||
| ; CHECK: WIDEN ir<%mul> = fmul ir<%conv>, ir<2.000000e+00> | ||
| ; CHECK: WIDEN-CAST ir<%conv.back> = fptosi ir<%mul> to i32 | ||
| ; CHECK: WIDEN store vp<{{.*}}>, ir<%conv.back> | ||
| ; CHECK: WIDEN store vp<{{.*}}>, ir<%conv.back> (!tbaa !{{[0-9]+}}) | ||
| ; | ||
| entry: | ||
| br label %loop | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given this is only used in one place is it worth adding this function? Not sure if it would be used elsewhere though.