[llvm-dev] LLVMTargetMachine with optimization level passed from clang.

Mehdi Amini via llvm-dev llvm-dev at lists.llvm.org
Fri Jan 6 12:49:17 PST 2017

> On Jan 6, 2017, at 12:41 PM, Robinson, Paul <paul.robinson at sony.com> wrote:
>> -----Original Message-----
>> From: llvm-dev [mailto:llvm-dev-bounces at lists.llvm.org] On Behalf Of Mehdi
>> Amini via llvm-dev
>> Sent: Friday, January 06, 2017 11:10 AM
>> To: Sumanth Gundapaneni
>> Cc: LLVM Developers
>> Subject: Re: [llvm-dev] LLVMTargetMachine with optimization level passed
>> from clang.
>>> On Jan 6, 2017, at 10:56 AM, Sumanth Gundapaneni
>> <sgundapa at codeaurora.org> wrote:
>>> Here is a problem scenario.
>>> I want to enable a backend pass at -O2 or above.
>>> if (TM->getOptLevel() >= CodeGenOpt::Default)
>>>   addPass(&xxxxx);
>>> This pass will be run at -O1 too since clang is creating the
>> TargetMachine with CodeGenOpt::Default for -O1.
>> Right, you can’t.
> Can somebody explain why it's not a bug that -O1 and -O2 are identical?

This is only a CodegenOpts, I don’t think it *has to* be a bug that this option is the same between O1 and O2. There are many other diff between O1/O2

However I clearly don’t like that `llc -O1` and `clang -O1` are not using the same settings here: https://reviews.llvm.org/D28409


More information about the llvm-dev mailing list