[llvm] [ArgPromotion] Perform alias analysis on actual arguments of Calls (PR #106216)
Hari Limaye via llvm-commits
llvm-commits at lists.llvm.org
Tue Sep 24 15:32:18 PDT 2024
================
@@ -716,10 +745,16 @@ static bool findArgParts(Argument *Arg, const DataLayout &DL, AAResults &AAR,
return true;
// Okay, now we know that the argument is only used by load instructions, and
- // it is safe to unconditionally perform all of them. Use alias analysis to
- // check to see if the pointer is guaranteed to not be modified from entry of
- // the function to each of the load instructions.
+ // it is safe to unconditionally perform all of them.
+
+ // If we can determine that no call to the Function modifies the memory region
+ // accessed through Arg, through alias analysis using actual arguments in the
+ // callers, we know that it is guaranteed to be safe to promote the argument.
+ if (isArgUnmodifiedByAllCalls(Arg, LocationSize::precise(Offset), FAM))
----------------
hazzlim wrote:
Ah yes - I was mistakenly thinking that we bail when any load has a negative offset from Arg, but this is only the case for loads in the entry block that are guaranteed to execute. And I think what I've done here is in fact incorrect for all cases where the lowest offset is non-zero.
Given that it is not really possible to test this at this stage, I have reverted to not using any Size information if you think that seems appropriate?
https://github.com/llvm/llvm-project/pull/106216
More information about the llvm-commits
mailing list