-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ome] Invoke simplifyInstruction after lowering ownership and use replaceAllSimplifiedUsesAndErase instead of a manual RAUW. #34813
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
[ome] Invoke simplifyInstruction after lowering ownership and use replaceAllSimplifiedUsesAndErase instead of a manual RAUW. #34813
Conversation
@swift-ci smoke test |
Found the problem. It came down to emitDestroyValueOperation having a footman in it. I may try to fix it when I have time. |
Not a big deal, but it's always helpful when renaming is done in a separate commit. |
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 change in this PR looks good. I asked for some clarification. The only issue I have is how badly SILBuilder is being abused for no reason. Why is the visitor passed a builder at all? The visitor should own a SILBuilderContext. It's trackingList should be that context's InsertedInsts. It can also hold on to the current builder, which can be instantiated in beforeVisit with the visitor's context.
Basically, don't call any setter functions on SILBuilder!
0f315b4
to
9284782
Compare
@swift-ci smoke test |
71d1f14
to
6ad689c
Compare
@swift-ci test |
@swift-ci benchmark |
Build failed |
Performance: -O
Code size: -OPerformance: -Osize
Code size: -OsizePerformance: -Onone
Code size: -swiftlibsHow to read the dataThe tables contain differences in performance which are larger than 8% and differences in code size which are larger than 1%.If you see any unexpected regressions, you should consider fixing the Noise: Sometimes the performance results (not code size!) contain false Hardware Overview
|
@swift-ci test linux platform |
6ad689c
to
4ba0496
Compare
@swift-ci test |
Woot all tests! |
withBuilder(SILInstruction *insertPt, | ||
llvm::function_ref<ResultTy(SILBuilder &, SILLocation)> visitor) { | ||
SILBuilderWithScope builder(insertPt, builderCtx); | ||
return visitor(builder, insertPt->getLoc()); |
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.
It's too bad this is so awkward. Ideally, building a single instruction should be able to naturally use function chaining:
SILBuilder(inst, builderCtx).emitSomethingElse(operands)
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.
Yes. But today it is SILBuilderWithScope.
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.
Thanks for fixing SILBuilder
Going to rebase again. |
Going to rebase on top of #34877 |
4ba0496
to
679a250
Compare
@swift-ci test |
…laceAllSimplifiedUsesAndErase instead of a manual RAUW. I am doing two things here: 1. simplifyInstruction expects its result to only be passed to replaceAllSimplifiedUsesAndErase. This was an oversite. 2. I am upstreaming support for InstSimplify in OSSA (to finish sil-combine work). The main assumption that inst-simplify is going to have is that it is looking at SIL in correct ownership ssa or non-ownership ssa. It is not going to be designed to work with an intermediate world that is the world where before this PR it was being invoked (specifically, we have marked the function as not being in OSSA but haven't finished transforming it into non-OSSA SIL). To avoid this problem, I moved the simplification to the end of the pass after we have done the initial traversal. Should be NFCI.
…SILBuilderWithContext and multiple local SILBuilderWithScope. To make it a little less verbose, I added an always inline helper method called: template <typename ResultTy> ResultTy OME::withBuilder(SILInstruction *insertPt, function_ref<ResultTy (SILBuilder &, SILLocation)> visitor) { SILBuilderWithScope builder(insertPt, builderContext); return visitor(builder, insertPt->getLoc()); } Since it is always inline there shouldn't be any perf impact and it should be like invoking a lambda in the caller directly in the same function that the lambda was declared in. I just couldn't type SILBuilderWithScope builder(insertPt, builderContext) all the time. Seems error prone.
679a250
to
f9e0649
Compare
Rebased on top of main now that I landed the precursors. |
@swift-ci test |
I am doing two things here:
simplifyInstruction expects its result to only be passed to
replaceAllSimplifiedUsesAndErase. This was an oversite.
I am upstreaming support for InstSimplify in OSSA (to finish sil-combine
work). The main assumption that inst-simplify is going to have is that it is
looking at SIL in correct ownership ssa or non-ownership ssa. It is not going to
be designed to work with an intermediate world that is the world where before
this PR it was being invoked (specifically, we have marked the function as not
being in OSSA but haven't finished transforming it into non-OSSA SIL). To avoid
this problem, I moved the simplification to the end of the pass after we have
done the initial traversal.
Should be NFCI.