[clang] [llvm] [HLSL] Adding Flatten and Branch if attributes (PR #116331)
Chris B via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 3 07:27:17 PST 2024
================
@@ -300,6 +301,36 @@ static MDTuple *emitTopLevelLibraryNode(Module &M, MDNode *RMD,
return constructEntryMetadata(nullptr, nullptr, RMD, Properties, Ctx);
}
+// TODO: We might need to refactor this to be more generic,
+// in case we need more metadata to be replaced.
+static void translateBranchMetadata(Module &M) {
+ for (auto &F : M) {
+ for (auto &BB : F) {
+ auto *BBTerminatorInst = BB.getTerminator();
+
+ auto *HlslControlFlowMD =
+ BBTerminatorInst->getMetadata("hlsl.controlflow.hint");
+
+ if (!HlslControlFlowMD || HlslControlFlowMD->getNumOperands() < 2)
----------------
llvm-beanz wrote:
Huh? `getMetadata` returns `null` on failure (hence the null check). If it finds the named metadata, it must have two operands right? You even have this asserting on the SPIR-V side.
https://github.com/llvm/llvm-project/pull/116331
More information about the cfe-commits
mailing list