================
@@ -71,13 +81,66 @@ bool tryReplaceAliasWithAliasee(GlobalAlias &GA) {
   return true;
 }
 
+bool tryAssignPredicateSpecConstIDs(Module &M, Function *F) {
+  StringMap<unsigned> IDs;
+
+  // Replace placeholder Specialisation Constant IDs with unique IDs associated
+  // with the predicate being evaluated, which is encoded in the call name.
+  for (auto &&U : F->users()) {
+    if (!isa<CallInst>(U))
+      continue;
+
+    auto *CI = cast<CallInst>(U);
+
+    if (!isa<ConstantInt>(CI->getArgOperand(0)))
+      continue;
+
+    unsigned ID = cast<ConstantInt>(CI->getArgOperand(0))->getZExtValue();
+
+    if (ID != UINT32_MAX)
+      continue;
+
+    StringRef Name = CI->getName().substr(0, CI->getName().rfind('.'));
+    ID = IDs.try_emplace(Name, IDs.size()).first->second;
----------------
AlexVlx wrote:

That's an excellent catch, and something I was completely oblivious to - thank 
you! I've fixed this by using metadata to encode the the predicate.

https://github.com/llvm/llvm-project/pull/134016
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to