Comment by seanbax

1 day ago

The Profiles authors are the ones claiming this uses local analysis only: https://news.ycombinator.com/item?id=41942126

They are clear that Profiles infers everything from function types and not function bodies. Obviously that won't work, but that's what they say.

In that post (I think your own?) it says, "Local analysis only. It's not looking in function definitions."

But local analysis means analysis of function definitions. At least it does to me. I can't think of what else it could mean. I think there must be some aspect of people talking past each other here, using the same words to mean different things.

Further, I don't think local analysis of the code comprising a function means throwing away the results of that analysis rather than passing it up the line to the analysis of callers of the function. E.g., local analysis of std::sort would establish its aliasing limitations, which would be available to analysis of the body of "f1" from the example in the paper (the results of which, in turn, would be available to callers of f1).

Now, I don't know if that's actually feasible/workable without the "heavy" annotation that C++ profiles wants to forbid. That's the key question to me.

  •   template<typename _RandomAccessIterator>
        _GLIBCXX20_CONSTEXPR
        inline void
        sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
        {
          // concept requirements
          __glibcxx_function_requires(_Mutable_RandomAccessIteratorConcept<
         _RandomAccessIterator>)
          __glibcxx_function_requires(_LessThanComparableConcept<
         typename iterator_traits<_RandomAccessIterator>::value_type>)
          __glibcxx_requires_valid_range(__first, __last);
          __glibcxx_requires_irreflexive(__first, __last);
    
          std::__sort(__first, __last, __gnu_cxx::__ops::__iter_less_iter());
        }
    

    That's the definition of std::sort. What aliasing information can be gleaned from local analysis of the function? Absolutely nothing.