[llvm] [DirectX] Legalize lifetime intrinsics for DXIL (PR #148003)

Deric C. via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 11 09:21:21 PDT 2025


================
@@ -2559,8 +2559,22 @@ void DXILBitcodeWriter::writeFunctionLevelValueSymbolTable(
   // to ensure the binary is the same no matter what values ever existed.
   SmallVector<const ValueName *, 16> SortedTable;
 
+  MallocAllocator Allocator;
   for (auto &VI : VST) {
-    SortedTable.push_back(VI.second->getValueName());
+    ValueName *VN = VI.second->getValueName();
+    // Clang mangles lifetime intrinsic names by appending '.p0' to the end,
+    // making them invalid lifetime intrinsics in LLVM 3.7. We can't
+    // demangle in dxil-prepare because it would result in invalid IR.
+    // Therefore we have to do this in the bitcode writer while writing its
+    // name to the symbol table.
+    if (const Function *Fn = dyn_cast<Function>(VI.getValue());
+        Fn && Fn->isIntrinsic()) {
----------------
Icohedron wrote:

Yea Farzon showed me it

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


More information about the llvm-commits mailing list