File: 2011-09-22-PHISpeculateInvoke.ll

package info (click to toggle)
llvm-3.0 3.0-10
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 75,412 kB
  • sloc: cpp: 468,043; asm: 109,345; ansic: 13,782; sh: 12,935; ml: 4,716; python: 4,351; perl: 2,096; makefile: 1,905; pascal: 1,578; exp: 389; xml: 283; lisp: 187; csh: 117
file content (40 lines) | stat: -rw-r--r-- 1,371 bytes parent folder | download | duplicates (3)
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: opt < %s -scalarrepl -S | FileCheck %s
; PR10987

; Make sure scalarrepl doesn't move a load across an invoke which could
; modify the loaded value.
; (The PHI could theoretically be transformed by splitting the critical
; edge, but scalarrepl doesn't modify the CFG, at least at the moment.)

declare void @extern_fn(i32*)
declare i32 @extern_fn2(i32)
declare i32 @__gcc_personality_v0(i32, i64, i8*, i8*)

define void @odd_fn(i1) noinline {
  %retptr1 = alloca i32
  %retptr2 = alloca i32
  br i1 %0, label %then, label %else

then:                                             ; preds = %2
  invoke void @extern_fn(i32* %retptr1)
          to label %join unwind label %unwind

else:                                             ; preds = %2
  store i32 3, i32* %retptr2
  br label %join

join:                                             ; preds = %then, %else
  %storemerge.in = phi i32* [ %retptr2, %else ], [ %retptr1, %then ]
  %storemerge = load i32* %storemerge.in
  %x3 = call i32 @extern_fn2(i32 %storemerge)
  ret void

unwind:                                           ; preds = %then
  %info = landingpad { i8*, i32 } personality i32 (i32, i64, i8*, i8*)* @__gcc_personality_v0
          cleanup
  call void @extern_fn(i32* null)
  unreachable
}

; CHECK: define void @odd_fn
; CHECK: %storemerge.in = phi i32* [ %retptr2, %else ], [ %retptr1, %then ]