This is an archive of the discontinued LLVM Phabricator instance.

[LTO][Legacy] Update TargetOption after parsing debug options
AbandonedPublic

Authored by steven_wu on Jul 31 2019, 1:05 PM.

Details

Summary

The current libLTO implementation sets up the TargetOption for the
CodeGenerator when the CodeGenerator is created. That is before the
codegen commandline options are parsed because lto_codegen_debug_options
API takes CodeGenerator as a parameter. That causes the codegen options
(e.g. -tailcallopt) passing through lto_codegen_debug_options has no effect.
Fix the issue by updating TargetOptions after parsing commandline
options.

rdar://problem/53595173

Event Timeline

steven_wu created this revision.Jul 31 2019, 1:05 PM

Can you add a test case?

Implementation specific to lto.cpp is really hard to write a test. The TargetOptions are cl::opt bring in through "llvm/CodeGen/CommandFlags.inc" so we need a client for libLTO to test this (which we never had). Let me know if you have any suggestions.

I just discovered that there was a nearly identical patch to do this a few years ago, which generated a bunch of discussion and it seems that there was an agreement not to do this (relating to not exposing internal options through the C API, but I haven't parsed it in detail yet). See https://reviews.llvm.org/D19015

However, note that only about the first half of the discussion is on Phabricator, the other half was via email. Search for D19015 here: http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20160411/thread.html

Adding @mehdi_amini and @probinson here since they were involved in the earlier patch discussion.

Interesting. I did some digging through bug report as well because I am curious why this is only reported now but didn't find anything.

I am fine with not fixing this. If someone really want a certain option, we can add a new LTO interface and linker flag for them. I guess lld or gold doesn't really have this problem since they are probably just set the TargetOption directly.

steven_wu abandoned this revision.Sep 3 2019, 9:26 AM