File: fake-use-constprop.ll

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.6-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,304 kB
  • sloc: cpp: 7,438,677; ansic: 1,393,822; asm: 1,012,926; python: 241,650; f90: 86,635; objc: 75,479; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (60 lines) | stat: -rw-r--r-- 1,559 bytes parent folder | download | duplicates (6)
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
; RUN: opt -passes=gvn -S < %s | FileCheck %s
;
; The Global Value Numbering pass (GVN) propagates boolean values
; that are constant in dominated basic blocks to all the uses
; in these basic blocks. However, we don't want the constant propagated
; into fake.use intrinsics since this would render the intrinsic useless
; with respect to keeping the variable live up until the fake.use.
; This test checks that we don't generate any fake.uses with constant 0.
;
; Reduced from the following test case, generated with clang -O2 -S -emit-llvm -fextend-variable-liveness test.c
;
; extern void func1();
; extern int bar();
; extern void baz(int);
;
; int foo(int i, float f, int *punused)
; {
;   int j = 3*i;
;   if (j > 0) {
;     int m = bar(i);
;     if (m) {
;       char b = f;
;       baz(b);
;       if (b)
;         goto lab;
;       func1();
;     }
; lab:
;     func1();
;   }
;   return 1;
; }

;; GVN should propagate a constant value through to a regular call, but not to
;; a fake use, which should continue to track the original value.
; CHECK: %[[CONV_VAR:[a-zA-Z0-9]+]] = fptosi
; CHECK: call {{.+}} @bees(i8 0)
; CHECK: call {{.+}} @llvm.fake.use(i8 %[[CONV_VAR]])

define i32 @foo(float %f) optdebug {
  %conv = fptosi float %f to i8
  %tobool3 = icmp eq i8 %conv, 0
  br i1 %tobool3, label %if.end, label %lab

if.end:
  tail call void (...) @bees(i8 %conv)
  tail call void (...) @llvm.fake.use(i8 %conv)
  br label %lab

lab:
  ret i32 1
}

declare i32 @bar(...)

declare void @baz(i32)

declare void @bees(i32)

declare void @func1(...)