llvm-project/clang/docs
Nick Desaulniers 5c562f62a4 [clang] number labels in asm goto strings after tied inputs
I noticed that the following case would compile in Clang but not GCC:
    void *x(void) {
      void *p = &&foo;
      asm goto ("# %0\n\t# %l1":"+r"(p):::foo);
      foo:;
      return p;
    }

Changing the output template above from %l2 would compile in GCC but not
Clang.

This demonstrates that when using tied outputs (say via the "+r" output
constraint), the hidden inputs occur or are numbered BEFORE the labels,
at least with GCC.

In fact, GCC does denote this in its documentation:
https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gcc/Extended-Asm.html#Goto-Labels

> Output operand with constraint modifier ‘+’ is counted as two operands
> because it is considered as one output and one input operand.

For the sake of compatibility, I think it's worthwhile to just make this
change.

It's better to use symbolic names for compatibility (especially now
between released version of Clang that support asm goto with outputs).
ie. %l1 from the above would be %l[foo]. The GCC docs also make this
recommendation.

Also, I cleaned up some cruft in GCCAsmStmt::getNamedOperand. AFAICT,
NumPlusOperands was no longer used, though I couldn't find which commit
didn't clean that up correctly.

Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98096
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103640
Link: https://gcc.gnu.org/onlinedocs/gcc-11.2.0/gcc/Extended-Asm.html#Goto-Labels

Reviewed By: void

