|
15 | 15 | #include "llvm/ADT/Twine.h" |
16 | 16 | #include "llvm/Analysis/DXILMetadataAnalysis.h" |
17 | 17 | #include "llvm/Analysis/DXILResource.h" |
18 | | -#include "llvm/IR/BasicBlock.h" |
19 | 18 | #include "llvm/IR/Constants.h" |
20 | 19 | #include "llvm/IR/DiagnosticInfo.h" |
21 | 20 | #include "llvm/IR/DiagnosticPrinter.h" |
22 | 21 | #include "llvm/IR/Function.h" |
23 | 22 | #include "llvm/IR/IRBuilder.h" |
24 | 23 | #include "llvm/IR/LLVMContext.h" |
25 | | -#include "llvm/IR/MDBuilder.h" |
26 | 24 | #include "llvm/IR/Metadata.h" |
27 | 25 | #include "llvm/IR/Module.h" |
28 | 26 | #include "llvm/InitializePasses.h" |
@@ -302,39 +300,6 @@ static MDTuple *emitTopLevelLibraryNode(Module &M, MDNode *RMD, |
302 | 300 | return constructEntryMetadata(nullptr, nullptr, RMD, Properties, Ctx); |
303 | 301 | } |
304 | 302 |
|
305 | | -// TODO: We might need to refactor this to be more generic, |
306 | | -// in case we need more metadata to be replaced. |
307 | | -static void translateBranchMetadata(Module &M) { |
308 | | - for (Function &F : M) { |
309 | | - for (BasicBlock &BB : F) { |
310 | | - Instruction *BBTerminatorInst = BB.getTerminator(); |
311 | | - |
312 | | - MDNode *HlslControlFlowMD = |
313 | | - BBTerminatorInst->getMetadata("hlsl.controlflow.hint"); |
314 | | - |
315 | | - if (!HlslControlFlowMD) |
316 | | - continue; |
317 | | - |
318 | | - assert(HlslControlFlowMD->getNumOperands() == 2 && |
319 | | - "invalid operands for hlsl.controlflow.hint"); |
320 | | - |
321 | | - MDBuilder MDHelper(M.getContext()); |
322 | | - ConstantInt *Op1 = |
323 | | - mdconst::extract<ConstantInt>(HlslControlFlowMD->getOperand(1)); |
324 | | - |
325 | | - SmallVector<llvm::Metadata *, 2> Vals( |
326 | | - ArrayRef<Metadata *>{MDHelper.createString("dx.controlflow.hints"), |
327 | | - MDHelper.createConstant(Op1)}); |
328 | | - |
329 | | - MDNode *MDNode = llvm::MDNode::get(M.getContext(), Vals); |
330 | | - |
331 | | - BBTerminatorInst->setMetadata("dx.controlflow.hints", MDNode); |
332 | | - BBTerminatorInst->setMetadata("hlsl.controlflow.hint", nullptr); |
333 | | - } |
334 | | - F.clearMetadata(); |
335 | | - } |
336 | | -} |
337 | | - |
338 | 303 | static void translateMetadata(Module &M, DXILBindingMap &DBM, |
339 | 304 | DXILResourceTypeMap &DRTM, |
340 | 305 | const Resources &MDResources, |
@@ -407,7 +372,6 @@ PreservedAnalyses DXILTranslateMetadata::run(Module &M, |
407 | 372 | const dxil::ModuleMetadataInfo MMDI = MAM.getResult<DXILMetadataAnalysis>(M); |
408 | 373 |
|
409 | 374 | translateMetadata(M, DBM, DRTM, MDResources, ShaderFlags, MMDI); |
410 | | - translateBranchMetadata(M); |
411 | 375 |
|
412 | 376 | return PreservedAnalyses::all(); |
413 | 377 | } |
@@ -445,7 +409,6 @@ class DXILTranslateMetadataLegacy : public ModulePass { |
445 | 409 | getAnalysis<DXILMetadataAnalysisWrapperPass>().getModuleMetadata(); |
446 | 410 |
|
447 | 411 | translateMetadata(M, DBM, DRTM, MDResources, ShaderFlags, MMDI); |
448 | | - translateBranchMetadata(M); |
449 | 412 | return true; |
450 | 413 | } |
451 | 414 | }; |
|
0 commit comments