From a2ff6db52b222c69e98b5f3a99a2ab9922be9b0a Mon Sep 17 00:00:00 2001 From: xlauko Date: Tue, 17 Sep 2024 15:15:02 +0200 Subject: [PATCH] conv: Make hl.var with lvalue illegal in LowerValueCategoriesPass. --- lib/vast/Conversion/Generic/LowerValueCategories.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/vast/Conversion/Generic/LowerValueCategories.cpp b/lib/vast/Conversion/Generic/LowerValueCategories.cpp index f3f8295924..8587d491fd 100644 --- a/lib/vast/Conversion/Generic/LowerValueCategories.cpp +++ b/lib/vast/Conversion/Generic/LowerValueCategories.cpp @@ -482,12 +482,17 @@ namespace vast::conv { populate(unary_in_place_conversions{}, patterns, trg, mctx, tc); populate(assign_conversions{}, patterns, trg, mctx, tc); - auto is_legal = [&](auto op) { + auto is_legal = [&](operation op) { return tc.template get_has_legal_return_type< operation >()(op) && tc.template get_has_legal_operand_types< operation >()(op); }; + trg.markUnknownOpDynamicallyLegal(is_legal); + trg.addDynamicallyLegalOp< hl::VarDeclOp >([&](hl::VarDeclOp op) { + return !mlir::isa< hl::LValueType >(op.getType()); + }); + // As we go and replace operands, sometimes it can happen that this cast // already will be in form `hl.ptr< T > -> T` instead of `hl.lvalue< T > -> T`. // I am not sure why this is happening, quite possibly some pattern is doing