Differential Revision: https://reviews.llvm.org/D115471
2022-01-11 12:09:24 -08:00
..
CommandGuide Update Bug report URL to Github Issues 2022-01-06 17:33:25 +08:00
DataFlowAnalysisIntroImages [clang][docs][dataflow] Added an introduction to dataflow analysis 2021-12-06 12:16:35 +01:00
analyzer Revert "[analyzer][ctu] Fix wrong 'multiple definitions' errors caused by space characters in lookup names when parsing the ctu index file" 2021-12-16 20:46:51 -05:00
tools [clang-format] NFC update LLVM overall clang-formatted status 2022-01-03 13:10:30 +00:00
APINotes.rst
AddressSanitizer.rst Revert "[asan] Add support for disable_sanitizer_instrumentation attribute" 2021-12-10 14:33:38 -08:00
AutomaticReferenceCounting.rst [clang] Fix typos in documentation (NFC) 2021-03-06 15:52:52 -08:00
Block-ABI-Apple.rst [NFC] Trim trailing whitespace in *.rst 2021-11-15 09:17:08 +08:00
BlockLanguageSpec.rst
CMakeLists.txt
ClangCheck.rst
ClangCommandLineReference.rst [clang] Add --start-no-unused-arguments/--end-no-unused-arguments to silence some unused argument warnings 2022-01-11 09:22:00 +02:00
ClangFormat.rst [clang-format] Add option to explicitly specify a config file 2022-01-03 11:43:25 +01:00
ClangFormatStyleOptions.rst [clang-format] Fix SeparateDefinitionBlocks docs and ... 2022-01-05 12:31:34 +01:00
ClangFormattedStatus.rst [clang-format] NFC update LLVM overall clang-formatted status 2022-01-03 13:10:30 +00:00
ClangNvlinkWrapper.rst [NFC] Trim trailing whitespace in *.rst 2021-11-15 09:17:08 +08:00
ClangOffloadBundler.rst [clang-offload-bundler][docs][NFC] invalid indentation cause build issue 2021-09-24 08:03:52 +01:00
ClangPlugins.rst [clang][driver] Add -fplugin-arg- to pass arguments to plugins 2021-11-25 10:47:55 +01:00
ClangStaticAnalyzer.rst
ClangTools.rst [Branch-Rename] Fix some links 2021-02-01 16:43:21 +05:30
ClangTransformerTutorial.rst Add a clang-transformer tutorial 2021-11-17 13:40:46 +00:00
ConstantInterpreter.rst
ControlFlowIntegrity.rst [NFC] Trim trailing whitespace in *.rst 2021-11-15 09:17:08 +08:00
ControlFlowIntegrityDesign.rst [NFC] Trim trailing whitespace in *.rst 2021-11-15 09:17:08 +08:00
CrossCompilation.rst
DataFlowAnalysisIntro.md [clang][docs][dataflow] Added an introduction to dataflow analysis 2021-12-06 12:16:35 +01:00
DataFlowSanitizer.rst [DFSan] Add force_zero_label abilist option to DFSan. This can be used as a work-around for overtainting. 2021-09-17 12:57:40 -07:00
DataFlowSanitizerDesign.rst [clang] Fix typos in documentation (NFC) 2021-08-21 12:17:58 -07:00
DriverArchitecture.png
DriverInternals.rst
ExternalClangExamples.rst
FAQ.rst
HardwareAssistedAddressSanitizerDesign.rst [HWASan] Mention x86_64 aliasing mode in design doc. 2021-03-25 14:22:20 -07:00
HowToSetupToolingForLLVM.rst
InternalsManual.rst [NFC] Trim trailing whitespace in *.rst 2021-11-15 09:17:08 +08:00
IntroductionToTheClangAST.rst [clang] Fix typos in documentation (NFC) 2021-08-21 12:17:58 -07:00
ItaniumMangleAbiTags.rst
JSONCompilationDatabase.rst Compilation Database: Point Bazel users to a solution 2021-11-28 19:30:06 -05:00
LTOVisibility.rst
LanguageExtensions.rst [clang] number labels in asm goto strings after tied inputs 2022-01-11 12:09:24 -08:00
LeakSanitizer.rst [lsan][docs] Clarify supported platforms 2021-04-21 10:27:55 -07:00
LibASTImporter.rst
LibASTMatchers.rst
LibASTMatchersReference.html Fix documentation for `forEachLambdaCapture` and `hasAnyCapture` 2021-12-02 13:28:05 +00:00
LibASTMatchersTutorial.rst [docs] Fix linking issues in LibASTMatchers tutorial 2021-07-05 12:11:25 +03:00
LibFormat.rst [NFC] Inclusive language: Remove instances of master in URLs 2021-11-05 08:48:41 -05:00
LibTooling.rst [Branch-Rename] Fix some links 2021-02-01 16:43:21 +05:30
MSVCCompatibility.rst
MatrixTypes.rst [Matrix] Add missing newline to appease sphinx. 2021-03-12 09:33:36 +00:00
MemorySanitizer.rst [msan] Add support for disable_sanitizer_instrumentation attribute 2021-08-20 15:11:26 +02:00
Modules.rst [NFC] Trim trailing whitespace in *.rst 2021-11-15 09:17:08 +08:00
ObjectiveCLiterals.rst
OpenCLSupport.rst [Docs] Document C++ for OpenCL 2021 support in clang. 2022-01-04 11:18:15 +00:00
OpenMPSupport.rst [OpenMP][NFC] update status for 5.1 'fail' atomic extension 2021-12-17 11:46:37 -06:00
PCHInternals.rst
PCHLayout.graffle
PCHLayout.png
RAVFrontendAction.rst [NFC] Trim trailing whitespace in *.rst 2021-11-15 09:17:08 +08:00
README.txt
RefactoringEngine.rst
ReleaseNotes.rst [clang] number labels in asm goto strings after tied inputs 2022-01-11 12:09:24 -08:00
SYCLSupport.rst [SYCL] Enable `opencl_global_[host,device]` attributes for SYCL 2021-05-18 10:27:35 +03:00
SafeStack.rst
SanitizerCoverage.rst [NFC] Trim trailing whitespace in *.rst 2021-11-15 09:17:08 +08:00
SanitizerSpecialCaseList.rst [clang] accept -fsanitize-ignorelist= in addition to -fsanitize-blacklist= 2021-05-04 10:24:00 -04:00
SanitizerStats.rst
ShadowCallStack.rst
SourceBasedCodeCoverage.rst Coverage: Document how to collect a profile without a filesystem 2021-04-22 11:29:39 -07:00
ThinLTO.rst [clang] Fix sentence in the usage section of ThinLTO docs. 2021-09-30 07:26:19 +05:30
ThreadSafetyAnalysis.rst [clang][docs] Inclusive language: remove use of sanity check in option description 2021-11-30 15:07:43 -05:00
ThreadSanitizer.rst [tsan] Add support for disable_sanitizer_instrumentation attribute 2021-08-23 12:38:33 +02:00
Toolchain.rst [clang] Fix library name (libsupc++) in the admonition note. 2021-09-29 19:45:06 +05:30
Tooling.rst
UndefinedBehaviorSanitizer.rst Improve UBSan documentation 2021-08-02 15:10:21 -07:00
UsersManual.rst [SPIR-V] Add linking using spirv-link. 2022-01-11 13:11:38 +00:00
conf.py [clang][docs][dataflow] Added an introduction to dataflow analysis 2021-12-06 12:16:35 +01:00
doxygen-mainpage.dox
doxygen.cfg.in [NFC] Inclusive Language: change master to main for .chm files 2021-11-08 08:23:04 -06:00
index.rst [clang][docs][dataflow] Added an introduction to dataflow analysis 2021-12-06 12:16:35 +01:00
make.bat

README.txt

See llvm/docs/README.txt