[clang] [CIR] Add poison attribute (PR #150760)
Henrich Lauko via cfe-commits
cfe-commits at lists.llvm.org
Sat Jul 26 11:21:44 PDT 2025
================
@@ -2239,16 +2249,18 @@ static OpFoldResult
foldUnaryBitOp(mlir::Attribute inputAttr,
llvm::function_ref<llvm::APInt(const llvm::APInt &)> func,
bool poisonZero = false) {
+ if (mlir::isa_and_present<PoisonAttr>(inputAttr)) {
+ // Propagate poison value
+ return inputAttr;
+ }
+
auto input = mlir::dyn_cast_if_present<IntAttr>(inputAttr);
if (!input)
return nullptr;
llvm::APInt inputValue = input.getValue();
- if (poisonZero && inputValue.isZero()) {
- // TODO(cir): maybe we should return a poison value here?
- assert(!MissingFeatures::poisonAttr());
- return nullptr;
- }
+ if (poisonZero && inputValue.isZero())
+ return PoisonAttr::get(input.getType());
----------------
xlauko wrote:
```suggestion
return cir::PoisonAttr::get(input.getType());
```
https://github.com/llvm/llvm-project/pull/150760
More information about the cfe-commits
mailing list