[llvm] [DirectX] Use an allow-list of DXIL compatible module metadata (PR #165290)
Joshua Batista via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 27 12:07:16 PDT 2025
================
@@ -426,19 +436,17 @@ static void translateGlobalMetadata(Module &M, DXILResourceMap &DRM,
cleanModuleFlags(M);
- // dx.rootsignatures will have been parsed from its metadata form as its
- // binary form as part of the RootSignatureAnalysisWrapper, so safely
- // remove it as it is not recognized in DXIL
- if (NamedMDNode *RootSignature = M.getNamedMetadata("dx.rootsignatures"))
- RootSignature->eraseFromParent();
-
- // llvm.errno.tbaa was recently added but is not supported in LLVM 3.7 and
- // causes all tests using the DXIL Validator to fail.
- //
- // This is a temporary fix and should be replaced with a allowlist once
- // we have determined all metadata that the DXIL Validator allows
- if (NamedMDNode *ErrNo = M.getNamedMetadata("llvm.errno.tbaa"))
- ErrNo->eraseFromParent();
+ // Finally, strip all module metadata that is not explicitly specified in the
+ // allow-list
+ SmallVector<NamedMDNode *> ToStrip;
+
+ for (NamedMDNode &NamedMD : M.named_metadata())
+ if (!NamedMD.getName().starts_with("llvm.dbg.") &&
+ !llvm::is_contained(CompatibleNamedModuleMDs, NamedMD.getName()))
+ ToStrip.push_back(&NamedMD);
----------------
bob80905 wrote:
nit: Is the reason you don't erasefromparent right here because the for loop's iteration would skip over the next node?
I vaguely recall an std:: function that enabled deletion within a for loop without needing to make a separate list.
https://github.com/llvm/llvm-project/pull/165290
More information about the llvm-commits
mailing list