From 7295d5a3f7d138920e2e0dccd096d3857395e62b Mon Sep 17 00:00:00 2001 From: Lukas Korencik Date: Tue, 27 Feb 2024 11:15:06 +0100 Subject: [PATCH] core: Fix linkage attribute parsing. --- include/vast/Dialect/Core/Func.hpp | 4 +--- lib/vast/Dialect/Core/Func.cpp | 24 +++++++++++++----------- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/include/vast/Dialect/Core/Func.hpp b/include/vast/Dialect/Core/Func.hpp index 83e5da6555..0268e74fed 100644 --- a/include/vast/Dialect/Core/Func.hpp +++ b/include/vast/Dialect/Core/Func.hpp @@ -58,9 +58,7 @@ namespace vast::core { Printer &printer, auto op, Attribute /* funcion_type */, mlir::DictionaryAttr, Region &body ) { - if (op.getLinkage() != core::GlobalLinkageKind::ExternalLinkage) { - printer << stringifyGlobalLinkageKind(op.getLinkage()) << ' '; - } + printer << stringifyGlobalLinkageKind(op.getLinkage()) << ' '; auto fty = op.getFunctionType(); mlir::function_interface_impl::printFunctionSignature( diff --git a/lib/vast/Dialect/Core/Func.cpp b/lib/vast/Dialect/Core/Func.cpp index f70b2856f0..fe8536931a 100644 --- a/lib/vast/Dialect/Core/Func.cpp +++ b/lib/vast/Dialect/Core/Func.cpp @@ -33,17 +33,6 @@ namespace vast::core ) { using core::GlobalLinkageKind; - // Default to external linkage if no keyword is provided. - attr_dict.append( - getLinkageAttrNameString(), - core::GlobalLinkageKindAttr::get( - parser.getContext(), - parse_optional_vast_keyword< GlobalLinkageKind >( - parser, GlobalLinkageKind::ExternalLinkage - ) - ) - ); - llvm::SmallVector< Parser::Argument, 8 > arguments; llvm::SmallVector< mlir::DictionaryAttr, 1 > result_attrs; llvm::SmallVector< Type, 8 > arg_types; @@ -78,6 +67,19 @@ namespace vast::core // builder, state, arguments, result_attrs // ); + // Default to external linkage if no keyword is provided. + if (!attr_dict.getNamed(getLinkageAttrNameString())) { + attr_dict.append( + getLinkageAttrNameString(), + core::GlobalLinkageKindAttr::get( + parser.getContext(), + parse_optional_vast_keyword< GlobalLinkageKind >( + parser, GlobalLinkageKind::ExternalLinkage + ) + ) + ); + } + auto loc = parser.getCurrentLocation(); auto parse_result = parser.parseOptionalRegion( body, arguments, /* enableNameShadowing */false