File: align.ll

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-12
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,496,180 kB
  • sloc: cpp: 5,593,972; ansic: 986,872; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,538; xml: 953; cs: 573; fortran: 567
file content (84 lines) | stat: -rw-r--r-- 2,725 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --function-signature --scrub-attributes
; RUN: opt -S -argpromotion < %s | FileCheck %s

define internal i32 @callee_must_exec(i32* %p) {
; CHECK-LABEL: define {{[^@]+}}@callee_must_exec
; CHECK-SAME: (i32 [[P_VAL:%.*]]) {
; CHECK-NEXT:    ret i32 [[P_VAL]]
;
  %x = load i32, i32* %p, align 16
  ret i32 %x
}

define void @caller_must_exec(i32* %p) {
; CHECK-LABEL: define {{[^@]+}}@caller_must_exec
; CHECK-SAME: (i32* [[P:%.*]]) {
; CHECK-NEXT:    [[P_VAL:%.*]] = load i32, i32* [[P]], align 16
; CHECK-NEXT:    [[TMP1:%.*]] = call i32 @callee_must_exec(i32 [[P_VAL]])
; CHECK-NEXT:    ret void
;
  call i32 @callee_must_exec(i32* %p)
  ret void
}

define internal i32 @callee_guaranteed_aligned(i1 %c, i32* %p) {
; CHECK-LABEL: define {{[^@]+}}@callee_guaranteed_aligned
; CHECK-SAME: (i1 [[C:%.*]], i32 [[P_VAL:%.*]]) {
; CHECK-NEXT:    br i1 [[C]], label [[IF:%.*]], label [[ELSE:%.*]]
; CHECK:       if:
; CHECK-NEXT:    ret i32 [[P_VAL]]
; CHECK:       else:
; CHECK-NEXT:    ret i32 -1
;
  br i1 %c, label %if, label %else

if:
  %x = load i32, i32* %p, align 16
  ret i32 %x

else:
  ret i32 -1
}

define void @caller_guaranteed_aligned(i1 %c, i32* align 16 dereferenceable(4) %p) {
; CHECK-LABEL: define {{[^@]+}}@caller_guaranteed_aligned
; CHECK-SAME: (i1 [[C:%.*]], i32* align 16 dereferenceable(4) [[P:%.*]]) {
; CHECK-NEXT:    [[P_VAL:%.*]] = load i32, i32* [[P]], align 16
; CHECK-NEXT:    [[TMP1:%.*]] = call i32 @callee_guaranteed_aligned(i1 [[C]], i32 [[P_VAL]])
; CHECK-NEXT:    ret void
;
  call i32 @callee_guaranteed_aligned(i1 %c, i32* %p)
  ret void
}

; TODO: This should not be promoted, as the caller only guarantees that the
; pointer is dereferenceable, not that it is aligned.
define internal i32 @callee_not_guaranteed_aligned(i1 %c, i32* %p) {
; CHECK-LABEL: define {{[^@]+}}@callee_not_guaranteed_aligned
; CHECK-SAME: (i1 [[C:%.*]], i32 [[P_VAL:%.*]]) {
; CHECK-NEXT:    br i1 [[C]], label [[IF:%.*]], label [[ELSE:%.*]]
; CHECK:       if:
; CHECK-NEXT:    ret i32 [[P_VAL]]
; CHECK:       else:
; CHECK-NEXT:    ret i32 -1
;
  br i1 %c, label %if, label %else

if:
  %x = load i32, i32* %p, align 16
  ret i32 %x

else:
  ret i32 -1
}

define void @caller_not_guaranteed_aligned(i1 %c, i32* dereferenceable(4) %p) {
; CHECK-LABEL: define {{[^@]+}}@caller_not_guaranteed_aligned
; CHECK-SAME: (i1 [[C:%.*]], i32* dereferenceable(4) [[P:%.*]]) {
; CHECK-NEXT:    [[P_VAL:%.*]] = load i32, i32* [[P]], align 16
; CHECK-NEXT:    [[TMP1:%.*]] = call i32 @callee_not_guaranteed_aligned(i1 [[C]], i32 [[P_VAL]])
; CHECK-NEXT:    ret void
;
  call i32 @callee_not_guaranteed_aligned(i1 %c, i32* %p)
  ret void
}