diff --git a/docs/LangRef.html b/docs/LangRef.html index 911d8668b61..666289d3087 100644 --- a/docs/LangRef.html +++ b/docs/LangRef.html @@ -92,7 +92,7 @@
Trap values are similar to undef values, however +
Poison values are similar to undef values, however instead of representing an unspecified bit pattern, they represent the fact that an instruction or constant expression which cannot evoke side effects has nevertheless detected a condition which results in undefined behavior.
-There is currently no way of representing a trap value in the IR; they +
There is currently no way of representing a poison value in the IR; they only exist when produced by operations such as add with the nsw flag.
-Trap value behavior is defined in terms of value dependence:
+Poison value behavior is defined in terms of value dependence:
Whenever a trap value is generated, all values which depend on it evaluate - to trap. If they have side effects, they evoke their side effects as if each - operand with a trap value were undef. If they have externally-visible side +
Whenever a poison value is generated, all values which depend on it evaluate + to poison. If they have side effects, they evoke their side effects as if each + operand with a poison value were undef. If they have externally-visible side effects, the behavior is undefined.
Here are some examples:
entry: - %trap = sub nuw i32 0, 1 ; Results in a trap value. - %still_trap = and i32 %trap, 0 ; Whereas (and i32 undef, 0) would return 0. - %trap_yet_again = getelementptr i32* @h, i32 %still_trap - store i32 0, i32* %trap_yet_again ; undefined behavior + %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. + %poison_yet_again = getelementptr i32* @h, i32 %still_poison + store i32 0, i32* %poison_yet_again ; undefined behavior - store i32 %trap, i32* @g ; Trap value conceptually stored to memory. - %trap2 = load i32* @g ; Returns a trap value, not just undef. + 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 %trap, i32* @g ; External observation; undefined behavior. + store volatile i32 %poison, i32* @g ; External observation; undefined behavior. %narrowaddr = bitcast i32* @g to i16* %wideaddr = bitcast i32* @g to i64* - %trap3 = load i16* %narrowaddr ; Returns a trap value. - %trap4 = load i64* %wideaddr ; Returns a trap value. + %poison3 = load i16* %narrowaddr ; Returns a poison value. + %poison4 = load i64* %wideaddr ; Returns a poison value. - %cmp = icmp slt i32 %trap, 0 ; Returns a trap value. + %cmp = icmp slt i32 %poison, 0 ; Returns a poison value. br i1 %cmp, label %true, label %end ; Branch to either destination. true: @@ -2608,7 +2608,7 @@ end: %p = phi i32 [ 0, %entry ], [ 1, %true ] ; Both edges into this PHI are ; control-dependent on %cmp, so this - ; always results in a trap value. + ; 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 @@ -3619,7 +3619,7 @@ that the invoke/unwind semantics are likely to change in future versions.nuw and nsw stand for "No Unsigned Wrap" and "No Signed Wrap", respectively. If the nuw and/or nsw keywords are present, the result value of the add - is a trap value if unsigned and/or signed overflow, + is a poison value if unsigned and/or signed overflow, respectively, occurs.
Example:
@@ -3700,7 +3700,7 @@ that the invoke/unwind semantics are likely to change in future versions.nuw and nsw stand for "No Unsigned Wrap" and "No Signed Wrap", respectively. If the nuw and/or nsw keywords are present, the result value of the sub - is a trap value if unsigned and/or signed overflow, + is a poison value if unsigned and/or signed overflow, respectively, occurs.
Example:
@@ -3787,7 +3787,7 @@ that the invoke/unwind semantics are likely to change in future versions.nuw and nsw stand for "No Unsigned Wrap" and "No Signed Wrap", respectively. If the nuw and/or nsw keywords are present, the result value of the mul - is a trap value if unsigned and/or signed overflow, + is a poison value if unsigned and/or signed overflow, respectively, occurs.
Example:
@@ -3857,7 +3857,7 @@ that the invoke/unwind semantics are likely to change in future versions.Division by zero leads to undefined behavior.
If the exact keyword is present, the result value of the - udiv is a trap value if %op1 is not a + udiv is a poison value if %op1 is not a multiple of %op2 (as such, "((a udiv exact b) mul b) == a").
@@ -3901,7 +3901,7 @@ that the invoke/unwind semantics are likely to change in future versions. a 32-bit division of -2147483648 by -1.If the exact keyword is present, the result value of the - sdiv is a trap value if the result would + sdiv is a poison value if the result would be rounded.
Example:
@@ -4110,9 +4110,9 @@ that the invoke/unwind semantics are likely to change in future versions. shift amount in op2.If the nuw keyword is present, then the shift produces a - trap value if it shifts out any non-zero bits. If + poison value if it shifts out any non-zero bits. If the nsw keyword is present, then the shift produces a - trap value if it shifts out any bits that disagree + poison value if it shifts out any bits that disagree with the resultant sign bit. As such, NUW/NSW have the same semantics as they would if the shift were expressed as a mul instruction with the same nsw/nuw bits in (mul %op1, (shl 1, %op2)).
@@ -4159,7 +4159,7 @@ that the invoke/unwind semantics are likely to change in future versions. shift amount in op2.If the exact keyword is present, the result value of the - lshr is a trap value if any of the bits + lshr is a poison value if any of the bits shifted out are non-zero.
@@ -4207,7 +4207,7 @@ that the invoke/unwind semantics are likely to change in future versions. the corresponding shift amount in op2.If the exact keyword is present, the result value of the - ashr is a trap value if any of the bits + ashr is a poison value if any of the bits shifted out are non-zero.
Example:
@@ -5161,7 +5161,7 @@ entry:
If the inbounds keyword is present, the result value of the - getelementptr is a trap value if the + getelementptr is a poison value if the base pointer is not an in bounds address of an allocated object, or if any of the addresses that would be formed by successive addition of the offsets implied by the indices to the base address with infinitely