@@ -852,9 +852,11 @@ 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 =
859
+ CB.isArgOperand (U) && CB.isByValArgument (CB.getArgOperandNo (U));
858
860
859
861
// Some intrinsics (for instance ptrmask) do not capture their results,
860
862
// but return results thas alias their pointer argument, and thus should
@@ -864,7 +866,7 @@ determinePointerAccessAttrs(Argument *A,
864
866
for (Use &UU : CB.uses ())
865
867
if (Visited.insert (&UU).second )
866
868
Worklist.push_back (&UU);
867
- } else if (!CB.doesNotCapture (UseIndex)) {
869
+ } else if (!( CB.doesNotCapture (UseIndex) || IsByVal )) {
868
870
if (!CB.onlyReadsMemory ())
869
871
// If the callee can save a copy into other memory, then simply
870
872
// scanning uses of the call is insufficient. We have no way
@@ -894,7 +896,7 @@ determinePointerAccessAttrs(Argument *A,
894
896
// invokes with operand bundles.
895
897
if (CB.doesNotAccessMemory (UseIndex)) {
896
898
/* nop */
897
- } else if (!isModSet (ArgMR) || CB.onlyReadsMemory (UseIndex)) {
899
+ } else if (!isModSet (ArgMR) || CB.onlyReadsMemory (UseIndex) || IsByVal ) {
898
900
IsRead = true ;
899
901
} else if (!isRefSet (ArgMR) ||
900
902
CB.dataOperandHasImpliedAttr (UseIndex, Attribute::WriteOnly)) {
0 commit comments