Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mlir] Use the process (host) triple in MLIRTargetLLVMTests #69538

Merged
merged 1 commit into from
Oct 19, 2023

Conversation

sstamenova
Copy link
Contributor

The test is meant to execute on the native target and only initializes the native target. However, it then gets the default target triple instead of the process (host) triple. This fails in cases where the native target and the default target are not the same.

The test was added here: https://reviews.llvm.org/D154100

The default target triple might be set to something other than the host while the test is meant to run on the host
@llvmbot
Copy link
Member

llvmbot commented Oct 19, 2023

@llvm/pr-subscribers-mlir

@llvm/pr-subscribers-mlir-llvm

Author: Stella Stamenova (sstamenova)

Changes

The test is meant to execute on the native target and only initializes the native target. However, it then gets the default target triple instead of the process (host) triple. This fails in cases where the native target and the default target are not the same.

The test was added here: https://reviews.llvm.org/D154100


Full diff: https://github.com/llvm/llvm-project/pull/69538.diff

1 Files Affected:

  • (modified) mlir/unittests/Target/LLVM/SerializeToLLVMBitcode.cpp (+1-1)
diff --git a/mlir/unittests/Target/LLVM/SerializeToLLVMBitcode.cpp b/mlir/unittests/Target/LLVM/SerializeToLLVMBitcode.cpp
index c23ed7efd72fdf4..69c9d9b2f320202 100644
--- a/mlir/unittests/Target/LLVM/SerializeToLLVMBitcode.cpp
+++ b/mlir/unittests/Target/LLVM/SerializeToLLVMBitcode.cpp
@@ -55,7 +55,7 @@ TEST_F(MLIRTargetLLVM, SKIP_WITHOUT_NATIVE(SerializeToLLVMBitcode)) {
   ASSERT_TRUE(!!module);
 
   // Serialize the module.
-  std::string targetTriple = llvm::sys::getDefaultTargetTriple();
+  std::string targetTriple = llvm::sys::getProcessTriple();
   LLVM::ModuleToObject serializer(*(module->getOperation()), targetTriple, "",
                                   "");
   std::optional<SmallVector<char, 0>> serializedModule = serializer.run();

Copy link
Contributor

@fabianmcg fabianmcg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you for catching this!

@joker-eph
Copy link
Collaborator

Why would the test fail? It seems like just emitting LLVM IR and parsing it back which should not even require a target?

@@ -55,7 +55,7 @@ TEST_F(MLIRTargetLLVM, SKIP_WITHOUT_NATIVE(SerializeToLLVMBitcode)) {
ASSERT_TRUE(!!module);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fabianmcg : why is the test decorated with SKIP_WITHOUT_NATIVE ?

(I can't comment above, it's line 41)

@sstamenova
Copy link
Contributor Author

Why would the test fail? It seems like just emitting LLVM IR and parsing it back which should not even require a target?

It fails because the test code only registers the native target. The error is: loc("-":0:0): error: Failed to lookup target: No available targets are compatible with triple XYZ

@joker-eph
Copy link
Collaborator

Thanks @sstamenova, we could likely fix this and make it work without the native target, but that's probably not worth the effort considering what this test is about!

@sstamenova sstamenova merged commit 5e30c74 into llvm:main Oct 19, 2023
4 checks passed
@sstamenova sstamenova deleted the mlirtriple branch October 19, 2023 01:48
@fabianmcg
Copy link
Contributor

fabianmcg commented Oct 19, 2023

Why would the test fail? It seems like just emitting LLVM IR and parsing it back which should not even require a target?

The reason is that ModuleToObject always sets Target information. Thus, it fails if there's no valid target, that's also the reason the test is skipped when there's is no native target, as it fails with the error pointed by Stella.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants