Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions jlm/mlir/RvsdgRoundtripTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -686,6 +686,8 @@ ROUNDTRIP_TEST(TestVariadicFunctionTest1, ::jlm::llvm::VariadicFunctionTest1)
ROUNDTRIP_TEST(TestVariadicFunctionTest2, ::jlm::llvm::VariadicFunctionTest2)
ROUNDTRIP_TEST(TestGamma, ::jlm::llvm::GammaTest)
ROUNDTRIP_TEST(TestImport, ::jlm::llvm::ImportTest)
ROUNDTRIP_TEST(TestEscapingLocalFunction, ::jlm::llvm::EscapingLocalFunctionTest)
ROUNDTRIP_TEST(TestLambdaCallArgumentMismatch, ::jlm::llvm::LambdaCallArgumentMismatch)

// NAllocaNodesTest is parameterized by the number of allocas, so it cannot use the
// default-constructing ROUNDTRIP_TEST macro.
Expand Down
13 changes: 7 additions & 6 deletions jlm/mlir/frontend/MlirToJlmConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1223,14 +1223,15 @@ MlirToJlmConverter::ConvertLambda(
}
auto functionType = rvsdg::FunctionType::Create(std::move(argumentTypes), std::move(resultTypes));

// FIXME
// The linkage should be part of the MLIR attributes so it can be extracted here
// Get the linkage attribute from the MLIR LambdaNode
auto linkageAttribute = mlirOperation.getAttr(::llvm::StringRef("linkage"));
JLM_ASSERT(linkageAttribute != nullptr);
auto linkageStr = ::mlir::cast<::mlir::StringAttr>(linkageAttribute);
auto linkage = llvm::linkageFromString(linkageStr.str());

Comment thread
phate marked this conversation as resolved.
auto rvsdgLambda = rvsdg::LambdaNode::Create(
rvsdgRegion,
llvm::LlvmLambdaOperation::Create(
functionType,
functionName.getValue().str(),
llvm::Linkage::externalLinkage));
llvm::LlvmLambdaOperation::Create(functionType, functionName.getValue().str(), linkage));

for (auto input : inputs)
{
Expand Down
25 changes: 24 additions & 1 deletion jlm/mlir/frontend/MlirToJlmConverterTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ TEST(MlirToJlmConverterTests, TestLambda)
auto attributeValue = Builder_->getStringAttr("test");
auto symbolName = Builder_->getNamedAttr(attributeName, attributeValue);
attributes.push_back(symbolName);
auto linkageName = Builder_->getStringAttr("linkage");
auto linkageValue = Builder_->getStringAttr("external_linkage");
auto linkage = Builder_->getNamedAttr(linkageName, linkageValue);
attributes.push_back(linkage);
::llvm::ArrayRef<::mlir::NamedAttribute> attributesRef(attributes);

// Add inputs to the function
Expand Down Expand Up @@ -185,6 +189,10 @@ TEST(MlirToJlmConverterTests, TestDivOperation)
auto attributeValue = Builder_->getStringAttr("test");
auto symbolName = Builder_->getNamedAttr(attributeName, attributeValue);
attributes.push_back(symbolName);
auto linkageName = Builder_->getStringAttr("linkage");
auto linkageValue = Builder_->getStringAttr("external_linkage");
auto linkage = Builder_->getNamedAttr(linkageName, linkageValue);
attributes.push_back(linkage);
::llvm::ArrayRef<::mlir::NamedAttribute> attributesRef(attributes);

// Add inputs to the function
Expand Down Expand Up @@ -377,6 +385,10 @@ TEST(MlirToJlmConverterTests, TestCompZeroExt)
auto attributeValue = Builder_->getStringAttr("test");
auto symbolName = Builder_->getNamedAttr(attributeName, attributeValue);
attributes.push_back(symbolName);
auto linkageName = Builder_->getStringAttr("linkage");
auto linkageValue = Builder_->getStringAttr("external_linkage");
auto linkage = Builder_->getNamedAttr(linkageName, linkageValue);
attributes.push_back(linkage);
::llvm::ArrayRef<::mlir::NamedAttribute> attributesRef(attributes);

// Add inputs to the function
Expand Down Expand Up @@ -601,6 +613,10 @@ TEST(MlirToJlmConverterTests, TestMatchOp)
auto attributeValue = Builder_->getStringAttr("test");
auto symbolName = Builder_->getNamedAttr(attributeName, attributeValue);
attributes.push_back(symbolName);
auto linkageName = Builder_->getStringAttr("linkage");
auto linkageValue = Builder_->getStringAttr("external_linkage");
auto linkage = Builder_->getNamedAttr(linkageName, linkageValue);
attributes.push_back(linkage);
::llvm::ArrayRef<::mlir::NamedAttribute> attributesRef(attributes);

// Add inputs to the function
Expand Down Expand Up @@ -773,6 +789,10 @@ TEST(MlirToJlmConverterTests, TestGammaOp)
auto attributeValue = Builder_->getStringAttr("test");
auto symbolName = Builder_->getNamedAttr(attributeName, attributeValue);
attributes.push_back(symbolName);
auto linkageName = Builder_->getStringAttr("linkage");
auto linkageValue = Builder_->getStringAttr("external_linkage");
auto linkage = Builder_->getNamedAttr(linkageName, linkageValue);
attributes.push_back(linkage);
::llvm::ArrayRef<::mlir::NamedAttribute> attributesRef(attributes);

// Add inputs to the function
Expand Down Expand Up @@ -925,6 +945,9 @@ TEST(MlirToJlmConverterTests, TestThetaOp)
auto attributeName = Builder_->getStringAttr("sym_name");
auto attributeValue = Builder_->getStringAttr("test");
auto symbolName = Builder_->getNamedAttr(attributeName, attributeValue);
auto linkageName = Builder_->getStringAttr("linkage");
auto linkageValue = Builder_->getStringAttr("external_linkage");
auto linkage = Builder_->getNamedAttr(linkageName, linkageValue);

auto iotype = Builder_->getType<IOStateEdgeType>();
auto memtype = Builder_->getType<MemStateEdgeType>();
Expand All @@ -937,7 +960,7 @@ TEST(MlirToJlmConverterTests, TestThetaOp)
::mlir::TypeRange({ iotype, memtype }),
::mlir::TypeRange({ iotype, memtype })),
::llvm::SmallVector<mlir::Value>(),
::llvm::ArrayRef<::mlir::NamedAttribute>({ symbolName }));
::llvm::ArrayRef<::mlir::NamedAttribute>({ symbolName, linkage }));
omegaBlock->push_back(lambda);
auto & lambdaRegion = lambda.getRegion();
auto * lambdaBlock = new mlir::Block;
Expand Down
Loading