This patch adds Win32 to the list of supported triples in
fir::CodeGenSpecifics. This change means that we can use the "native"
triple, even when running tests on Windows. Currently this affects only
1 test, but it will change once we start adding more tests for lowering
and code-generation.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
This change is required for the unit test from https://reviews.llvm.org/D119012 to pass on Windows (it uses the "native" triple).
Out of curiosity, how much has this been tested? I wouldn't be surprised if there are some gotcha differences between the Windows and Linux ABIs...
flang/lib/Optimizer/CodeGen/Target.cpp | ||
---|---|---|
241 |
Out of curiosity, how much has this been tested?
Diana is experimenting on Windows. That's probably it at the moment.
I wouldn't be surprised if there are some gotcha differences between the Windows and Linux ABIs...
Possibly. But we won't be able to test at all unless this code-path is enabled, right?
Have you tried this patch on fir-dev?
Yes and everything worked fine for me. Though I only tested on Linux (not sure that matters though, most/all tests seem to use --target=x86_64-unknown-linux-gnu).
I didn't see anything that would be OS (or ABI) specific in KindMapping, which is what fir::CodeGenSpecifics::get effectively returns. To me this looks like a fairly safe change to make.
Have you tried this patch on fir-dev?
Yes and everything worked fine for me. Though I only tested on Linux (not sure that matters though, most/all tests seem to use --target=x86_64-unknown-linux-gnu).
I didn't see anything that would be OS (or ABI) specific in KindMapping, which is what fir::CodeGenSpecifics::get effectively returns. To me this looks like a fairly safe change to make.
On our side we do not run any test suites on windows. I'm just hoping this does not cause problem while we upstream the rest of fir-dev.
It sounds that you are very unlikely to hit this case then (i.e. this is always going to be true in your test/dev env: triple != -{}-{}-windows-win32). But we do have Windows pre-merge and post-merge testing, so it's not like this is not tested at all.
I'm just hoping this does not cause problem while we upstream the rest of fir-dev.
Upstreaming remains our top-priority. If this change becomes a blocker, we can revert it.
I don't follow that.
The KindMap is not related to the target machine. It is effectively a mini-language to allow support for different dialects of Fortran that may use or reassign KIND values (in the source syntax) as a form of future-proofing the optimizer. (It's a source code thing.)
Code gen to a specific target can and does depend on what the target (triple) is from the user, the ABI(s) of that target, and how the LLVM machine code expects to see aspects of the LLVM IR presented to produce the correct calls, memory layouts, etc. flang has to follow in clang's footsteps in that regard as different LLVM backends expect different types, etc. (The target is a codegen thing.)
@schweitz, I referred to KindMap as that's one of the things that's returned by fir::CodeGenSpecifics::get. I think that we agree that it's rather OS-agnostic and in this respect, this change is safe.
Code gen to a specific target can and does depend on what the target (triple) is from the user, the ABI(s) of that target, and how the LLVM machine code expects to see aspects of the LLVM IR presented to produce the correct calls, memory layouts, etc. flang has to follow in clang's footsteps in that regard as different LLVM backends expect different types, etc. (The target is a codegen thing.)
Noted. This is currently expressed via e.g TargetI386 or TargetAArch64, right? These structs contain architecture-specific information, but I don't see anything OS-specific. For this reason, I feel that it is safe to enable Win32 here. This way:
- we can keep our tests more generic (i.e. avoid using --target when the generated code is target-agnostic),
- we avoid reducing the test coverage on Windows.
I think that we all agree that more work will be required to make sure that all ABIs work as expected. But we can re-visit this in due time and fine-tune things as required. For now, basic tests on Windows (and MacOSX, but that's on fir-dev) hit llvm::report_fatal_error unless the triple is hard-coded. But we run our CI on these platforms, fir::CodeGenSpecifics::get is OS-agnostic (am I missing something here?), so why not include Win32 (and MacOSX) here?