-
Notifications
You must be signed in to change notification settings - Fork 12k
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
Missing extension attributes in tests #115564
Comments
@llvm/issue-subscribers-mlir Author: Jonas Paulsson (JonPsson1)
As argument extensions are needed for correctness, I have been working on going through the code base for cases where they are missing. In mlir, I have now found a few, that I would need help with. In particular, I don't know where these functions are emitted, or how to add the proper Attributes (CreateRuntimeFunction? /.td file?). These are the tests that fail, with the problematic function printed as well:
Thanks for any help here. Adding people I find in the logs: |
Thanks for raising this! What are "argument extensions"? 😅 |
A few targets - like SystemZ - has per their ABI a requirement that integer arguments are extended before passed / returned to another function. On SystemZ, e.g. an i32 argument must be either sign or zero extended to the full register width (64 bits). This really must be done by the caller (/return instruction), as the other function is free to assume that this is always done. The general reasoning for these extension attributes are that some targets care about them, and targets who don't are free to ignore them if present. As an example, I recently fixed a case of this: 76a52db. As the test shows, the attributes are added on SystemZ. |
Please note that this verification step producing these errors only exists so far in the SystemZ backend, so you will not see these errors normally. |
So for example, I can see that mlir/test/mlir-cpu-runner/simple.mlir fails because it generates the LLVM I/R
which should be
(assuming that @int32_main return value is signed) I wonder where exactly this:
becomes the LLVM I/R function above..? |
I have managed to track down the actual creation of the IR Function to happen in ModuleTranslation::convertFunctionSignatures(). What I see is that in this .mlir test file, there exists:
So this is an arbitrarily defined function without any signext/zeroext attribute on the return value. Now I wonder if there is even such a thing in the MLIR module?
If this is a huge task, or if it's not relevant, perhaps the verification step could be disabled (for now) like, for llc ( @nikic Any thoughts on this? |
MLIR's LLVM dialect also supports That said, the tests you are looking at use LLVM IR as input, right? I think the issue you're mainly hitting is that LLVM IR tends to very target dependent already, especially in the regards of ABI. Sure, you could add ABI attributes and make it work for SystemZ but then it might not work on other targets. IMO it'd be reasonable to disable these tests on SystemZ using a |
I think for these tests it would make sense to use (Now, if we say started with ClangIR and then ended up in this position, that would be a different matter.) |
thanks! - good to know.
In at least one of them, the input is an mlir module (see previous post). May be LLVM IR in the others...
That seems like a reasonable option, at least for tests that were written in LLVM I/R. On the other hand, like @nikic wrote, these tests aren't intented for a specific ABI, so if it would be possible to use the VerifyArgABICompliance TargetInfo flag that might be simple enough (I suppose for mlir-cpu-runner.cpp this might work?) |
I first tried to see if I could use TargetOptions like with llc, but that did not seem straightforward as it is not declared anywhere as in llc.cpp, at least not what I could see. I then tried to update the tests as best I could, which seems to work fine. Instead of duplicating the test, I disable the check on the RUN-line, which I guess works well as it is just in one file, I'd say. Patch proposed here: #116314 |
As argument extensions are needed for correctness, I have been working on going through the code base for cases where they are missing. In mlir, I have now found a few, that I would need help with. In particular, I don't know where these functions are emitted, or how to add the proper Attributes (CreateRuntimeFunction? /.td file?). These are the tests that fail, with the problematic function printed as well:
Thanks for any help here. Adding people I find in the logs:
@shahidact @dcaballe @banach-space @ienkovich @tblah @paulwalker-arm @brod4910 @CoTinker @Groverkss
The text was updated successfully, but these errors were encountered: