[llvm] Add option to dump IR to files instead of stderr (PR #66412)

Nuri Amari via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 15 11:43:50 PDT 2023


================
@@ -684,9 +686,64 @@ PrintIRInstrumentation::~PrintIRInstrumentation() {
   assert(ModuleDescStack.empty() && "ModuleDescStack is not empty at exit");
 }
 
-void PrintIRInstrumentation::pushModuleDesc(StringRef PassID, Any IR) {
+static SmallString<32> getIRDisplayName(Any IR) {
+
+  auto hashName = [](StringRef name) {
----------------
NuriAmari wrote:

> I thought hashing strings is stable unless the seed for hashing is changed

I think this is true, and the seed doesn't even seem to change at the moment. That said it looks like the intention is to have it change between executions eventually.

https://github.com/llvm/llvm-project/blob/c60ccfbb898148449946f82cbac6140f1e01cb12/llvm/include/llvm/ADT/Hashing.h#L333-L343

That said, the comments are pretty clear that stability isn't to be relied upon so I think `stable_ash_combine_string` is better for our purposes.

https://github.com/llvm/llvm-project/blob/c60ccfbb898148449946f82cbac6140f1e01cb12/llvm/include/llvm/ADT/Hashing.h#L20-L24

https://github.com/llvm/llvm-project/pull/66412


More information about the llvm-commits mailing list