This is an archive of the discontinued LLVM Phabricator instance.

[LLD] [ELF] Pass CPU string to LTO pipeline.
Needs ReviewPublic

Authored by pbhatu on Jan 17 2018, 7:09 AM.

Details

Summary

Previously an empty CPU string was passed to the LTO engine which
resulted in a generic CPU for which certain features like NOPL
were disabled. This fixes that.

Diff Detail

Event Timeline

pbhatu created this revision.Jan 17 2018, 7:09 AM
davide requested changes to this revision.Jan 17 2018, 10:22 AM

You should add a testcase as Rafael pointed out. Overall it looks fine.
We used mllvm in lld to pass this kind of options to the backend but this seems justifiable.
BTW, if you're using lld or the gold plugin you might consider implementing the linker counterpart as well (if you have your proprietary linker, just ignore this last bit).

This revision now requires changes to proceed.Jan 17 2018, 10:22 AM
pbhatu updated this revision to Diff 130560.Jan 18 2018, 10:02 PM

I added a test case. Since znver1 supports NOPW, it should be generated when we specify it as the CPU.

You should add a testcase as Rafael pointed out. Overall it looks fine.
We used mllvm in lld to pass this kind of options to the backend but this seems justifiable.
BTW, if you're using lld or the gold plugin you might consider implementing the linker counterpart as well (if you have your proprietary linker, just ignore this last bit).

Thanks for the prompt review Davide and Rafael!

I don't think the mllvm option works as intended. The specified CPU(through mllvm) is definitely being used in the middle end for optimizations during LTO. However, it is not picked up when we initialize the target machine for the backend. This patch tries to fix that.

Also, I'm a bit confused by your last statement. What do you mean by implementing the linker counterpart as well? I think I'm missing the larger picture.

pbhatu updated this revision to Diff 131927.Jan 29 2018, 11:19 PM

Addressed comments: clang-formatted the patch and removed the -m option from the test case.

I do not have commit access, could you please do it instead?

As of r322227 I would have though the target-cpu attribute would control the NOPL creation and override the CPU string.

espindola accepted this revision.Jan 30 2018, 10:51 AM

Committed as r323801.

craig.topper added inline comments.Jan 30 2018, 11:02 AM
test/ELF/lto/cpu-string.ll
10

This CHECK line doesn't prove anything. nop would nopw. This should be a CHECK-NOT nopw.

espindola resigned from this revision.Feb 26 2018, 2:44 PM