-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[IPO] Prevent removal of some convergent attr #134863
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
Changes from 3 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 | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2902,6 +2902,22 @@ struct AANonConvergentImpl : public AANonConvergent { | |||||||||||||||||
| } | ||||||||||||||||||
| }; | ||||||||||||||||||
|
|
||||||||||||||||||
| static bool FunctionCalledWithConvergenceToken(const Function *F) { | ||||||||||||||||||
| for (auto &Use : F->uses()) { | ||||||||||||||||||
| CallBase *CB = dyn_cast<CallBase>(Use.getUser()); | ||||||||||||||||||
| if (!CB) | ||||||||||||||||||
| continue; | ||||||||||||||||||
|
|
||||||||||||||||||
| // We are not called, just used as an argument. | ||||||||||||||||||
| if (CB->getCalledFunction() != F) | ||||||||||||||||||
| continue; | ||||||||||||||||||
|
Comment on lines
+2908
to
+2913
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.
Suggested change
|
||||||||||||||||||
|
|
||||||||||||||||||
| if (CB->getConvergenceControlToken()) | ||||||||||||||||||
| return true; | ||||||||||||||||||
| } | ||||||||||||||||||
| return false; | ||||||||||||||||||
|
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. This needs to be a conservatively correct true. If the address is captured you do not know the users. If the function is externally visible, you also do not know the users. |
||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| struct AANonConvergentFunction final : AANonConvergentImpl { | ||||||||||||||||||
| AANonConvergentFunction(const IRPosition &IRP, Attributor &A) | ||||||||||||||||||
| : AANonConvergentImpl(IRP, A) {} | ||||||||||||||||||
|
|
@@ -2929,6 +2945,11 @@ struct AANonConvergentFunction final : AANonConvergentImpl { | |||||||||||||||||
| UsedAssumedInformation)) { | ||||||||||||||||||
| return indicatePessimisticFixpoint(); | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| const Function *F = this->getIRPosition().getAssociatedFunction(); | ||||||||||||||||||
| if (FunctionCalledWithConvergenceToken(F)) | ||||||||||||||||||
| return indicatePessimisticFixpoint(); | ||||||||||||||||||
|
|
||||||||||||||||||
| return ChangeStatus::UNCHANGED; | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1864,12 +1864,16 @@ static bool InstrBreaksNonConvergent(Instruction &I, | |
| !SCCNodes.contains(CB->getCalledFunction()); | ||
| } | ||
|
|
||
| static bool FunctionRequiresConvergence(const Function &F) { | ||
| for (auto &Use : F.uses()) { | ||
| static bool FunctionRequiresConvergence(const Function *F) { | ||
|
Collaborator
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. This is identical to |
||
| for (auto &Use : F->uses()) { | ||
| CallBase *CB = dyn_cast<CallBase>(Use.getUser()); | ||
| if (!CB) | ||
| return true; | ||
|
|
||
| // We are not called, just used as an argument. | ||
| if (CB->getCalledFunction() != F) | ||
| continue; | ||
|
|
||
| if (CB->getConvergenceControlToken()) | ||
| return true; | ||
| } | ||
|
|
@@ -1981,7 +1985,7 @@ static void inferConvergent(const SCCNodeSet &SCCNodes, | |
| Attribute::Convergent, | ||
| // Skip non-convergent functions. | ||
| [](const Function &F) { | ||
| return !F.isConvergent() || FunctionRequiresConvergence(F); | ||
| return !F.isConvergent() || FunctionRequiresConvergence(&F); | ||
| }, | ||
| // Instructions that break non-convergent assumption. | ||
| [SCCNodes](Instruction &I) { | ||
|
|
||
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.
Start with lowercase