[PATCH] D135818: [clang] Update ASM goto documentation to reflect how Clang differs from GCC
Bill Wendling via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 12 14:45:12 PDT 2022
void created this revision.
void added a reviewer: nickdesaulniers.
Herald added a project: All.
void requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D135818
Files:
clang/docs/LanguageExtensions.rst
Index: clang/docs/LanguageExtensions.rst
===================================================================
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1546,28 +1546,13 @@
ASM Goto with Output Constraints
================================
-In addition to the functionality provided by `GCC's extended
-assembly <https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html>`_, clang
-supports output constraints with the `goto` form.
+.. note::
-The goto form of GCC's extended assembly allows the programmer to branch to a C
-label from within an inline assembly block. Clang extends this behavior by
-allowing the programmer to use output constraints:
-
-.. code-block:: c++
-
- int foo(int x) {
- int y;
- asm goto("# %0 %1 %l2" : "=r"(y) : "r"(x) : : err);
- return y;
- err:
- return -1;
- }
-
-It's important to note that outputs are valid only on the "fallthrough" branch.
-Using outputs on an indirect branch may result in undefined behavior. For
-example, in the function above, use of the value assigned to `y` in the `err`
-block is undefined behavior.
+ Clang's implementation of ASM goto differs from `GCC's
+ implementation<https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html>`_ in
+ that Clang doesn't support outputs on the indirect branch. Use of an output
+ on the indirect branch may result in undefined behavior and should be
+ avoided.
When using tied-outputs (i.e. outputs that are inputs and outputs, not just
outputs) with the `+r` constraint, there is a hidden input that's created
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D135818.467268.patch
Type: text/x-patch
Size: 1576 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221012/14a27e8d/attachment-0001.bin>
More information about the cfe-commits
mailing list