[PATCH] D70157: Align branches within 32-Byte boundary

Fangrui Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 14 17:30:31 PST 2019


MaskRay added a comment.

On x86, the preferred function alignment is 16 (https://github.com/llvm/llvm-project/blob/arcpatch-D70157/llvm/lib/Target/X86/X86ISelLowering.cpp#L1893), which is the default function alignment in text sections. If the cross-boundary decision is made with alignment=32 (--x86-align-branch-boundary=32) in mind, and the section alignment is still 16 (not increased to 32 or higher), the linker may place the section at an address which equals 16 modulo 32, the section contents will thus shift by 16. The instructions that do not cross the boundary in the object files may cross the boundary in the linker output. Have you considered increasing the section alignment to 32?

Shall we default to -mbranches-within-32B-boundaries if the specified -march= or -mtune= may be affected by the erratum?



================
Comment at: llvm/test/MC/X86/i386-align-branch-1a.s:1
+# RUN: llvm-mc -filetype=obj -triple i386-unknown-unknown --x86-align-branch-boundary=32 --x86-align-branch=fused-jcc-jmp  --x86-align-branch-prefix-size=5 %s | llvm-objdump -d  - | FileCheck %s
+# RUN: llvm-mc -filetype=obj -triple i386-unknown-unknown --x86-branches-within-32B-boundaries %s | llvm-objdump -d  - | FileCheck %s
----------------
If you want to test that `--x86-branches-within-32B-boundaries` expands to the 3 other `--x86-*` options.

```
... -o %t
... -o %t2
cmp %t %t2
FileCheck --input-file %t
```


================
Comment at: llvm/test/MC/X86/i386-align-branch-1a.s:9
+# CHECK: 00000000 foo:
+# CHECK:        0: 65 65 65 a3 01 00 00 00      	movl	%eax, %gs:1
+# CHECK:        8: 55                           	pushl	%ebp
----------------
Use `CHECK-NEXT:` (see https://llvm.org/docs/CommandGuide/FileCheck.html)

Add comments where REX prefixes or NOPs are used.


================
Comment at: llvm/test/MC/X86/i386-align-branch-1a.s:9
+# CHECK: 00000000 foo:
+# CHECK:        0: 65 65 65 a3 01 00 00 00      	movl	%eax, %gs:1
+# CHECK:        8: 55                           	pushl	%ebp
----------------
MaskRay wrote:
> Use `CHECK-NEXT:` (see https://llvm.org/docs/CommandGuide/FileCheck.html)
> 
> Add comments where REX prefixes or NOPs are used.
Don't mix tabs with spaces. The columns do not align in an editor.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70157





More information about the cfe-commits mailing list