================
@@ -788,6 +797,17 @@ void LoopInfoStack::push(BasicBlock *Header, 
clang::ASTContext &Ctx,
     }
   }
 
+  // Identify loop attribute 'code_align' from Attrs.
+  // For attribute code_align:
+  // n - 'llvm.loop.align i32 n' metadata will be emitted.
+  for (const auto *A : Attrs) {
+    if (const auto *CodeAlign = dyn_cast<CodeAlignAttr>(A)) {
+      const auto *CE = cast<ConstantExpr>(CodeAlign->getAlignment());
+      llvm::APSInt ArgVal = CE->getResultAsAPSInt();
+      setCodeAlign(ArgVal.getSExtValue());
+    }
+  }
----------------
AaronBallman wrote:

```suggestion
  if (const auto *CodeAlign = getSpecificAttr<CodeAlignAttr>(Attrs)) {
    const auto *CE = cast<ConstantExpr>(CodeAlign->getAlignment());
    llvm::APSInt ArgVal = CE->getResultAsAPSInt();
    setCodeAlign(ArgVal.getSExtValue());
  }
```

https://github.com/llvm/llvm-project/pull/70762
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to