[PATCH] D92162: [LangRef] Add poison constant
Juneyoung Lee via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 26 02:37:27 PST 2020
aqjune created this revision.
aqjune added reviewers: nlopes, jdoerfert, efriedma, nikic, liuz, regehr.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
aqjune requested review of this revision.
This patch adds a description about the newly added poison constant to LangRef.
rG LLVM Github Monorepo
@@ -3657,13 +3657,13 @@
+A poison value is a result of an erroneous operation.
In order to facilitate speculative execution, many instructions do not
invoke immediate undefined behavior when provided with illegal operands,
and return a poison value instead.
-There is currently no way of representing a poison value in the IR; they
-only exist when produced by operations such as :ref:`add <i_add>` with
-the ``nsw`` flag.
+The string '``poison``' can be used anywhere a constant is expected, and
+operations such as :ref:`add <i_add>` with the ``nsw`` flag can produce
+a poison value.
Poison value behavior is defined in terms of value *dependence*:
@@ -3732,6 +3732,7 @@
%poison = sub nuw i32 0, 1 ; Results in a poison value.
+ %poison2 = sub i32 poison, 1 ; Also results in a poison value.
%still_poison = and i32 %poison, 0 ; 0, but also poison.
%poison_yet_again = getelementptr i32, i32* @h, i32 %still_poison
store i32 0, i32* %poison_yet_again ; Undefined behavior due to
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 1241 bytes
Desc: not available
More information about the llvm-commits