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