[llvm] [SROA] Optimize reloaded values in allocas that escape into readonly nocapture calls. (PR #116645)
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 27 07:41:58 PST 2024
================
@@ -1390,14 +1395,30 @@ class AllocaSlices::SliceBuilder : public PtrUseVisitor<SliceBuilder> {
/// Disable SROA entirely if there are unhandled users of the alloca.
void visitInstruction(Instruction &I) { PI.setAborted(&I); }
+
+ void visitCallBase(CallBase &CB) {
+ // If the operands that are U are NoCapture ReadOnly, then we mark it as
+ // EscapedReadOnly.
+ Function *Callee = CB.getCalledFunction();
+ if (Callee && CB.arg_size() == Callee->arg_size() &&
+ !CB.hasOperandBundles() && all_of(enumerate(CB.args()), [&](auto V) {
----------------
nikic wrote:
The operand bundle checks shouldn't be necessary. doesNotCapture/onlyReadsMemory both support operand bundle indices and also handle operand bundle effects.
https://github.com/llvm/llvm-project/pull/116645
More information about the llvm-commits
mailing list