@@ -827,7 +827,6 @@ struct AA::PointerInfo::State : public AbstractState {
827
827
AccessList = R.AccessList ;
828
828
OffsetBins = R.OffsetBins ;
829
829
RemoteIMap = R.RemoteIMap ;
830
- ReachesReturn = R.ReachesReturn ;
831
830
return *this ;
832
831
}
833
832
@@ -838,7 +837,6 @@ struct AA::PointerInfo::State : public AbstractState {
838
837
std::swap (AccessList, R.AccessList );
839
838
std::swap (OffsetBins, R.OffsetBins );
840
839
std::swap (RemoteIMap, R.RemoteIMap );
841
- std::swap (ReachesReturn, R.ReachesReturn );
842
840
return *this ;
843
841
}
844
842
@@ -880,16 +878,11 @@ struct AA::PointerInfo::State : public AbstractState {
880
878
AAPointerInfo::OffsetBinsTy OffsetBins;
881
879
DenseMap<const Instruction *, SmallVector<unsigned >> RemoteIMap;
882
880
883
- // / Flag to determine if the underlying pointer is reaching a return statement
884
- // / in the associated function or not. Returns in other functions cause
885
- // / invalidation.
886
- bool ReachesReturn = false ;
887
-
888
881
// / See AAPointerInfo::forallInterferingAccesses.
889
882
bool forallInterferingAccesses (
890
883
AA::RangeTy Range,
891
884
function_ref<bool (const AAPointerInfo::Access &, bool )> CB) const {
892
- if (!isValidState () || ReachesReturn )
885
+ if (!isValidState ())
893
886
return false ;
894
887
895
888
for (const auto &It : OffsetBins) {
@@ -911,7 +904,7 @@ struct AA::PointerInfo::State : public AbstractState {
911
904
Instruction &I,
912
905
function_ref<bool (const AAPointerInfo::Access &, bool )> CB,
913
906
AA::RangeTy &Range) const {
914
- if (!isValidState () || ReachesReturn )
907
+ if (!isValidState ())
915
908
return false ;
916
909
917
910
auto LocalList = RemoteIMap.find (&I);
@@ -1078,8 +1071,7 @@ struct AAPointerInfoImpl
1078
1071
return std::string (" PointerInfo " ) +
1079
1072
(isValidState () ? (std::string (" #" ) +
1080
1073
std::to_string (OffsetBins.size ()) + " bins" )
1081
- : " <invalid>" ) +
1082
- (ReachesReturn ? " (returned)" : " " );
1074
+ : " <invalid>" );
1083
1075
}
1084
1076
1085
1077
// / See AbstractAttribute::manifest(...).
@@ -1092,7 +1084,6 @@ struct AAPointerInfoImpl
1092
1084
virtual int64_t numOffsetBins () const override {
1093
1085
return State::numOffsetBins ();
1094
1086
}
1095
- virtual bool reachesReturn () const override { return ReachesReturn; }
1096
1087
1097
1088
bool forallInterferingAccesses (
1098
1089
AA::RangeTy Range,
@@ -1382,7 +1373,6 @@ struct AAPointerInfoImpl
1382
1373
1383
1374
const auto &OtherAAImpl = static_cast <const AAPointerInfoImpl &>(OtherAA);
1384
1375
bool IsByval = OtherAAImpl.getAssociatedArgument ()->hasByValAttr ();
1385
- ReachesReturn = OtherAAImpl.ReachesReturn ;
1386
1376
1387
1377
// Combine the accesses bin by bin.
1388
1378
ChangeStatus Changed = ChangeStatus::UNCHANGED;
@@ -1676,13 +1666,8 @@ ChangeStatus AAPointerInfoFloating::updateImpl(Attributor &A) {
1676
1666
}
1677
1667
if (isa<PtrToIntInst>(Usr))
1678
1668
return false ;
1679
- if (isa<CastInst>(Usr) || isa<SelectInst>(Usr))
1669
+ if (isa<CastInst>(Usr) || isa<SelectInst>(Usr) || isa<ReturnInst>(Usr) )
1680
1670
return HandlePassthroughUser (Usr, CurPtr, Follow);
1681
- // Returns are allowed if they are in the associated functions. Users can
1682
- // then check the call site return. Returns from other functions can't be
1683
- // tracked and are cause for invalidation.
1684
- if (auto *RI = dyn_cast<ReturnInst>(Usr))
1685
- return ReachesReturn = RI->getFunction () == getAssociatedFunction ();
1686
1671
1687
1672
// For PHIs we need to take care of the recurrence explicitly as the value
1688
1673
// might change while we iterate through a loop. For now, we give up if
@@ -1913,37 +1898,15 @@ ChangeStatus AAPointerInfoFloating::updateImpl(Attributor &A) {
1913
1898
DepClassTy::REQUIRED);
1914
1899
if (!CSArgPI)
1915
1900
return false ;
1916
- bool IsArgMustAcc = (getUnderlyingObject (CurPtr) == &AssociatedValue);
1901
+ bool IsMustAcc = (getUnderlyingObject (CurPtr) == &AssociatedValue);
1917
1902
Changed = translateAndAddState (A, *CSArgPI, OffsetInfoMap[CurPtr], *CB,
1918
- IsArgMustAcc) |
1919
- Changed;
1920
- if (!CSArgPI->reachesReturn ())
1921
- return isValidState ();
1922
-
1923
- Function *Callee = CB->getCalledFunction ();
1924
- if (!Callee || Callee->arg_size () <= ArgNo)
1925
- return false ;
1926
- bool UsedAssumedInformation = false ;
1927
- auto ReturnedValue = A.getAssumedSimplified (
1928
- IRPosition::returned (*Callee), *this , UsedAssumedInformation,
1929
- AA::ValueScope::Intraprocedural);
1930
- auto *ReturnedArg =
1931
- dyn_cast_or_null<Argument>(ReturnedValue.value_or (nullptr ));
1932
- auto *Arg = Callee->getArg (ArgNo);
1933
- if (ReturnedArg && Arg != ReturnedArg)
1934
- return true ;
1935
- bool IsRetMustAcc = IsArgMustAcc && (ReturnedArg == Arg);
1936
- const auto *CSRetPI = A.getAAFor <AAPointerInfo>(
1937
- *this , IRPosition::callsite_returned (*CB), DepClassTy::REQUIRED);
1938
- if (!CSRetPI)
1939
- return false ;
1940
- Changed = translateAndAddState (A, *CSRetPI, OffsetInfoMap[CurPtr], *CB,
1941
- IsRetMustAcc) |
1903
+ IsMustAcc) |
1942
1904
Changed;
1943
1905
return isValidState ();
1944
1906
}
1945
1907
LLVM_DEBUG (dbgs () << " [AAPointerInfo] Call user not handled " << *CB
1946
1908
<< " \n " );
1909
+ // TODO: Allow some call uses
1947
1910
return false ;
1948
1911
}
1949
1912
@@ -2379,10 +2342,8 @@ struct AANoFreeFloating : AANoFreeImpl {
2379
2342
Follow = true ;
2380
2343
return true ;
2381
2344
}
2382
- if (isa<StoreInst>(UserI) || isa<LoadInst>(UserI))
2383
- return true ;
2384
-
2385
- if (isa<ReturnInst>(UserI) && getIRPosition ().isArgumentPosition ())
2345
+ if (isa<StoreInst>(UserI) || isa<LoadInst>(UserI) ||
2346
+ isa<ReturnInst>(UserI))
2386
2347
return true ;
2387
2348
2388
2349
// Unknown user.
@@ -12789,7 +12750,7 @@ struct AAAllocationInfoImpl : public AAAllocationInfo {
12789
12750
if (!PI)
12790
12751
return indicatePessimisticFixpoint ();
12791
12752
12792
- if (!PI->getState ().isValidState () || PI-> reachesReturn () )
12753
+ if (!PI->getState ().isValidState ())
12793
12754
return indicatePessimisticFixpoint ();
12794
12755
12795
12756
const DataLayout &DL = A.getDataLayout ();
0 commit comments