forked from OSchip/llvm-project
parent
9a2a0933ed
commit
5f115a78cb
|
|
@ -2582,11 +2582,11 @@ b: unreachable
|
|||
<pre class="doc_code">
|
||||
entry:
|
||||
%poison = sub nuw i32 0, 1 ; Results in a poison value.
|
||||
%still_poison = and i32 %poison, 0 ; Whereas (and i32 undef, 0) would return 0.
|
||||
%still_poison = and i32 %poison, 0 ; Whereas (and i32 undef, 0) would return 0.
|
||||
%poison_yet_again = getelementptr i32* @h, i32 %still_poison
|
||||
store i32 0, i32* %poison_yet_again ; undefined behavior
|
||||
|
||||
store i32 %poison, i32* @g ; Poison value conceptually stored to memory.
|
||||
store i32 %poison, i32* @g ; Poison value conceptually stored to memory.
|
||||
%poison2 = load i32* @g ; Returns a poison value, not just undef.
|
||||
|
||||
store volatile i32 %poison, i32* @g ; External observation; undefined behavior.
|
||||
|
|
@ -2596,38 +2596,38 @@ entry:
|
|||
%poison3 = load i16* %narrowaddr ; Returns a poison value.
|
||||
%poison4 = load i64* %wideaddr ; Returns a poison value.
|
||||
|
||||
%cmp = icmp slt i32 %poison, 0 ; Returns a poison value.
|
||||
br i1 %cmp, label %true, label %end ; Branch to either destination.
|
||||
%cmp = icmp slt i32 %poison, 0 ; Returns a poison value.
|
||||
br i1 %cmp, label %true, label %end ; Branch to either destination.
|
||||
|
||||
true:
|
||||
store volatile i32 0, i32* @g ; This is control-dependent on %cmp, so
|
||||
; it has undefined behavior.
|
||||
store volatile i32 0, i32* @g ; This is control-dependent on %cmp, so
|
||||
; it has undefined behavior.
|
||||
br label %end
|
||||
|
||||
end:
|
||||
%p = phi i32 [ 0, %entry ], [ 1, %true ]
|
||||
; Both edges into this PHI are
|
||||
; control-dependent on %cmp, so this
|
||||
; always results in a poison value.
|
||||
; Both edges into this PHI are
|
||||
; control-dependent on %cmp, so this
|
||||
; always results in a poison value.
|
||||
|
||||
store volatile i32 0, i32* @g ; This would depend on the store in %true
|
||||
; if %cmp is true, or the store in %entry
|
||||
; otherwise, so this is undefined behavior.
|
||||
store volatile i32 0, i32* @g ; This would depend on the store in %true
|
||||
; if %cmp is true, or the store in %entry
|
||||
; otherwise, so this is undefined behavior.
|
||||
|
||||
br i1 %cmp, label %second_true, label %second_end
|
||||
; The same branch again, but this time the
|
||||
; true block doesn't have side effects.
|
||||
; The same branch again, but this time the
|
||||
; true block doesn't have side effects.
|
||||
|
||||
second_true:
|
||||
; No side effects!
|
||||
ret void
|
||||
|
||||
second_end:
|
||||
store volatile i32 0, i32* @g ; This time, the instruction always depends
|
||||
; on the store in %end. Also, it is
|
||||
; control-equivalent to %end, so this is
|
||||
; well-defined (again, ignoring earlier
|
||||
; undefined behavior in this example).
|
||||
store volatile i32 0, i32* @g ; This time, the instruction always depends
|
||||
; on the store in %end. Also, it is
|
||||
; control-equivalent to %end, so this is
|
||||
; well-defined (again, ignoring earlier
|
||||
; undefined behavior in this example).
|
||||
</pre>
|
||||
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue