All of lore.kernel.org
 help / color / mirror / Atom feed
* clang .code16 with -Os producing larger code that it needs to
@ 2015-02-20 14:58 Vladimir 'φ-coder/phcoder' Serbinenko
  2015-02-20 15:26 ` Vladimir 'φ-coder/phcoder' Serbinenko
  2015-02-20 15:38 ` David Woodhouse
  0 siblings, 2 replies; 10+ messages in thread
From: Vladimir 'φ-coder/phcoder' Serbinenko @ 2015-02-20 14:58 UTC (permalink / raw)
  To: dwmw2, llvmdev, The development of GRUB 2

[-- Attachment #1: Type: text/plain, Size: 1052 bytes --]

When experimenting with compiling GRUB2 with clang using integrated as,
I found out that it generates a 16-bit code bigger than gas counterpart
and result gets too big for size constraints of bootsector. This was
traced mainly to 2 problems.
32-bit access to 16-bit addresses.
source:
	movl	LOCAL(kernel_sector), %ebx
	movl	%ebx, 8(%si)
clang:
    7cbc:	67 66 8b 1d 5c 7c 00 	addr32 mov 0x7c5c,%ebx
    7cc3:	00
    7cc4:	66 89 5c 08          	mov    %ebx,0x8(%si)

gas:
    7cbc:	66 8b 1e 5c 7c       	mov    0x7c5c,%ebx
    7cc1:	66 89 5c 08          	mov    %ebx,0x8(%si)
32-bit jump.
source:
	jnb	LOCAL(floppy_probe)
clang:
+    7cb5:	66 0f 83 07 01 00 00 	jae    7dc3 <L_floppy_probe>
gas:
-    7cb5:	0f 83 0a 01          	jae    7dc3 <L_floppy_probe>
The last one is particularly problematic as it never makes sense to
issue 32-bit jump if %ip is only 16 bits and it eats 3 extra bytes per
jump. Is it possible to force clang to generate 16-bit jumps?
On bright side if I remove error strings the code is functional.


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 213 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-02-24 14:54 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-20 14:58 clang .code16 with -Os producing larger code that it needs to Vladimir 'φ-coder/phcoder' Serbinenko
2015-02-20 15:26 ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-02-20 15:38 ` David Woodhouse
2015-02-20 15:46   ` Vladimir 'φ-coder/phcoder' Serbinenko
2015-02-20 16:05     ` David Woodhouse
2015-02-20 16:18       ` David Woodhouse
2015-02-20 18:47         ` [LLVMdev] " Rafael Espíndola
2015-02-23 12:07           ` David Woodhouse
2015-02-24  8:42             ` Craig Topper
2015-02-24  9:07               ` David Woodhouse

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.