[libcxx-commits] [PATCH] D74813: [RFC] Add hash of block contents to function block names

Alex Borcan via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Thu Apr 23 13:01:17 PDT 2020


alexbdv updated this revision to Diff 259684.
alexbdv marked an inline comment as done.

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74813/new/

https://reviews.llvm.org/D74813

Files:
  clang/lib/AST/Mangle.cpp


Index: clang/lib/AST/Mangle.cpp
===================================================================
--- clang/lib/AST/Mangle.cpp
+++ clang/lib/AST/Mangle.cpp
@@ -36,11 +36,18 @@
                                 StringRef Outer,
                                 const BlockDecl *BD,
                                 raw_ostream &Out) {
-  unsigned discriminator = Context.getBlockId(BD, true);
-  if (discriminator == 0)
-    Out << "__" << Outer << "_block_invoke";
-  else
-    Out << "__" << Outer << "_block_invoke_" << discriminator+1;
+  SmallString<256> ParamBuff;
+  llvm::raw_svector_ostream ParamTypes(ParamBuff);
+  for (ParmVarDecl *PVD : BD->parameters()) {
+    Context.mangleTypeName(PVD->getType(), ParamTypes);
+  }
+
+  llvm::MD5 Hash;
+  llvm::MD5::MD5Result Result;
+  Hash.update(ParamTypes.str());
+  Hash.final(Result);
+
+  Out << "__" << Outer << "_block_invoke_" << *(unsigned short*)&Result;
 }
 
 void MangleContext::anchor() { }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74813.259684.patch
Type: text/x-patch
Size: 957 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20200423/a63e782e/attachment.bin>


More information about the libcxx-commits mailing list