forked from OSchip/llvm-project
b2a9c02521
Summary: A particular coroutine usage pattern, where a coroutine is created, manipulated and destroyed by the same calling function, is common for coroutines implementing RAII idiom and is suitable for allocation elision optimization which avoid dynamic allocation by storing the coroutine frame as a static `alloca` in its caller. coro.free and coro.alloc intrinsics are used to indicate which code needs to be suppressed when dynamic allocation elision happens: ``` entry: %elide = call i8* @llvm.coro.alloc() %need.dyn.alloc = icmp ne i8* %elide, null br i1 %need.dyn.alloc, label %coro.begin, label %dyn.alloc dyn.alloc: %alloc = call i8* @CustomAlloc(i32 4) br label %coro.begin coro.begin: %phi = phi i8* [ %elide, %entry ], [ %alloc, %dyn.alloc ] %hdl = call i8* @llvm.coro.begin(i8* %phi, i32 0, i8* null, i8* bitcast ([2 x void (%f.frame*)*]* @f.resumers to i8*)) ``` and ``` %mem = call i8* @llvm.coro.free(i8* %hdl) %need.dyn.free = icmp ne i8* %mem, null br i1 %need.dyn.free, label %dyn.free, label %if.end dyn.free: call void @CustomFree(i8* %mem) br label %if.end if.end: ... ``` If heap allocation elision is performed, we replace coro.alloc with a static alloca on the caller frame and coro.free with null constant. Also, we need to make sure that if there are any tail calls referencing the coroutine frame, we need to remote tail call attribute, since now coroutine frame lives on the stack. Documentation and overview is here: http://llvm.org/docs/Coroutines.html. Upstreaming sequence (rough plan) 1.Add documentation. (https://reviews.llvm.org/D22603) 2.Add coroutine intrinsics. (https://reviews.llvm.org/D22659) 3.Add empty coroutine passes. (https://reviews.llvm.org/D22847) 4.Add coroutine devirtualization + tests. ab) Lower coro.resume and coro.destroy (https://reviews.llvm.org/D22998) c) Do devirtualization (https://reviews.llvm.org/D23229) 5.Add CGSCC restart trigger + tests. (https://reviews.llvm.org/D23234) 6.Add coroutine heap elision + tests. <= we are here 7.Add the rest of the logic (split into more patches) Reviewers: mehdi_amini, majnemer Subscribers: mehdi_amini, llvm-commits Differential Revision: https://reviews.llvm.org/D23245 llvm-svn: 278242 |
||
---|---|---|
.. | ||
CommandGuide | ||
Frontend | ||
HistoricalNotes | ||
Proposals | ||
TableGen | ||
_ocamldoc | ||
_static | ||
_templates | ||
_themes/llvm-theme | ||
tutorial | ||
AMDGPUUsage.rst | ||
ARM-BE-bitcastfail.png | ||
ARM-BE-bitcastsuccess.png | ||
ARM-BE-ld1.png | ||
ARM-BE-ldr.png | ||
AdvancedBuilds.rst | ||
AliasAnalysis.rst | ||
Atomics.rst | ||
BigEndianNEON.rst | ||
BitCodeFormat.rst | ||
BlockFrequencyTerminology.rst | ||
BranchWeightMetadata.rst | ||
Bugpoint.rst | ||
CMake.rst | ||
CMakeLists.txt | ||
CMakePrimer.rst | ||
CodeGenerator.rst | ||
CodeOfConduct.rst | ||
CodingStandards.rst | ||
CommandLine.rst | ||
CompileCudaWithLLVM.rst | ||
CompilerWriterInfo.rst | ||
Coroutines.rst | ||
CoverageMappingFormat.rst | ||
DebuggingJITedCode.rst | ||
DeveloperPolicy.rst | ||
Dummy.html | ||
ExceptionHandling.rst | ||
ExtendedIntegerResults.txt | ||
ExtendingLLVM.rst | ||
Extensions.rst | ||
FAQ.rst | ||
FaultMaps.rst | ||
GarbageCollection.rst | ||
GetElementPtr.rst | ||
GettingStarted.rst | ||
GettingStartedVS.rst | ||
GoldPlugin.rst | ||
HowToAddABuilder.rst | ||
HowToBuildOnARM.rst | ||
HowToCrossCompileLLVM.rst | ||
HowToReleaseLLVM.rst | ||
HowToSetUpLLVMStyleRTTI.rst | ||
HowToSubmitABug.rst | ||
HowToUseAttributes.rst | ||
HowToUseInstrMappings.rst | ||
InAlloca.rst | ||
LLVMBuild.rst | ||
LLVMBuild.txt | ||
LangRef.rst | ||
Lexicon.rst | ||
LibFuzzer.rst | ||
LinkTimeOptimization.rst | ||
MCJIT-creation.png | ||
MCJIT-dyld-load.png | ||
MCJIT-engine-builder.png | ||
MCJIT-load-object.png | ||
MCJIT-load.png | ||
MCJIT-resolve-relocations.png | ||
MCJITDesignAndImplementation.rst | ||
MIRLangRef.rst | ||
Makefile.sphinx | ||
MarkedUpDisassembly.rst | ||
MergeFunctions.rst | ||
NVPTXUsage.rst | ||
Packaging.rst | ||
Passes.rst | ||
Phabricator.rst | ||
ProgrammersManual.rst | ||
Projects.rst | ||
README.txt | ||
ReleaseNotes.rst | ||
ReleaseProcess.rst | ||
ReportingGuide.rst | ||
ScudoHardenedAllocator.rst | ||
SegmentedStacks.rst | ||
SourceLevelDebugging.rst | ||
SphinxQuickstartTemplate.rst | ||
StackMaps.rst | ||
Statepoints.rst | ||
SystemLibrary.rst | ||
TableGenFundamentals.rst | ||
TestSuiteMakefileGuide.rst | ||
TestingGuide.rst | ||
TypeMetadata.rst | ||
Vectorizers.rst | ||
WritingAnLLVMBackend.rst | ||
WritingAnLLVMPass.rst | ||
YamlIO.rst | ||
conf.py | ||
doxygen-mainpage.dox | ||
doxygen.cfg.in | ||
gcc-loops.png | ||
index.rst | ||
linpack-pc.png | ||
make.bat | ||
re_format.7 | ||
yaml2obj.rst |
README.txt
LLVM Documentation ================== LLVM's documentation is written in reStructuredText, a lightweight plaintext markup language (file extension `.rst`). While the reStructuredText documentation should be quite readable in source form, it is mostly meant to be processed by the Sphinx documentation generation system to create HTML pages which are hosted on <http://llvm.org/docs/> and updated after every commit. Manpage output is also supported, see below. If you instead would like to generate and view the HTML locally, install Sphinx <http://sphinx-doc.org/> and then do: cd <build-dir> cmake -DLLVM_ENABLE_SPHINX=true -DSPHINX_OUTPUT_HTML=true <src-dir> make -j3 docs-llvm-html $BROWSER <build-dir>/docs//html/index.html The mapping between reStructuredText files and generated documentation is `docs/Foo.rst` <-> `<build-dir>/docs//html/Foo.html` <-> `http://llvm.org/docs/Foo.html`. If you are interested in writing new documentation, you will want to read `SphinxQuickstartTemplate.rst` which will get you writing documentation very fast and includes examples of the most important reStructuredText markup syntax. Manpage Output =============== Building the manpages is similar to building the HTML documentation. The primary difference is to use the `man` makefile target, instead of the default (which is `html`). Sphinx then produces the man pages in the directory `<build-dir>/docs/man/`. cd <build-dir> cmake -DLLVM_ENABLE_SPHINX=true -DSPHINX_OUTPUT_MAN=true <src-dir> make -j3 docs-llvm-man man -l >build-dir>/docs/man/FileCheck.1 The correspondence between .rst files and man pages is `docs/CommandGuide/Foo.rst` <-> `<build-dir>/docs//man/Foo.1`. These .rst files are also included during HTML generation so they are also viewable online (as noted above) at e.g. `http://llvm.org/docs/CommandGuide/Foo.html`. Checking links ============== The reachability of external links in the documentation can be checked by running: cd docs/ make -f Makefile.sphinx linkcheck