Skip to content
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

[SDAG] Read-only intrinsics must have WillReturn attribute to be treated as loads #99999

Merged
merged 7 commits into from
Aug 16, 2024
Merged
3 changes: 2 additions & 1 deletion llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5229,7 +5229,8 @@ void SelectionDAGBuilder::visitTargetIntrinsic(const CallInst &I,
// definition.
const Function *F = I.getCalledFunction();
bool HasChain = !F->doesNotAccessMemory();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably also have || !F->willReturn() here. If it's a readnone function that may diverge, it also needs a chain, right? This would probably also help identify intrinsics that are incorrectly missing the attribute.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a good idea. When I add that there are many test failures, and the few I looked into are resolved by adding WillReturn. If it's okay, I would prefer that be added and the relevant intrinsics fixed in a separate PR so that we can land this one sooner.

bool OnlyLoad = HasChain && F->onlyReadsMemory();
bool OnlyLoad =
HasChain && F->onlyReadsMemory() && F->willReturn() && F->doesNotThrow();

// Build the operand list.
SmallVector<SDValue, 8> Ops;
Expand Down
Loading