[llvm-branch-commits] [clang] [CIR] Make UndefAttr use AttrBuilderWithInferredContext (PR #136605)
Henrich Lauko via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Mon Apr 21 13:26:07 PDT 2025
https://github.com/xlauko created https://github.com/llvm/llvm-project/pull/136605
None
>From 40e72ddd5b2afc2fd83070822bb6aa1294e873fe Mon Sep 17 00:00:00 2001
From: xlauko <xlauko at mail.muni.cz>
Date: Mon, 21 Apr 2025 22:03:35 +0200
Subject: [PATCH] [CIR] Make UndefAttr use AttrBuilderWithInferredContext
---
clang/include/clang/CIR/Dialect/IR/CIRAttrs.td | 7 +++++++
clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp | 4 ++--
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
index 214db1b1caeeb..dfe15a10fa54e 100644
--- a/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
+++ b/clang/include/clang/CIR/Dialect/IR/CIRAttrs.td
@@ -93,6 +93,13 @@ def UndefAttr : CIR_Attr<"Undef", "undef", [TypedAttrInterface]> {
}];
let parameters = (ins AttributeSelfTypeParameter<"">:$type);
+
+ let builders = [
+ AttrBuilderWithInferredContext<(ins "mlir::Type":$type), [{
+ return $_get(type.getContext(), type);
+ }]>
+ ];
+
let assemblyFormat = [{}];
}
diff --git a/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp b/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp
index 9cd5c54e6c19e..fe8a5e7428a81 100644
--- a/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp
+++ b/clang/lib/CIR/Dialect/IR/CIRMemorySlot.cpp
@@ -34,8 +34,8 @@ llvm::SmallVector<MemorySlot> cir::AllocaOp::getPromotableSlots() {
Value cir::AllocaOp::getDefaultValue(const MemorySlot &slot,
OpBuilder &builder) {
- return builder.create<cir::ConstantOp>(
- getLoc(), slot.elemType, builder.getAttr<cir::UndefAttr>(slot.elemType));
+ return builder.create<cir::ConstantOp>(getLoc(), slot.elemType,
+ cir::UndefAttr::get(slot.elemType));
}
void cir::AllocaOp::handleBlockArgument(const MemorySlot &slot,
More information about the llvm-branch-commits
mailing list