Skip to content

Commit 1e43fc2

Browse files
committed
Address review 4
- Fix incorrect calculation of the size of the memory region accessed by the loads through Arg.
1 parent 31621cc commit 1e43fc2

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

llvm/lib/Transforms/IPO/ArgumentPromotion.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -728,7 +728,8 @@ static bool findArgParts(Argument *Arg, const DataLayout &DL, AAResults &AAR,
728728
append_range(ArgPartsVec, ArgParts);
729729
sort(ArgPartsVec, llvm::less_first());
730730

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.
732733
int64_t Offset = ArgPartsVec[0].first;
733734
for (const auto &Pair : ArgPartsVec) {
734735
if (Pair.first < Offset)
@@ -749,13 +750,7 @@ static bool findArgParts(Argument *Arg, const DataLayout &DL, AAResults &AAR,
749750
// If we can determine that no call to the Function modifies the memory region
750751
// accessed through Arg, through alias analysis using actual arguments in the
751752
// 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))
759754
return true;
760755

761756
// Otherwise, use alias analysis to check if the pointer is guaranteed to not

0 commit comments

Comments
 (0)