aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/Transforms/InstCombine/vararg.ll
blob: 93d230d22d8c8ab8c4cf446d817e29b8d2cc6f10 (plain)
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
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 5
; RUN: opt < %s -passes=instcombine -S | FileCheck %s

%struct.__va_list = type { ptr, ptr, ptr, i32, i32 }

define void @func(ptr nocapture readnone %fmt, ...) {
; CHECK-LABEL: define void @func(
; CHECK-SAME: ptr readnone captures(none) [[FMT:%.*]], ...) {
; CHECK-NEXT:  [[ENTRY:.*:]]
; CHECK-NEXT:    ret void
;
entry:
  %va0 = alloca %struct.__va_list, align 8
  %va1 = alloca %struct.__va_list, align 8
  call void @llvm.lifetime.start.p0(ptr %va0)
  call void @llvm.va_start(ptr %va0)
  call void @llvm.lifetime.start.p0(ptr %va1)
  call void @llvm.va_copy(ptr %va1, ptr %va0)
  call void @llvm.va_end(ptr %va1)
  call void @llvm.lifetime.end.p0(ptr %va1)
  call void @llvm.va_end(ptr %va0)
  call void @llvm.lifetime.end.p0(ptr %va0)
  ret void
}

declare void @callee(ptr)

define void @func_destroy_copy_src(ptr nocapture readnone %fmt, ...) {
; CHECK-LABEL: define void @func_destroy_copy_src(
; CHECK-SAME: ptr readnone captures(none) [[FMT:%.*]], ...) {
; CHECK-NEXT:  [[ENTRY:.*:]]
; CHECK-NEXT:    [[VA0:%.*]] = alloca [[STRUCT___VA_LIST:%.*]], align 8
; CHECK-NEXT:    [[VA1:%.*]] = alloca [[STRUCT___VA_LIST]], align 8
; CHECK-NEXT:    call void @llvm.lifetime.start.p0(ptr nonnull [[VA0]])
; CHECK-NEXT:    call void @llvm.lifetime.start.p0(ptr nonnull [[VA1]])
; CHECK-NEXT:    call void @llvm.va_start.p0(ptr nonnull [[VA0]])
; CHECK-NEXT:    call void @llvm.va_copy.p0(ptr nonnull [[VA1]], ptr nonnull [[VA0]])
; CHECK-NEXT:    call void @llvm.va_end.p0(ptr [[VA0]])
; CHECK-NEXT:    call void @callee(ptr nonnull [[VA1]])
; CHECK-NEXT:    call void @llvm.va_end.p0(ptr [[VA1]])
; CHECK-NEXT:    call void @llvm.lifetime.end.p0(ptr nonnull [[VA1]])
; CHECK-NEXT:    call void @llvm.lifetime.end.p0(ptr nonnull [[VA0]])
; CHECK-NEXT:    ret void
;
entry:
  %va0 = alloca %struct.__va_list, align 8
  %va1 = alloca %struct.__va_list, align 8
  call void @llvm.lifetime.start.p0(ptr %va0)
  call void @llvm.lifetime.start.p0(ptr %va1)
  call void @llvm.va_start(ptr %va0)
  call void @llvm.va_copy(ptr %va1, ptr %va0)
  call void @llvm.va_end(ptr %va0)
  call void @callee(ptr %va1)
  call void @llvm.va_end(ptr %va1)
  call void @llvm.lifetime.end.p0(ptr %va1)
  call void @llvm.lifetime.end.p0(ptr %va0)
  ret void
}