File: printargv.ll

package info (click to toggle)
llvm-toolchain-16 1%3A16.0.6-15~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,634,792 kB
  • sloc: cpp: 6,179,261; ansic: 1,216,205; asm: 741,319; python: 196,614; objc: 75,325; f90: 49,640; lisp: 32,396; pascal: 12,286; sh: 9,394; perl: 7,442; ml: 5,494; awk: 3,523; makefile: 2,723; javascript: 1,206; xml: 886; fortran: 581; cs: 573
file content (81 lines) | stat: -rw-r--r-- 2,705 bytes parent folder | download | duplicates (12)
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
; RUN: lli -jit-kind=orc-lazy %s a b c | FileCheck %s

; CHECK: argc = 4
; CHECK-NEXT: argv = ["{{.*}}printargv.ll", "a", "b", "c"]
; CHECK-NEXT: argv[4] = null

@.str = private unnamed_addr constant [11 x i8] c"argc = %i\0A\00", align 1
@.str.1 = private unnamed_addr constant [9 x i8] c"argv = [\00", align 1
@.str.3 = private unnamed_addr constant [5 x i8] c"\22%s\22\00", align 1
@.str.4 = private unnamed_addr constant [5 x i8] c"null\00", align 1
@.str.5 = private unnamed_addr constant [7 x i8] c", \22%s\22\00", align 1
@.str.6 = private unnamed_addr constant [15 x i8] c"argv[%i] = %s\0A\00", align 1
@.str.7 = private unnamed_addr constant [5 x i8] c"junk\00", align 1
@str.8 = private unnamed_addr constant [2 x i8] c"]\00", align 1

define i32 @main(i32 %argc, ptr nocapture readonly %argv)  {
entry:
  %call = tail call i32 (ptr, ...) @printf(ptr @.str, i32 %argc)
  %call1 = tail call i32 (ptr, ...) @printf(ptr @.str.1)
  %cmp = icmp eq i32 %argc, 0
  br i1 %cmp, label %if.then, label %if.end

if.then:
  %puts36 = tail call i32 @puts(ptr @str.8)
  br label %if.end

if.end:
  %0 = load ptr, ptr %argv, align 8
  %tobool = icmp eq ptr %0, null
  br i1 %tobool, label %if.else, label %if.then3

if.then3:
  %call5 = tail call i32 (ptr, ...) @printf(ptr @.str.3, ptr %0)
  br label %if.end7

if.else:
  %call6 = tail call i32 (ptr, ...) @printf(ptr @.str.4)
  br label %if.end7

if.end7:
  %cmp837 = icmp eq i32 %argc, 1
  br i1 %cmp837, label %for.cond.cleanup, label %for.body.preheader

for.body.preheader:
  %1 = zext i32 %argc to i64
  br label %for.body

for.cond.cleanup:
  %puts = tail call i32 @puts(ptr @str.8)
  %idxprom19 = sext i32 %argc to i64
  %arrayidx20 = getelementptr inbounds ptr, ptr %argv, i64 %idxprom19
  %2 = load ptr, ptr %arrayidx20, align 8
  %tobool21 = icmp eq ptr %2, null
  %cond = select i1 %tobool21, ptr @.str.4, ptr @.str.7
  %call22 = tail call i32 (ptr, ...) @printf(ptr @.str.6, i32 %argc, ptr %cond)
  ret i32 0

for.body:
  %indvars.iv = phi i64 [ 1, %for.body.preheader ], [ %indvars.iv.next, %for.inc ]
  %arrayidx9 = getelementptr inbounds ptr, ptr %argv, i64 %indvars.iv
  %3 = load ptr, ptr %arrayidx9, align 8
  %tobool10 = icmp eq ptr %3, null
  br i1 %tobool10, label %if.else15, label %if.then11

if.then11:
  %call14 = tail call i32 (ptr, ...) @printf(ptr @.str.5, ptr %3)
  br label %for.inc

if.else15:
  %call16 = tail call i32 (ptr, ...) @printf(ptr @.str.4)
  br label %for.inc

for.inc:
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %cmp8 = icmp eq i64 %indvars.iv.next, %1
  br i1 %cmp8, label %for.cond.cleanup, label %for.body
}

declare i32 @printf(ptr nocapture readonly, ...)

declare i32 @puts(ptr nocapture readonly)