[PATCH] Do not generate nopl instruction on CPUs that don't support it.

Hi

This patch fixes code generation bug - 586-class CPUs don't support the
nopl instruction and some 686-class CPUs don't support it too.

I created bug 17792 for that.

BTW. I think you should also optimize padding on these CPUs - instead of a
stream of 0x90 nops, you should generate variants of "lea (%esi), %esi"
instruction like gcc.

This patch disables generation of nopl instructions on the following CPUs:

i686 - there are i686-class CPUs that don't have nopl: Via c3, Transmeta
  Crusoe, Microsoft VirtualBox - see
  https://bbs.archlinux.org/viewtopic.php?pid=775414
k6, k6-2, k6-3, winchip-c6, winchip2 - these are 586-class CPUs
via c3 c3-2 - see https://bugs.archlinux.org/task/19733 as a proof that
  Via c3 and c3-Nehemiah don't have nopl

Mikulas

Please include a testcase with the patch.

gas uses " nopl 0x0(%eax)" for k6_2. Are you sure it is a gas bug?

Please include a testcase with the patch.

I'm sending testcase here. Compile it with
"clang -O2 -march=k6-2 -c loop.c"

gas uses " nopl 0x0(%eax)" for k6_2. Are you sure it is a gas bug?

Yes, it is gas bug. I should report it to binutils maintainers.

Mikulas

Please include a testcase with the patch.

I'm sending testcase here. Compile it with
"clang -O2 -march=k6-2 -c loop.c"

The test should be in the patch itself. It can use llvm-mc to check
how the nops are expanded. The trick used by
MachO/x86_32-optimal_nop.s is to use '.align X, 0x90'.

gas uses " nopl 0x0(%eax)" for k6_2. Are you sure it is a gas bug?

Yes, it is gas bug. I should report it to binutils maintainers.

Thanks!

Cheers,
Rafael

>
>
>
>> Please include a testcase with the patch.
>
> I'm sending testcase here. Compile it with
> "clang -O2 -march=k6-2 -c loop.c"

The test should be in the patch itself. It can use llvm-mc to check
how the nops are expanded. The trick used by
MachO/x86_32-optimal_nop.s is to use '.align X, 0x90'.

So put it there and commit it to llvm codebase. I'm not an expert in llvm,
I just needed a patch to make it work on my computer.

>> gas uses " nopl 0x0(%eax)" for k6_2. Are you sure it is a gas bug?
>
> Yes, it is gas bug. I should report it to binutils maintainers.

Thanks!

Cheers,
Rafael

I already reported it to binutils maintainers and they fixed it.

Mikulas

So put it there and commit it to llvm codebase. I'm not an expert in llvm,
I just needed a patch to make it work on my computer.

Updating the tests is fairly easy. In any case, I update the tests and
committed your patch as r195679.

>> gas uses " nopl 0x0(%eax)" for k6_2. Are you sure it is a gas bug?
>
> Yes, it is gas bug. I should report it to binutils maintainers.

Thanks!

Cheers,
Rafael

I already reported it to binutils maintainers and they fixed it.

Thanks!

Cheers,
Rafael