1. [CSSPGO] Fix dangling context strings and improve profile order consistency and error handling (details)
  2. [IVUsers] Check LoopSimplify cache earlier (NFC) (details)
  3. [NFC][CVP] Add tests for @llvm.[us]{min,max}() intrinsics (details)
  4. [CVP] @llvm.[us]{min,max}() intrinsics handling (details)
Commit 00ef28ef21f0a46059203c5aa96e9febe1192e43 by aktoon
[CSSPGO] Fix dangling context strings and improve profile order consistency and error handling

This patch fixed the following issues along side with some refactoring:

1. Fix bugs where StringRef for context string out live the underlying std::string. We now keep string table in profile generator to hold std::strings. We also do the same for bracketed context strings in profile writer.
2. Make sure profile output strictly follow (total sample, name) order. Previously, there's inconsistency between ProfileMap's key and FunctionSamples's name, leading to inconsistent ordering. This is now fixed by introducing context profile canonicalization. Assertions are also added to make sure ProfileMap's key and FunctionSamples's name are always consistent.
3. Enhanced error handling for profile writing to make sure we bubble up errors properly for both llvm-profgen and llvm-profdata when string table is not populated correctly for extended binary profile.
4. Keep all internal context representation bracket free. This avoids creating new strings for context trimming, merging and preinline. getNameWithContext API is now simplied accordingly.
5. Factor out the code for context trimming and merging into SampleContextTrimmer in SampleProf.cpp. This enables llvm-profdata to use the trimmer when merging profiles. Changes in llvm-profgen will be in separate patch.

Differential Revision:
The file was modifiedllvm/tools/llvm-profgen/ProfileGenerator.h
The file was modifiedllvm/tools/llvm-profdata/llvm-profdata.cpp
The file was modifiedllvm/test/tools/llvm-profgen/recursion-compression-pseudoprobe.test
The file was modifiedllvm/lib/ProfileData/SampleProf.cpp
The file was modifiedllvm/tools/llvm-profgen/CSPreInliner.cpp
The file was modifiedllvm/tools/llvm-profgen/ProfileGenerator.cpp
The file was modifiedllvm/include/llvm/ProfileData/SampleProfWriter.h
The file was modifiedllvm/test/tools/llvm-profgen/recursion-compression-noprobe.test
The file was modifiedllvm/lib/ProfileData/SampleProfWriter.cpp
The file was modifiedllvm/include/llvm/ProfileData/SampleProf.h
Commit 8de2f1ff79aa2a8a72b8c44ea70b48aa9f282ae5 by nikita.ppv
[IVUsers] Check LoopSimplify cache earlier (NFC)

Check the cache before calling isLoopSimplifyForm(). Otherwise we'd
always perform the check for the innermost loop and only skip it
for dominating loops.
The file was modifiedllvm/lib/Analysis/IVUsers.cpp
Commit d610f051045163f781ebc6da2e97414deafecd1e by lebedev.ri
[NFC][CVP] Add tests for @llvm.[us]{min,max}() intrinsics
The file was addedllvm/test/Transforms/CorrelatedValuePropagation/min-max.ll
Commit 9829f5e6b1bca9b61efc629770d28bb9014dec45 by lebedev.ri
[CVP] @llvm.[us]{min,max}() intrinsics handling

If we can tell that either one of the arguments is taken,
bypass the intrinsic.

Notably, we are indeed fine with non-strict predicate:
* UL:
* UG:
* SL:
* SG:

Much like with all other comparison handling in CVP,
while we could sort-of handle two Value's,
at least for plain ICmpInst it does not appear to be worthwhile.

This only fires 78 times on test-suite + dt + rs,
but we don't canonicalize to these yet. (only SCEV produces them)
The file was modifiedllvm/test/Transforms/CorrelatedValuePropagation/min-max.ll
The file was modifiedllvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp
The file was modifiedllvm/include/llvm/Analysis/LazyValueInfo.h
The file was modifiedllvm/lib/Analysis/LazyValueInfo.cpp