File: simplify-libcalls-inreg.ll

package info (click to toggle)
llvm-toolchain-17 1%3A17.0.6-22
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,799,624 kB
  • sloc: cpp: 6,428,607; ansic: 1,383,196; asm: 793,408; python: 223,504; objc: 75,364; f90: 60,502; lisp: 33,869; pascal: 15,282; sh: 9,684; perl: 7,453; ml: 4,937; awk: 3,523; makefile: 2,889; javascript: 2,149; xml: 888; fortran: 619; cs: 573
file content (54 lines) | stat: -rw-r--r-- 2,052 bytes parent folder | download | duplicates (9)
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
; RUN: opt -passes=instcombine -S %s | FileCheck %s

; The intent of this test is to check that the declarations produces for
; libcalls retains the inreg parameter attribute.

target datalayout = "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-f64:32:64-f80:32-n8:16:32-S128"
target triple = "i386-unknown-linux-gnu"

declare ptr @foo()
declare i32 @memcmp(ptr inreg nocapture noundef, ptr inreg nocapture noundef, i32 inreg noundef)
declare i32 @printf(ptr, ...)
declare double @exp2(double)
declare i32 @__sprintf_chk(ptr, i32, i32, ptr, ...)
@a = common global [60 x i8] zeroinitializer, align 1
@b = common global [60 x i8] zeroinitializer, align 1
@h = constant [2 x i8] c"h\00"

; CHECK:     declare i32 @bcmp(ptr inreg nocapture, ptr inreg nocapture, i32 inreg)
; CHECK-NOT: declare i32 @bcmp(ptr nocapture, ptr nocapture, i32)

define i32 @baz(ptr inreg noundef %s2, i32 inreg noundef %n){
  %call = call ptr @foo()
  %call1 = call i32 @memcmp(ptr inreg noundef %call, ptr inreg noundef %s2, i32 inreg noundef %n)
  %cmp = icmp eq i32 %call1, 0
  %conv = zext i1 %cmp to i32
  ret i32 %conv
}

; CHECK:     declare noundef i32 @putchar(i32 inreg noundef)
; CHECK-NOT: declare noundef i32 @putchar(i32 noundef)

define void @test_fewer_params_than_num_register_parameters() {
  call i32 (ptr, ...) @printf(ptr @h)
  ret void
}

; CHECK:     declare double @ldexp(double, i32 inreg)
; CHECK-NOT: declare double @ldexp(double, i32)

define double @test_non_int_params(i16 signext %x) {
  %conv = sitofp i16 %x to double
  %ret = call double @exp2(double %conv)
  ret double %ret
}

; CHECK:     declare noundef i32 @sprintf(ptr noalias nocapture noundef writeonly, ptr nocapture noundef readonly, ...)
; CHECK-NOT: declare noundef i32 @sprintf(ptr inreg noalias nocapture noundef writeonly, ptr inreg nocapture noundef readonly, ...)
define i32 @test_variadic() {
  %ret = call i32 (ptr, i32, i32, ptr, ...) @__sprintf_chk(ptr @a, i32 0, i32 -1, ptr @b)
  ret i32 %ret
}

!llvm.module.flags = !{!0}
!0 = !{i32 1, !"NumRegisterParameters", i32 3}