@@ -852,9 +852,10 @@ determinePointerAccessAttrs(Argument *A,
852
852
continue ;
853
853
}
854
854
855
- // Given we've explictily handled the callee operand above, what's left
855
+ // Given we've explicitly handled the callee operand above, what's left
856
856
// must be a data operand (e.g. argument or operand bundle)
857
857
const unsigned UseIndex = CB.getDataOperandNo (U);
858
+ const bool IsByVal = CB.isByValArgument (CB.getArgOperandNo (U));
858
859
859
860
// Some intrinsics (for instance ptrmask) do not capture their results,
860
861
// but return results thas alias their pointer argument, and thus should
@@ -864,7 +865,7 @@ determinePointerAccessAttrs(Argument *A,
864
865
for (Use &UU : CB.uses ())
865
866
if (Visited.insert (&UU).second )
866
867
Worklist.push_back (&UU);
867
- } else if (!CB.doesNotCapture (UseIndex)) {
868
+ } else if (!( CB.doesNotCapture (UseIndex) || IsByVal )) {
868
869
if (!CB.onlyReadsMemory ())
869
870
// If the callee can save a copy into other memory, then simply
870
871
// scanning uses of the call is insufficient. We have no way
@@ -894,7 +895,7 @@ determinePointerAccessAttrs(Argument *A,
894
895
// invokes with operand bundles.
895
896
if (CB.doesNotAccessMemory (UseIndex)) {
896
897
/* nop */
897
- } else if (!isModSet (ArgMR) || CB.onlyReadsMemory (UseIndex)) {
898
+ } else if (!isModSet (ArgMR) || CB.onlyReadsMemory (UseIndex) || IsByVal ) {
898
899
IsRead = true ;
899
900
} else if (!isRefSet (ArgMR) ||
900
901
CB.dataOperandHasImpliedAttr (UseIndex, Attribute::WriteOnly)) {
0 commit comments