@@ -728,7 +728,8 @@ static bool findArgParts(Argument *Arg, const DataLayout &DL, AAResults &AAR,
728
728
append_range (ArgPartsVec, ArgParts);
729
729
sort (ArgPartsVec, llvm::less_first ());
730
730
731
- // Make sure the parts are non-overlapping.
731
+ // Make sure the parts are non-overlapping. This also computes the size of the
732
+ // memory region accessed through Arg.
732
733
int64_t Offset = ArgPartsVec[0 ].first ;
733
734
for (const auto &Pair : ArgPartsVec) {
734
735
if (Pair.first < Offset)
@@ -749,13 +750,7 @@ static bool findArgParts(Argument *Arg, const DataLayout &DL, AAResults &AAR,
749
750
// If we can determine that no call to the Function modifies the memory region
750
751
// accessed through Arg, through alias analysis using actual arguments in the
751
752
// callers, we know that it is guaranteed to be safe to promote the argument.
752
-
753
- // Compute the size of the memory region accessed by the Loads through Arg.
754
- LocationSize Size = LocationSize::precise (0 );
755
- for (LoadInst *Load : Loads) {
756
- Size = Size.unionWith (MemoryLocation::get (Load).Size );
757
- }
758
- if (isArgUnmodifiedByAllCalls (Arg, Size, FAM))
753
+ if (isArgUnmodifiedByAllCalls (Arg, LocationSize::precise (Offset), FAM))
759
754
return true ;
760
755
761
756
// Otherwise, use alias analysis to check if the pointer is guaranteed to not
0 commit comments