-
Notifications
You must be signed in to change notification settings - Fork 14.2k
[SandboxIR][Region] Implement an auxiliary vector in Region #126376
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
Conversation
Added Region::clearAux(). |
llvm/include/llvm/SandboxIR/Region.h
Outdated
|
||
/// MDNode that we'll use to mark instructions as being part of the region. | ||
MDNode *RegionMDN; | ||
static constexpr const char *MDKind = "sandboxvec"; | ||
static constexpr const char *RegionStr = "sandboxregion"; | ||
static constexpr const char *AuxMDKind = "sbaux"; |
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.
the other names use "sandbox" instead of "sb" as a prefix. Should this be "sandboxaux"? Or even "sandboxregionaux"? (I don't know how long these strings usually are)
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.
Good point, yeah we should make this consistent. I will change it to "sandboxaux".
llvm::Constant *IdxC = | ||
dyn_cast<ConstantAsMetadata>(AuxMDN->getOperand(0))->getValue(); | ||
auto Idx = cast<llvm::ConstantInt>(IdxC)->getSExtValue(); | ||
R->setAux(Idx, &Inst); |
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.
Here we could have a check that we don't have two different values whose metadata claims the same index in the aux vector.
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.
I added a check in setAux(Idx, I)
but this function is only called internally so using the same index shouldn't be possible unless this function is broken.
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.
You could have incorrect metadata, right? Something like
define void @foo(i8 %v) {
%t0 = add i8 %v, 0, !sandboxvec !0, !sandboxaux !1
%t1 = add i8 %v, 1, !sandboxvec !0, !sandboxaux !1
ret void
}
!0 = distinct !{!"sandboxregion"}
!1 = !{i32 0}
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.
You are right, I think I should be able to add a test for it too.
This patch adds additional functionality to the sandboxir Region. The Region is used as a way of passing a set of Instructions across region passes in a way that can be represented in the IR with metadata. This is a design choice that allows us to test region passes in isolation with lit tests. Up until now the region was only used to tag the instructions generated by the passes. There is a need to represent an ordered set of instructions, which can be used as a way to represent the initial seeds to the first vectorization pass. This patch implements this auxiliary vector that can be used to convey such information.
) This patch adds additional functionality to the sandboxir Region. The Region is used as a way of passing a set of Instructions across region passes in a way that can be represented in the IR with metadata. This is a design choice that allows us to test region passes in isolation with lit tests. Up until now the region was only used to tag the instructions generated by the passes. There is a need to represent an ordered set of instructions, which can be used as a way to represent the initial seeds to the first vectorization pass. This patch implements this auxiliary vector that can be used to convey such information.
) This patch adds additional functionality to the sandboxir Region. The Region is used as a way of passing a set of Instructions across region passes in a way that can be represented in the IR with metadata. This is a design choice that allows us to test region passes in isolation with lit tests. Up until now the region was only used to tag the instructions generated by the passes. There is a need to represent an ordered set of instructions, which can be used as a way to represent the initial seeds to the first vectorization pass. This patch implements this auxiliary vector that can be used to convey such information.
auto &LLVMCtx = Ctx.LLVMCtx; | ||
for (auto [Idx, I] : enumerate(Aux)) { | ||
llvm::ConstantInt *IdxC = | ||
llvm::ConstantInt::get(LLVMCtx, llvm::APInt(32, Idx, false)); |
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.
https://discourse.llvm.org/t/second-stage-of-build-on-windows-fails-in-sandboxir/84841
@vporpo - could you replace the APInt with the ConstantInt::get(Type *Ty, uint64_t V, bool isSigned) variant?
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.
This patch adds additional functionality to the sandboxir Region. The Region is used as a way of passing a set of Instructions across region passes in a way that can be represented in the IR with metadata. This is a design choice that allows us to test region passes in isolation with lit tests.
Up until now the region was only used to tag the instructions generated by the passes. There is a need to represent an ordered set of instructions, which can be used as a way to represent the initial seeds to the first vectorization pass. This patch implements this auxiliary vector that can be used to convey such information.