[clang] [CIR] Upstream TypeInfo attribute (PR #159426)
Henrich Lauko via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 18 02:13:06 PDT 2025
================
@@ -521,6 +522,20 @@ mlir::Value CIRAttrToValue::visitCirAttr(cir::GlobalViewAttr globalAttr) {
llvm_unreachable("Expecting pointer or integer type for GlobalViewAttr");
}
+// TypeInfoAttr visitor.
+mlir::Value CIRAttrToValue::visitCirAttr(cir::TypeInfoAttr typeinfoArr) {
+ mlir::Type llvmTy = converter->convertType(typeinfoArr.getType());
+ mlir::Location loc = parentOp->getLoc();
+ mlir::Value result = rewriter.create<mlir::LLVM::UndefOp>(loc, llvmTy);
+
+ for (auto [idx, elt] : llvm::enumerate(typeinfoArr.getData())) {
+ mlir::Value init = visit(elt);
+ result = rewriter.create<mlir::LLVM::InsertValueOp>(loc, result, init, idx);
----------------
xlauko wrote:
```suggestion
result = mlir::LLVM::InsertValueOp::create(rewriter, loc, result, init, idx);
```
https://github.com/llvm/llvm-project/pull/159426
More information about the cfe-commits
mailing list