[PATCH] D72225: Align branches within 32-Byte boundary(Prefix padding)

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 14 01:13:44 PST 2020


MaskRay added a comment.

You cannot prepend prefixes to `callq __tls_get_addr` (General-Dynamic/Local-Dynamic TLS models). The code sequence is specially organized to allow linker relaxation. Prepending prefixes may cause the linker to mis-relax the code sequence.

  --x86-align-branch-prefix-size=0
  
      4660: 0f 84 df 01 00 00            	je	479 <_ZN12_GLOBAL__N_116do_free_no_hooksEPv+0x295>
      4666: 66 48 8d 3d 00 00 00 00      	leaq	(%rip), %rdi
  		000000000000466a:  R_X86_64_TLSGD	__rseq_abi-0x4
      466e: 66 66 48 e8 00 00            	callw	0 <_ZN12_GLOBAL__N_116do_free_no_hooksEPv+0xc4>
  		0000000000004672:  R_X86_64_PLT32	__tls_get_addr-0x4
      4674: 00 00                        	addb	%al, (%rax)
      4676: 83 78 04 00                  	cmpl	$0, 4(%rax)
      467a: 66 0f 1f 44 00 00            	nopw	(%rax,%rax)
      4680: 0f 88 08 02 00 00            	js	520 <_ZN12_GLOBAL__N_116do_free_no_hooksEPv+0x2de>
  
  --x86-align-branch-prefix-size=5
  
      4660:	0f 84 df 01 00 00    	je     4845 <_ZN12_GLOBAL__N_116do_free_no_hooksEPv+0x295>
      4666:	2e 2e 2e 2e 2e 66 48 	cs cs cs cs data16 lea %cs:0x0(%rip),%rdi        # 4673 <_ZN12_GLOBAL__N_116do_free_no_hooksEPv+0xc3>
      466d:	8d 3d 00 00 00 00 
  			466f: R_X86_64_TLSGD	__rseq_abi-0x4
      4673:	2e 66 66 48 e8 00 00 	cs data16 data16 callq 467c <_ZN12_GLOBAL__N_116do_free_no_hooksEPv+0xcc>
      467a:	00 00 
  			4678: R_X86_64_PLT32	__tls_get_addr-0x4
      467c:	83 78 04 00          	cmpl   $0x0,0x4(%rax)
      4680:	0f 88 08 02 00 00    	js     488e <_ZN12_GLOBAL__N_116do_free_no_hooksEPv+0x2de>

Note, with -fno-plt, clang will emit `calll *___tls_get_addr at GOT(%ebx)` (32-bit) `callq *__tls_get_addr at GOTPCREL(%rip)` (64-bit). prefix-size= cannot alter such instructions, either.

I'll try investigating other issues in a few hours (>9).


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D72225/new/

https://reviews.llvm.org/D72225





More information about the llvm-commits mailing list