[clang] [llvm] [SPIRV][AMDGPU][clang][CodeGen][opt] Add late-resolved feature identifying predicates (PR #134016)

Juan Manuel Martinez CaamaƱo via cfe-commits cfe-commits at lists.llvm.org
Fri Feb 6 01:32:05 PST 2026


================
@@ -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;
----------------
jmmartinez wrote:

Haven't tried to be honest, but doesn't the frontend pass `-discard-value-names` on release builds? In that case the value names for non-global types would be dropped afaik.

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


More information about the cfe-commits mailing list