Closed llvmbot closed 9 years ago
OK. Let's look at things this way:
1) Whether or not to allow changing of target-cpu/target-feature/triple at link time code generation.
2) How to pass other sorts of options to the backend for code generation
3) The llvm developer debugging story
I'm going to go ahead and redirect this to the mailing list and close the bug so that the rest of this discussion can go there. :)
You brought it up and haven't even replied to the rest of my commentary.
llc is a low-level tool for LLVM developers.
Sure, the general idea still holds if you're going to allow overrides via the tools.
I disagree. There are two distinct questions here:
IMO, these questions are completely unrelated (putting aside whether infrastructure could be shared).
llc is a low-level tool for LLVM developers.
Sure, the general idea still holds if you're going to allow overrides via the tools.
shrug That's the question behind things like the llc overrides? :)
llc is a low-level tool for LLVM developers.
shrug That's the question behind things like the llc overrides? :)
That said I was actually envisioning something like:
clang -emit-llvm foo.c -o foo.bc ...
clang -O3 -flto all.bc -arch x86_64h -o haswell_slice clang -O3 -flto all.bc -arch x86_64 -o x86_64_slice
for the same set of bitcode files. But given the front end language restrictions on doing anything actually interesting there it's not too much of a constraint.
Another usage is the (admittedly one I don't think we want to support) halide one that I discovered this week:
clang foo.c -emit-llvm foo.bc clang -target aarch64-linux-gnu foo.bc -O3 -o foo.aarch64 clang -target x86_64-linux-gnu foo.bc -O3 -o foo.x86_64 ...
I've since convinced them to use the pnacl sort of thing for more target independent code generation at the moment. It's a use case that could be thought about more though.
We should probably allow people to override the defaults on the command line though.
Should that be a fully supported driver option? It feels like with the per function flag working it is best to just tell people to pass -mavx to the -c invocation.
I agree with Rafael. If overriding the defaults has any effect, isn't that a bug?
We should probably allow people to override the defaults on the command line though.
Should that be a fully supported driver option? It feels like with the per function flag working it is best to just tell people to pass -mavx to the -c invocation.
So, this is actually two different bugs:
a) that you can't pass code generation options to the lto process, b) that you can't do per function generation of code to take into account things like -mavx2 being used on a single translation unit.
b has been fixed as you'll see from:
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20150323/126563.html
We should probably allow people to override the defaults on the command line though.
Hi Mike,
This is a well-known bug. The problem is that during LTO the command line flags (and other information) are not passed to the code generator. There is a proposal in place to fix this, but it's not finished.
Extended Description
I found that
clang -O4 -mavx2 *.c
sets AVX2 in the frontend, but not during link-time optimization. The same may be true for other flags. This causes problems with code that tries to detect whether AVX2 (or possibly other features) are supported, since it will emit code designed for those features but they will not be present during link-time optimization.
The terminal transcript shows the bug in action. When compiled with -O3, AVX2 instructions are emitted, and when compiled with -O4, they are not. The transcript does not show that AVX2 is defined in the C file, but in fact it is.