File: tail-dup.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 (40 lines) | stat: -rw-r--r-- 1,942 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
; RUN: llc < %s -mtriple=thumb-apple-darwin -relocation-model=dynamic-no-pic -mcpu=cortex-a8 -asm-verbose=false | FileCheck %s

; We should be able to tail-duplicate the basic block containing the indirectbr
; into all of its predecessors.
; CHECK-LABEL: fn:
; CHECK: mov pc
; CHECK: mov pc
; CHECK: mov pc

@fn.codetable = internal unnamed_addr constant [3 x ptr] [ptr blockaddress(@fn, %RETURN), ptr blockaddress(@fn, %INCREMENT), ptr blockaddress(@fn, %DECREMENT)], align 4

define i32 @fn(ptr nocapture %opcodes) nounwind readonly ssp {
entry:
  %0 = load i32, ptr %opcodes, align 4
  %arrayidx = getelementptr inbounds [3 x ptr], ptr @fn.codetable, i32 0, i32 %0
  br label %indirectgoto

INCREMENT:                                        ; preds = %indirectgoto
  %inc = add nsw i32 %result.0, 1
  %1 = load i32, ptr %opcodes.addr.0, align 4
  %arrayidx2 = getelementptr inbounds [3 x ptr], ptr @fn.codetable, i32 0, i32 %1
  br label %indirectgoto

DECREMENT:                                        ; preds = %indirectgoto
  %dec = add nsw i32 %result.0, -1
  %2 = load i32, ptr %opcodes.addr.0, align 4
  %arrayidx4 = getelementptr inbounds [3 x ptr], ptr @fn.codetable, i32 0, i32 %2
  br label %indirectgoto

indirectgoto:                                     ; preds = %DECREMENT, %INCREMENT, %entry
  %result.0 = phi i32 [ 0, %entry ], [ %dec, %DECREMENT ], [ %inc, %INCREMENT ]
  %opcodes.pn = phi ptr [ %opcodes, %entry ], [ %opcodes.addr.0, %DECREMENT ], [ %opcodes.addr.0, %INCREMENT ]
  %indirect.goto.dest.in = phi ptr [ %arrayidx, %entry ], [ %arrayidx4, %DECREMENT ], [ %arrayidx2, %INCREMENT ]
  %opcodes.addr.0 = getelementptr inbounds i32, ptr %opcodes.pn, i32 1
  %indirect.goto.dest = load ptr, ptr %indirect.goto.dest.in, align 4
  indirectbr ptr %indirect.goto.dest, [label %RETURN, label %INCREMENT, label %DECREMENT]

RETURN:                                           ; preds = %indirectgoto
  ret i32 %result.0
}