@@ -1621,13 +1621,6 @@ ChangeStatus AAPointerInfoFloating::updateImpl(Attributor &A) {
1621
1621
return true ;
1622
1622
};
1623
1623
1624
- const auto *F = getAnchorScope ();
1625
- const auto *CI =
1626
- F ? A.getInfoCache ().getAnalysisResultForFunction <CycleAnalysis>(*F)
1627
- : nullptr ;
1628
- const auto *TLI =
1629
- F ? A.getInfoCache ().getTargetLibraryInfoForFunction (*F) : nullptr ;
1630
-
1631
1624
auto UsePred = [&](const Use &U, bool &Follow) -> bool {
1632
1625
Value *CurPtr = U.get ();
1633
1626
User *Usr = U.getUser ();
@@ -1671,18 +1664,18 @@ ChangeStatus AAPointerInfoFloating::updateImpl(Attributor &A) {
1671
1664
// For PHIs we need to take care of the recurrence explicitly as the value
1672
1665
// might change while we iterate through a loop. For now, we give up if
1673
1666
// the PHI is not invariant.
1674
- if (isa <PHINode>(Usr)) {
1667
+ if (auto *PHI = dyn_cast <PHINode>(Usr)) {
1675
1668
// Note the order here, the Usr access might change the map, CurPtr is
1676
1669
// already in it though.
1677
- bool IsFirstPHIUser = !OffsetInfoMap.count (Usr );
1678
- auto &UsrOI = OffsetInfoMap[Usr ];
1670
+ bool IsFirstPHIUser = !OffsetInfoMap.count (PHI );
1671
+ auto &UsrOI = OffsetInfoMap[PHI ];
1679
1672
auto &PtrOI = OffsetInfoMap[CurPtr];
1680
1673
1681
1674
// Check if the PHI operand has already an unknown offset as we can't
1682
1675
// improve on that anymore.
1683
1676
if (PtrOI.isUnknown ()) {
1684
1677
LLVM_DEBUG (dbgs () << " [AAPointerInfo] PHI operand offset unknown "
1685
- << *CurPtr << " in " << *Usr << " \n " );
1678
+ << *CurPtr << " in " << *PHI << " \n " );
1686
1679
Follow = !UsrOI.isUnknown ();
1687
1680
UsrOI.setUnknown ();
1688
1681
return true ;
@@ -1705,7 +1698,8 @@ ChangeStatus AAPointerInfoFloating::updateImpl(Attributor &A) {
1705
1698
auto It = OffsetInfoMap.find (CurPtrBase);
1706
1699
if (It == OffsetInfoMap.end ()) {
1707
1700
LLVM_DEBUG (dbgs () << " [AAPointerInfo] PHI operand is too complex "
1708
- << *CurPtr << " in " << *Usr << " \n " );
1701
+ << *CurPtr << " in " << *PHI
1702
+ << " (base: " << *CurPtrBase << " )\n " );
1709
1703
UsrOI.setUnknown ();
1710
1704
Follow = true ;
1711
1705
return true ;
@@ -1718,6 +1712,9 @@ ChangeStatus AAPointerInfoFloating::updateImpl(Attributor &A) {
1718
1712
// Cycles reported by CycleInfo. It is sufficient to check the PHIs in
1719
1713
// every Cycle header; if such a node is marked unknown, this will
1720
1714
// eventually propagate through the whole net of PHIs in the recurrence.
1715
+ const auto *CI =
1716
+ A.getInfoCache ().getAnalysisResultForFunction <CycleAnalysis>(
1717
+ *PHI->getFunction ());
1721
1718
if (mayBeInCycle (CI, cast<Instruction>(Usr), /* HeaderOnly */ true )) {
1722
1719
auto BaseOI = It->getSecond ();
1723
1720
BaseOI.addToAll (Offset.getZExtValue ());
@@ -1729,7 +1726,7 @@ ChangeStatus AAPointerInfoFloating::updateImpl(Attributor &A) {
1729
1726
1730
1727
LLVM_DEBUG (
1731
1728
dbgs () << " [AAPointerInfo] PHI operand pointer offset mismatch "
1732
- << *CurPtr << " in " << *Usr << " \n " );
1729
+ << *CurPtr << " in " << *PHI << " \n " );
1733
1730
UsrOI.setUnknown ();
1734
1731
Follow = true ;
1735
1732
return true ;
@@ -1882,6 +1879,8 @@ ChangeStatus AAPointerInfoFloating::updateImpl(Attributor &A) {
1882
1879
if (auto *CB = dyn_cast<CallBase>(Usr)) {
1883
1880
if (CB->isLifetimeStartOrEnd ())
1884
1881
return true ;
1882
+ const auto *TLI =
1883
+ A.getInfoCache ().getTargetLibraryInfoForFunction (*CB->getFunction ());
1885
1884
if (getFreedOperand (CB, TLI) == U)
1886
1885
return true ;
1887
1886
if (CB->isArgOperand (&U)) {
0 commit comments