diff options
author | Farzon Lotfi <farzonlotfi@microsoft.com> | 2025-03-29 00:45:11 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-03-29 00:45:11 -0400 |
commit | 1e03408d4b17a792da5fd01b30f05ff055cfbd79 (patch) | |
tree | 77f5036cbd571c8108c4d3d65a97bbcc33d13ea0 /llvm/lib | |
parent | 2898c3e0bbf904c68efb194525bcdfeedb3014c2 (diff) | |
download | llvm-1e03408d4b17a792da5fd01b30f05ff055cfbd79.zip llvm-1e03408d4b17a792da5fd01b30f05ff055cfbd79.tar.gz llvm-1e03408d4b17a792da5fd01b30f05ff055cfbd79.tar.bz2 |
[DirectX] Remove intrinsic definitions with no use (#133459)
Do cleanup in DXILFinalizeLinkage.cpp where intrinsic declares are getting orphaned.
This change reduces "Unsupported intrinsic for DXIL lowering" errors
when compiling DML shaders from 12218 to 415. and improves our
compilation success rate from less than 1% to 44%.
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/DirectX/DXILFinalizeLinkage.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/Target/DirectX/DXILFinalizeLinkage.cpp b/llvm/lib/Target/DirectX/DXILFinalizeLinkage.cpp index 91ac758..7651617 100644 --- a/llvm/lib/Target/DirectX/DXILFinalizeLinkage.cpp +++ b/llvm/lib/Target/DirectX/DXILFinalizeLinkage.cpp @@ -18,7 +18,7 @@ using namespace llvm; static bool finalizeLinkage(Module &M) { - SmallPtrSet<Function *, 8> Funcs; + SmallVector<Function *> Funcs; // Collect non-entry and non-exported functions to set to internal linkage. for (Function &EF : M.functions()) { @@ -26,7 +26,7 @@ static bool finalizeLinkage(Module &M) { continue; if (EF.hasFnAttribute("hlsl.shader") || EF.hasFnAttribute("hlsl.export")) continue; - Funcs.insert(&EF); + Funcs.push_back(&EF); } for (Function *F : Funcs) { @@ -36,6 +36,14 @@ static bool finalizeLinkage(Module &M) { M.getFunctionList().erase(F); } + // Do a pass over intrinsics that are no longer used and remove them. + Funcs.clear(); + for (Function &F : M.functions()) + if (F.isIntrinsic() && F.use_empty()) + Funcs.push_back(&F); + for (Function *F : Funcs) + F->eraseFromParent(); + return false; } |