Just like gcc, we should have the -Og option as more and more software are using it:
https://llvm.org/bugs/show_bug.cgi?id=20765
Details
Diff Detail
Event Timeline
Please include full context with your diff.
lib/Frontend/CompilerInvocation.cpp | ||
---|---|---|
101–103 | Please clang-format this. |
Hi Sylvestre,
Paul's comments on the bug are still pertinent: -Og is not the same as -O1.
-Og means for "optimised for debuggers" which is short for "preserve the debug illusion without bloating the code". This is not at all what -O1 is, even though they're used indistinguishably via -O1 -g.
As a stop-gap, I guess having -Og == -O1 would stop errors from being reported, but if we could do a quick assessment on the list to make sure this has the expected semantics (and adding a full new option if not), would be the best way forward.
I'm adding a few debug folks here, in hope they have a better idea (and would add more folks, if necessary). :)
cheers,
--renato
test/Driver/debug-options.c | ||
---|---|---|
21–22 | I don't think we need this test case: -Og doesn't actually have anything to do with -g mechanically speaking, so there's no need to test them together. I'd probably go find wherever -O1 is tested in the driver, and test -Og there. |
As Renato points out, this addresses the user experience of tripping over the lack of -Og, however it does not really address the intent of PR20765 which is to provide a mode of optimizations that don't particularly interfere with debugging.
Eventually someone needs to take on the project of "proper -Og" which might or might not result in -Og still matching -O1.
I am not opposed to starting out this way, but don't close the PR.
If we later get user complaints about how -Og interferes with debugging, well, then we'll have actual use-cases to work from, which is extremely helpful for this sort of optimization tuning.
test/Preprocessor/init.c | ||
---|---|---|
208 | check-prefix O1? Then you don't need the Og: and Og-NOT: lines. |
Looking into what optimisations would be relevant to -Og (or rather what optimisation should be omitted because they are too disruptive to the debug experience) is something that I have on my road-map as something to look into and gather feedback on.
I agree that this should be considered as just the starting point for enabling a fully functional -Og option.
I agree with Keith. This is a starting point, not a final destination.
As we evolve this, we can start looking at better ways to improve the debug illusion, but right now, O1 is probably the best thing to do.
LGTM, thanks!
This seems to have hit a recent Xcode toolchain (Xcode 9.1 ?).
Xcode now complains that "[app name] was compiled with optimization - stepping may behave oddly; variables may not be available.", when launching a debug session, which seems to be the case, debugging is all over the place :)
Reproduced on both macOS and iOS targets.
LLDB prints this warning whenever LLVM marks a compile unit with DW_AT_optimized (which LLVM does for everything but -O0).
Reproduced on both macOS and iOS targets.
Please clang-format this.