|
| 1 | +; RUN: llc -mtriple=aarch64-none-linux-gnu -enable-machine-outliner < %s | FileCheck %s --check-prefix=BTI |
| 2 | +; RUN: llc -mtriple=aarch64-none-linux-gnu -global-isel -enable-machine-outliner < %s | \ |
| 3 | +; RUN: FileCheck %s --check-prefix=BTI |
| 4 | +; RUN: llc -mtriple=aarch64-none-linux-gnu -fast-isel -enable-machine-outliner < %s | \ |
| 5 | +; RUN: FileCheck %s --check-prefix=BTI |
| 6 | +; RUN: llc -mtriple=aarch64-none-linux-gnu -enable-machine-outliner -mattr=+no-bti-at-return-twice < %s | \ |
| 7 | +; RUN: FileCheck %s --check-prefix=NOBTI |
| 8 | +; RUN: llc -mtriple=aarch64-none-linux-gnu -global-isel -enable-machine-outliner -mattr=+no-bti-at-return-twice < %s | \ |
| 9 | +; RUN: FileCheck %s --check-prefix=NOBTI |
| 10 | +; RUN: llc -mtriple=aarch64-none-linux-gnu -fast-isel -enable-machine-outliner -mattr=+no-bti-at-return-twice < %s | \ |
| 11 | +; RUN: FileCheck %s --check-prefix=NOBTI |
| 12 | + |
| 13 | +; Check that the outliner does not split up the call to setjmp and the bti after it. |
| 14 | +; When we do not insert a bti, it is allowed to move the setjmp call into an outlined function. |
| 15 | + |
| 16 | +; C source |
| 17 | +; -------- |
| 18 | +; extern int setjmp(void*); |
| 19 | +; |
| 20 | +; int f(int a, int b, int c, int d) { |
| 21 | +; setjmp(0); |
| 22 | +; return 1 + a * (a + b) / (c + d); |
| 23 | +; } |
| 24 | +; |
| 25 | +; int g(int a, int b, int c, int d) { |
| 26 | +; setjmp(0); |
| 27 | +; return 2 + a * (a + b) / (c + d); |
| 28 | +; } |
| 29 | + |
| 30 | +define i32 @f(i32 noundef %a, i32 noundef %b, i32 noundef %c, i32 noundef %d) { |
| 31 | +; BTI-LABEL: f: |
| 32 | +; BTI: bl OUTLINED_FUNCTION_1 |
| 33 | +; BTI-NEXT: bl setjmp |
| 34 | +; BTI-NEXT: hint #36 |
| 35 | +; BTI-NEXT: bl OUTLINED_FUNCTION_0 |
| 36 | + |
| 37 | +; NOBTI: f: |
| 38 | +; NOBTI: bl OUTLINED_FUNCTION_0 |
| 39 | +; NOBTI-NEXT: bl OUTLINED_FUNCTION_1 |
| 40 | + |
| 41 | +entry: |
| 42 | + %call = call i32 @setjmp(i8* noundef null) #0 |
| 43 | + %add = add nsw i32 %b, %a |
| 44 | + %mul = mul nsw i32 %add, %a |
| 45 | + %add1 = add nsw i32 %d, %c |
| 46 | + %div = sdiv i32 %mul, %add1 |
| 47 | + %add2 = add nsw i32 %div, 1 |
| 48 | + ret i32 %add2 |
| 49 | +} |
| 50 | + |
| 51 | +declare i32 @setjmp(i8* noundef) #0 |
| 52 | + |
| 53 | +define i32 @g(i32 noundef %a, i32 noundef %b, i32 noundef %c, i32 noundef %d) { |
| 54 | +; BTI-LABEL: g: |
| 55 | +; BTI: bl OUTLINED_FUNCTION_1 |
| 56 | +; BTI-NEXT: bl setjmp |
| 57 | +; BTI-NEXT: hint #36 |
| 58 | +; BTI-NEXT: bl OUTLINED_FUNCTION_0 |
| 59 | + |
| 60 | +; NOBTI: g: |
| 61 | +; NOBTI: bl OUTLINED_FUNCTION_0 |
| 62 | +; NOBTI-NEXT: bl OUTLINED_FUNCTION_1 |
| 63 | + |
| 64 | +entry: |
| 65 | + %call = call i32 @setjmp(i8* noundef null) #0 |
| 66 | + %add = add nsw i32 %b, %a |
| 67 | + %mul = mul nsw i32 %add, %a |
| 68 | + %add1 = add nsw i32 %d, %c |
| 69 | + %div = sdiv i32 %mul, %add1 |
| 70 | + %add2 = add nsw i32 %div, 2 |
| 71 | + ret i32 %add2 |
| 72 | +} |
| 73 | + |
| 74 | +; NOBTI-LABEL: OUTLINED_FUNCTION_0: |
| 75 | +; NOBTI: b setjmp |
| 76 | +; NOBTI: OUTLINED_FUNCTION_1: |
| 77 | +; NOBTI-LABEL: ret |
| 78 | + |
| 79 | +attributes #0 = { returns_twice } |
| 80 | + |
| 81 | +!llvm.module.flags = !{!0} |
| 82 | + |
| 83 | +!0 = !{i32 1, !"branch-target-enforcement", i32 1} |
0 commit comments