File: vaarg_movable.ll

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 995,808 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (35 lines) | stat: -rw-r--r-- 1,268 bytes parent folder | download | duplicates (2)
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
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -reassociate -die < %s | FileCheck %s

; The two va_arg instructions depend on the memory/context, are therfore not
; identical and the sub should not be optimized to 0 by reassociate.
;
; ...
; ...
define i32 @func(i32 %dummy, ...) {
;
; CHECK-LABEL: @func(
; CHECK-NEXT:    [[VARARGS:%.*]] = alloca i8*, align 8
; CHECK-NEXT:    [[VARARGS1:%.*]] = bitcast i8** [[VARARGS]] to i8*
; CHECK-NEXT:    call void @llvm.va_start(i8* [[VARARGS1]])
; CHECK-NEXT:    [[V0:%.*]] = va_arg i8** [[VARARGS]], i32
; CHECK-NEXT:    [[V1:%.*]] = va_arg i8** [[VARARGS]], i32
; CHECK-NEXT:    [[V0_NEG:%.*]] = sub i32 0, [[V0]]
; CHECK-NEXT:    [[SUB:%.*]] = add i32 [[V0_NEG]], 1
; CHECK-NEXT:    [[ADD:%.*]] = add i32 [[SUB]], [[V1]]
; CHECK-NEXT:    call void @llvm.va_end(i8* [[VARARGS1]])
; CHECK-NEXT:    ret i32 [[ADD]]
;
  %varargs = alloca i8*, align 8
  %varargs1 = bitcast i8** %varargs to i8*
  call void @llvm.va_start(i8* %varargs1)
  %v0 = va_arg i8** %varargs, i32
  %v1 = va_arg i8** %varargs, i32
  %sub = sub nsw i32 %v1, %v0
  %add = add nsw i32 %sub, 1
  call void @llvm.va_end(i8* %varargs1)
  ret i32 %add
}

declare void @llvm.va_start(i8*)
declare void @llvm.va_end(i8*)