Home | History | Annotate | Download | only in LICM
      1 ; ModuleID = 'PR1657.bc'
      2 ; Do not promote getelementptr because it may exposes load from a null pointer 
      3 ; and store from a null pointer  which are covered by 
      4 ; icmp eq %struct.decision* null, null condition.
      5 ; RUN: opt < %s -licm -S | not grep promoted
      6 	%struct.decision = type { i8, %struct.decision* }
      7 
      8 define i32 @main() {
      9 entry:
     10 	br label %blah.i
     11 
     12 blah.i:		; preds = %cond_true.i, %entry
     13 	%tmp3.i = icmp eq %struct.decision* null, null		; <i1> [#uses=1]
     14 	br i1 %tmp3.i, label %clear_modes.exit, label %cond_true.i
     15 
     16 cond_true.i:		; preds = %blah.i
     17 	%tmp1.i = getelementptr %struct.decision* null, i32 0, i32 0		; <i8*> [#uses=1]
     18 	store i8 0, i8* %tmp1.i
     19 	br label %blah.i
     20 
     21 clear_modes.exit:		; preds = %blah.i
     22 	call void @exit( i32 0 )
     23 	unreachable
     24 }
     25 
     26 define i32 @f(i8* %ptr) {
     27 entry:
     28         br label %loop.head
     29 
     30 loop.head:              ; preds = %cond.true, %entry
     31         %x = phi i8* [ %ptr, %entry ], [ %ptr.i, %cond.true ]           ; <i8*> [#uses=1]
     32         %tmp3.i = icmp ne i8* %ptr, %x          ; <i1> [#uses=1]
     33         br i1 %tmp3.i, label %cond.true, label %exit
     34 
     35 cond.true:              ; preds = %loop.head
     36         %ptr.i = getelementptr i8* %ptr, i32 0          ; <i8*> [#uses=2]
     37         store i8 0, i8* %ptr.i
     38         br label %loop.head
     39 
     40 exit:           ; preds = %loop.head
     41         ret i32 0
     42 }
     43 
     44 define i32 @f2(i8* %p, i8* %q) {
     45 entry:
     46         br label %loop.head
     47 
     48 loop.head:              ; preds = %cond.true, %entry
     49         %tmp3.i = icmp eq i8* null, %q            ; <i1> [#uses=1]
     50         br i1 %tmp3.i, label %exit, label %cond.true
     51 
     52 cond.true:              ; preds = %loop.head
     53         %ptr.i = getelementptr i8* %p, i32 0          ; <i8*> [#uses=2]
     54         store i8 0, i8* %ptr.i
     55         br label %loop.head
     56 
     57 exit:           ; preds = %loop.head
     58         ret i32 0
     59 }
     60 
     61 declare void @exit(i32)
     62