@@ -4895,8 +4895,13 @@ struct AAInstanceInfoImpl : public AAInstanceInfo {
4895
4895
const auto &ArgInstanceInfoAA = A.getAAFor <AAInstanceInfo>(
4896
4896
*this , IRPosition::callsite_argument (*CB, CB->getArgOperandNo (&U)),
4897
4897
DepClassTy::OPTIONAL);
4898
- if (ArgInstanceInfoAA.isAssumedUniqueForAnalysis ())
4899
- return true ;
4898
+ if (!ArgInstanceInfoAA.isAssumedUniqueForAnalysis ())
4899
+ return false ;
4900
+ // If this call base might reach the scope again we might forward the
4901
+ // argument back here. This is very conservative.
4902
+ if (AA::isPotentiallyReachable (A, *CB, *Scope, *this , nullptr ))
4903
+ return false ;
4904
+ return true ;
4900
4905
}
4901
4906
return false ;
4902
4907
};
@@ -5201,6 +5206,8 @@ ChangeStatus AANoCaptureImpl::updateImpl(Attributor &A) {
5201
5206
// AAReturnedValues, e.g., track all values that escape through returns
5202
5207
// directly somehow.
5203
5208
auto CheckReturnedArgs = [&](const AAReturnedValues &RVAA) {
5209
+ if (!RVAA.getState ().isValidState ())
5210
+ return false ;
5204
5211
bool SeenConstant = false ;
5205
5212
for (auto &It : RVAA.returned_values ()) {
5206
5213
if (isa<Constant>(It.first )) {
@@ -6433,6 +6440,8 @@ ChangeStatus AAHeapToStackFunction::updateImpl(Attributor &A) {
6433
6440
dbgs () << " [H2S] unique free call might free unknown allocations\n " );
6434
6441
return false ;
6435
6442
}
6443
+ if (DI->PotentialAllocationCalls .empty ())
6444
+ return true ;
6436
6445
if (DI->PotentialAllocationCalls .size () > 1 ) {
6437
6446
LLVM_DEBUG (dbgs () << " [H2S] unique free call might free "
6438
6447
<< DI->PotentialAllocationCalls .size ()
0 commit comments