File: fake-use-phi.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 (50 lines) | stat: -rw-r--r-- 2,044 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
; RUN: opt < %s -passes='require<profile-summary>,function(codegenprepare)' -S -mtriple=x86_64 | FileCheck %s --implicit-check-not="llvm.fake.use"
;
; When performing return duplication to enable
; tail call optimization we clone fake uses that exist in the to-be-eliminated
; return block into the predecessor blocks. When doing this with fake uses
; of PHI-nodes, they cannot be easily copied, but require the correct operand.
; We are currently not able to do this correctly, so we suppress the cloning
; of such fake uses at the moment.
;
; There should be no fake use of a call result in any of the resulting return
; blocks.

; Fake uses of `this` should be duplicated into both return blocks.
; CHECK: if.then:
; CHECK: @llvm.fake.use({{.*}}this
; CHECK: if.else:
; CHECK: @llvm.fake.use({{.*}}this

; CHECK: declare void @llvm.fake.use

source_filename = "test.ll"

%class.a = type { i8 }

declare i32 @foo(ptr nonnull dereferenceable(1)) local_unnamed_addr
declare i32 @bar(ptr nonnull dereferenceable(1)) local_unnamed_addr

define hidden void @func(ptr nonnull dereferenceable(1) %this) local_unnamed_addr align 2 optdebug {
entry:
  %b = getelementptr inbounds %class.a, ptr %this, i64 0, i32 0
  %0 = load i8, i8* %b, align 1
  %tobool.not = icmp eq i8 %0, 0
  br i1 %tobool.not, label %if.else, label %if.then

if.then:                                          ; preds = %entry
  %call = tail call i32 @foo(ptr nonnull dereferenceable(1) %this)
  %call2 = tail call i32 @bar(ptr nonnull dereferenceable(1) %this)
  br label %if.end

if.else:                                          ; preds = %entry
  %call4 = tail call i32 @bar(ptr nonnull dereferenceable(1) %this)
  %call5 = tail call i32 @foo(ptr nonnull dereferenceable(1) %this)
  br label %if.end

if.end:                                           ; preds = %if.else, %if.then
  %call4.sink = phi i32 [ %call4, %if.else ], [ %call, %if.then ]
  notail call void (...) @llvm.fake.use(i32 %call4.sink)
  notail call void (...) @llvm.fake.use(ptr nonnull %this)
  ret void
}