I'm working on enabling thinLTO for our custom backend on LLVM-8 with lld to get code size benefits from dead symbol elimination. The code in LTO::run() of LTO.cpp confuses me that, even though thinLTO is specified, runRegularLTO() will be run first and its return value determines whether runThinLTO() will be executed.
My question is if it's clearly known that thinLTO is used, is it still necessary to execute runRegularLTO()?If it is, what's the reason behind? For now our custom backend, where distributed thinLTO is adopted, it works fine as I removed the line executing runRegularLTO(). But if I preserve it, the code fails the `if (Conf.PostInternalizeModuleHook &&!Conf.PostInternalizeModuleHook(0, *RegularLTO.CombinedModule))`, which I also don't understand, and fall through to backend() and abort there. I believe something is missed during adding the target support but cannot figure it out. Could anyone help?
Regards,
Mindong Chen
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Hi,
I'm working on enabling thinLTO for our custom backend on LLVM-8 with lld to get code size benefits from dead symbol elimination. The code in LTO::run() of LTO.cpp confuses me that, even though thinLTO is specified, runRegularLTO() will be run first and its return value determines whether runThinLTO() will be executed.
My question is if it's clearly known that thinLTO is used, is it still necessary to execute runRegularLTO()?If it is, what's the reason behind?
For now our custom backend, where distributed thinLTO is adopted, it works fine as I removed the line executing runRegularLTO(). But if I preserve it, the code fails the `if (Conf.PostInternalizeModuleHook &&!Conf.PostInternalizeModuleHook(0, *RegularLTO.CombinedModule))`, which I also don't understand, and fall through to backend() and abort there. I believe something is missed during adding the target support but cannot figure it out. Could anyone help?
Regards,
Mindong Chen
_______________________________________________
LLVM Developers mailing list
llvm...@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
Hi,
I'm working on enabling thinLTO for our custom backend on LLVM-8 with lld to get code size benefits from dead symbol elimination.
Hi David,
`-ffunction-sections -fdata-sections -Wl,-gc-sections ` is actually our first choice but because `-ffunction-sections` puts each function into its own section and section alignment cost is not negligible for our target, the gain is unpredictable and we deprecated the plan.
Regards,
Mindong
Hi Teresa,
Thanks for the detailed reply!
> How are you creating your bitcode files?
I create the bitcode with `-flto=thin -c` and sure it has a GLOBALVAL_SUMMARY_BLOCK. And there’s no RegularLTO partition only ThinLTO bicode.
> Where is it aborting in the backend?
It aborts at ` report_fatal_error("Failed to setup codegen")` in of codegen() of LTOBackend.cpp. And before that in createTargetMachine() it also warns ‘xxx is not a recognized processor’. But the program should return before run into backend() IIUC since all I want is using lld with `-thinlto-index-only` option to generate *.thinlto.bc and feed it and bitocde to clang to invoke target-specific optimizations(we use gnu as and ld).Do you have any suggestion about this?
Regards,
Mindong
From: Teresa Johnson [mailto:tejo...@google.com]
Sent: Wednesday, November 27, 2019 11:12 PM
To: chenmindong <chenmi...@huawei.com>
Cc: llvm...@lists.llvm.org; Yuchao (Michael) <michael...@huawei.com>
Subject: Re: [llvm-dev] ThinLTO Problem
Hi Mindong,
Hi Teresa,
Thanks for the detailed reply!
> How are you creating your bitcode files?
I create the bitcode with `-flto=thin -c` and sure it has a GLOBALVAL_SUMMARY_BLOCK. And there’s no RegularLTO partition only ThinLTO bicode.
> Where is it aborting in the backend?
It aborts at ` report_fatal_error("Failed to setup codegen")` in of codegen() of LTOBackend.cpp. And before that in createTargetMachine() it also warns ‘xxx is not a recognized processor’. But the program should return before run into backend() IIUC since all I want is using lld with `-thinlto-index-only` option to generate *.thinlto.bc and feed it and bitocde to clang to invoke target-specific optimizations(we use gnu as and ld).Do you have any suggestion about this?
Hi Teresa,
The third way you suggested has solved my problem perfectly! `-plugin-opt emit-llvm` assigns PostInternalizeModuleHook a lambda which always returns false so that `if (Conf.PostInternalizeModuleHook && !Conf.PostInternalizeModuleHook(0, *RegularLTO.CombinedModule))` is met now and runRegularLTO() returns without executing backend(), though it creates an output file(defaults to be a.out), it doesn’t really matter. For the first suggestion, I need some time to figure out what a “valid target machine” requires here and what I missed. Your help is really appreciated!