1 /// Test that -malign-branch* and -mbranches-within-32B-boundaries are parsed and converted to MC options.
2 
3 /// Test -malign-branch-boundary=
4 // RUN: %clang -target x86_64 -malign-branch-boundary=16 %s -c -### 2>&1 | FileCheck %s --check-prefix=BOUNDARY
5 // BOUNDARY: "-mllvm" "-x86-align-branch-boundary=16"
6 // RUN: %clang -target x86_64-unknown-linux -malign-branch-boundary=16 -flto %s -### 2>&1 | FileCheck %s --check-prefix=BOUNDARY-LTO
7 // BOUNDARY-LTO: "-plugin-opt=-x86-align-branch-boundary=16"
8 
9 // RUN: %clang -target x86_64 -malign-branch-boundary=8 %s -c -### 2>&1 | FileCheck %s --check-prefix=BOUNDARY-ERR
10 // RUN: %clang -target x86_64 -malign-branch-boundary=15 %s -c -### 2>&1 | FileCheck %s --check-prefix=BOUNDARY-ERR
11 // BOUNDARY-ERR: invalid argument {{.*}} to -malign-branch-boundary=
12 
13 /// Test -malign-branch=
14 // RUN: %clang -target x86_64 -malign-branch=fused,jcc,jmp %s -c -### %s 2>&1 | FileCheck %s --check-prefix=TYPE0
15 // TYPE0: "-mllvm" "-x86-align-branch=fused+jcc+jmp"
16 // RUN: %clang -target x86_64 -malign-branch=fused,jcc,jmp,ret,call,indirect %s -c -### %s 2>&1 | FileCheck %s --check-prefix=TYPE1
17 // TYPE1: "-mllvm" "-x86-align-branch=fused+jcc+jmp+ret+call+indirect"
18 // RUN: %clang -target x86_64-unknown-linux -malign-branch=fused,jcc,jmp -flto %s -### %s 2>&1 | FileCheck %s --check-prefix=TYPE0-LTO
19 // TYPE0-LTO: "-plugin-opt=-x86-align-branch=fused+jcc+jmp"
20 
21 // RUN: %clang -target x86_64 -malign-branch=fused,foo,bar %s -c -### %s 2>&1 | FileCheck %s --check-prefix=TYPE-ERR
22 // TYPE-ERR: invalid argument 'foo' to -malign-branch=; each element must be one of: fused, jcc, jmp, call, ret, indirect
23 // TYPE-ERR: invalid argument 'bar' to -malign-branch=; each element must be one of: fused, jcc, jmp, call, ret, indirect
24 
25 /// Test -mpad-max-prefix-size=
26 // RUN: %clang -target x86_64 -mpad-max-prefix-size=0 %s -c -### 2>&1 | FileCheck %s --check-prefix=PREFIX-0
27 // PREFIX-0: "-mllvm" "-x86-pad-max-prefix-size=0"
28 // RUN: %clang -target x86_64 -mpad-max-prefix-size=15 %s -c -### 2>&1 | FileCheck %s --check-prefix=PREFIX-15
29 // PREFIX-15: "-mllvm" "-x86-pad-max-prefix-size=15"
30 // RUN: %clang -target x86_64-unknown-linux -mpad-max-prefix-size=0 -flto %s -### 2>&1 | FileCheck %s --check-prefix=PREFIX-0-LTO
31 // PREFIX-0-LTO: "-plugin-opt=-x86-pad-max-prefix-size=0"
32 
33 /// Test -mbranches-within-32B-boundaries
34 // RUN: %clang -target x86_64 -mbranches-within-32B-boundaries %s -c -### 2>&1 | FileCheck %s --check-prefix=32B
35 // 32B: "-mllvm" "-x86-branches-within-32B-boundaries"
36 // RUN: %clang -target x86_64-unknown-linux -mbranches-within-32B-boundaries -flto %s -### 2>&1 | FileCheck %s --check-prefix=32B-LTO
37 // 32B-LTO: "-plugin-opt=-x86-branches-within-32B-boundaries"
38 
39 /// Unsupported on other targets.
40 // RUN: %clang -target aarch64 -malign-branch=jmp %s -c -### 2>&1 | FileCheck --check-prefix=UNUSED %s
41 // RUN: %clang -target aarch64 -malign-branch-boundary=7 %s -c -### 2>&1 | FileCheck --check-prefix=UNUSED %s
42 // RUN: %clang -target aarch64 -mpad-max-prefix-size=15 %s -c -### 2>&1 | FileCheck --check-prefix=UNUSED %s
43 // RUN: %clang -target aarch64 -mbranches-within-32B-boundaries %s -c -### 2>&1 | FileCheck --check-prefix=UNUSED %s
44 // UNUSED: warning: argument unused
45