[clang] [llvm] [HLSL] Adding Flatten and Branch if attributes (PR #116331)

Chris B via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 17 08:51:51 PST 2024


================
@@ -295,6 +296,39 @@ 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");
----------------
llvm-beanz wrote:

nit: https://llvm.org/docs/CodingStandards.html#use-auto-type-deduction-to-make-code-more-readable
```suggestion
  for (Function &F : M) {
    for (BasicBlock &BB : F) {
      Inst *BBTerminatorInst = BB.getTerminator();

      MDNode *HlslControlFlowMD =
          BBTerminatorInst->getMetadata("hlsl.controlflow.hint");
```

https://github.com/llvm/llvm-project/pull/116331


More information about the cfe-commits mailing list