[llvm] 440ce05 - [FunctionAttrs] Handle potential access of captured argument
Nikita Popov via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 13 02:15:49 PDT 2022
Author: Nikita Popov
Date: 2022-10-13T11:15:36+02:00
New Revision: 440ce05fbf869040b41a5fc9953d7b11ad5bb776
URL: https://github.com/llvm/llvm-project/commit/440ce05fbf869040b41a5fc9953d7b11ad5bb776
DIFF: https://github.com/llvm/llvm-project/commit/440ce05fbf869040b41a5fc9953d7b11ad5bb776.diff
LOG: [FunctionAttrs] Handle potential access of captured argument
We have to account for accesses to argument memory via captures.
I don't think there's any way to make this produce incorrect
results right now (because as soon as "other" is set, we lose the
ability to infer argmemonly), but this avoids incorrect results
once we have more precise representation.
Added:
Modified:
llvm/lib/Transforms/IPO/FunctionAttrs.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
index 055cb14c3114c..007d84a702fa9 100644
--- a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -171,6 +171,12 @@ checkFunctionMemoryAccess(Function &F, bool ThisBody, AAResults &AAR,
MRB |= CallMRB.getWithoutLoc(FunctionModRefBehavior::ArgMem);
+ // If the call accesses captured memory (currently part of "other") and
+ // an argument is captured (currently not tracked), then it may also
+ // access argument memory.
+ ModRefInfo OtherMR = CallMRB.getModRef(FunctionModRefBehavior::Other);
+ MRB |= FunctionModRefBehavior::argMemOnly(OtherMR);
+
// Check whether all pointer arguments point to local memory, and
// ignore calls that only access local memory.
ModRefInfo ArgMR = CallMRB.getModRef(FunctionModRefBehavior::ArgMem);
More information about the llvm-commits
mailing list