Files
clang-p2996/llvm/lib/Transforms/Utils/DXILUpgrade.cpp
Justin Bogner 71e3642619 [Transforms][DXIL] Wire up a basic DXILUpgrade pass (#66275)
This pass will upgrade DXIL-style llvm constructs (which are mostly
metadata) into the representations we use in LLVM for the same concepts.

For now we just strip the valver metadata, which we don't need. Later
changes will make this pass more useful, and then we should be able to
wire it into clang and possibly the DirectX backend's AsmParser.
2023-09-14 11:02:31 -07:00

37 lines
1.1 KiB
C++

//===- DXILUpgrade.cpp - Upgrade DXIL metadata to LLVM constructs ---------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include "llvm/Transforms/Utils/DXILUpgrade.h"
using namespace llvm;
static bool handleValVerMetadata(Module &M) {
NamedMDNode *ValVer = M.getNamedMetadata("dx.valver");
if (!ValVer)
return false;
// We don't need the validation version internally, so we drop it.
ValVer->dropAllReferences();
ValVer->eraseFromParent();
return true;
}
PreservedAnalyses DXILUpgradePass::run(Module &M, ModuleAnalysisManager &AM) {
PreservedAnalyses PA;
// We never add, remove, or change functions here.
PA.preserve<FunctionAnalysisManagerModuleProxy>();
PA.preserveSet<AllAnalysesOn<Function>>();
bool Changed = false;
Changed |= handleValVerMetadata(M);
if (!Changed)
return PreservedAnalyses::all();
return PA;
}