================
@@ -187,6 +187,19 @@ class OpLowerer {
     SmallVector<CallInst *> ToRemove;
     SmallVector<Function *> CastFns;
 
+    // Also pick up any `dx.resource.casthandle` calls that were introduced
+    // outside of this pass (e.g. by DXILResourceAccess when it emits DXIL
+    // ops directly). All such casts must be resolved here.
+    for (Function &F : M) {
+      if (!F.isDeclaration() ||
+          F.getIntrinsicID() != Intrinsic::dx_resource_casthandle)
+        continue;
+      for (User *U : F.users())
+        if (auto *CI = dyn_cast<CallInst>(U))
+          if (!llvm::is_contained(CleanupCasts, CI))
+            CleanupCasts.push_back(CI);
+    }
----------------
farzonl wrote:

Thank you for pointing this out Deric I missed this. DXILOpLoweing is a ful 
module pass. Something is wrong here that w are not taking advantage of 
existing module iterations. I think the right way to have done this would have 
been to pre-populate CleanupCasts  in an earlier function and not in 
`cleanupHandleCasts`. I don't think a new DirectX intrinsic is necessary. I 
think we need to follow the existing means of handeling cast cleanups.

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

Reply via email to