From 440ce05fbf869040b41a5fc9953d7b11ad5bb776 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 13 Oct 2022 11:13:30 +0200 Subject: [PATCH] [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. --- llvm/lib/Transforms/IPO/FunctionAttrs.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/llvm/lib/Transforms/IPO/FunctionAttrs.cpp b/llvm/lib/Transforms/IPO/FunctionAttrs.cpp index 055cb14..007d84a 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); -- 2.7.4