summaryrefslogtreecommitdiff
path: root/examples
AgeCommit message (Collapse)Author
2017-12-20PR35705: Fix Chapter 9 example code for API changes to DIBuilderDavid Blaikie
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@321214 91177308-0d34-0410-b5e6-96231b3b80d8
2017-12-05[CMake] Use PRIVATE in target_link_libraries for executablesShoaib Meenai
We currently use target_link_libraries without an explicit scope specifier (INTERFACE, PRIVATE or PUBLIC) when linking executables. Dependencies added in this way apply to both the target and its dependencies, i.e. they become part of the executable's link interface and are transitive. Transitive dependencies generally don't make sense for executables, since you wouldn't normally be linking against an executable. This also causes issues for generating install export files when using LLVM_DISTRIBUTION_COMPONENTS. For example, clang has a lot of LLVM library dependencies, which are currently added as interface dependencies. If clang is in the distribution components but the LLVM libraries it depends on aren't (which is a perfectly legitimate use case if the LLVM libraries are being built static and there are therefore no run-time dependencies on them), CMake will complain about the LLVM libraries not being in export set when attempting to generate the install export file for clang. This is reasonable behavior on CMake's part, and the right thing is for LLVM's build system to explicitly use PRIVATE dependencies for executables. Unfortunately, CMake doesn't allow you to mix and match the keyword and non-keyword target_link_libraries signatures for a single target; i.e., if a single call to target_link_libraries for a particular target uses one of the INTERFACE, PRIVATE, or PUBLIC keywords, all other calls must also be updated to use those keywords. This means we must do this change in a single shot. I also fully expect to have missed some instances; I tested by enabling all the projects in the monorepo (except dragonegg), and configuring both with and without shared libraries, on both Darwin and Linux, but I'm planning to rely on the buildbots for other configurations (since it should be pretty easy to fix those). Even after this change, we still have a lot of target_link_libraries calls that don't specify a scope keyword, mostly for shared libraries. I'm thinking about addressing those in a follow-up, but that's a separate change IMO. Differential Revision: https://reviews.llvm.org/D40823 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@319840 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-12Fix broken links to the Itanium CXX ABIVlad Tsyrklevich
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312985 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-04[ORC] Refactor OrcRemoteTarget code to expose its RPC API, reduceLang Hames
code duplication in the client, and improve error propagation. This patch moves the OrcRemoteTarget rpc::Function declarations from OrcRemoteTargetRPCAPI into their own namespaces under llvm::orc::remote so that they can be used in new contexts (in particular, a remote-object-file adapter layer that I will commit shortly). Code duplication in OrcRemoteTargetClient (especially in loops processing the code, rw-data and ro-data allocations) is removed by moving the loop bodies into their own functions. Error propagation is (slightly) improved by adding an ErrorReporter functor to the OrcRemoteTargetClient -- Errors that can't be returned (because they occur in destructors, or behind stable APIs that don't provide error returns) can be sent to the ErrorReporter instead. Some methods in the Client API are also changed to make better use of the Expected class: returning Expected<T>s rather than returning Errors and taking T&s to store the results. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312500 91177308-0d34-0410-b5e6-96231b3b80d8
2017-09-03[ORC] Add an Error return to the JITCompileCallbackManager::grow method.Lang Hames
Calling grow may result in an error if, for example, this is a callback manager for a remote target. We need to be able to return this error to the callee. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@312429 91177308-0d34-0410-b5e6-96231b3b80d8
2017-08-15[ORC][Kaleidoscope] Update Chapter 1 of BuildingAJIT to incorporate recent ORCLang Hames
API changes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@310947 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-19Defeat another -Wunused-but-set-variable warningHans Wennborg
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@308484 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-13fix typos in comments and error messges; NFCHiroshi Inoue
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307885 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-07[ORC] Errorize the ORC APIs.Lang Hames
This patch updates the ORC layers and utilities to return and propagate llvm::Errors where appropriate. This is necessary to allow ORC to safely handle error cases in cross-process and remote JITing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307350 91177308-0d34-0410-b5e6-96231b3b80d8
2017-07-04[Orc] Remove the memory manager argument to addModule, and de-templatize theLang Hames
symbol resolver argument. De-templatizing the symbol resolver is part of the ongoing simplification of ORC layer API. Removing the memory management argument (and delegating construction of memory managers for RTDyldObjectLinkingLayer to a functor passed in to the constructor) allows us to build JITs whose base object layers need not be compatible with RTDyldObjectLinkingLayer's memory mangement scheme. For example, a 'remote object layer' that sends fully relocatable objects directly to the remote does not need a memory management scheme at all (that will be handled by the remote). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@307058 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-23[ORC] Re-apply r306166 and r306168 with fix for regression test.Lang Hames
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306182 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-23This reverts commit r306166 and r306168.Rafael Espindola
Revert "[ORC] Remove redundant semicolons from DEFINE_SIMPLE_CONVERSION_FUNCTIONS uses." Revert "[ORC] Move ORC IR layer interface from addModuleSet to addModule and fix the module type as std::shared_ptr<Module>." They broke ExecutionEngine/OrcMCJIT/test-global-ctors.ll on linux. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306176 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-23[ORC] Move ORC IR layer interface from addModuleSet to addModule and fix theLang Hames
module type as std::shared_ptr<Module>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306166 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-22[ORC] Switch the object layer API from addObjectSet to addObject (singular), andLang Hames
move the ObjectCache from the IRCompileLayer to SimpleCompiler. This is the first in a series of patches aimed at cleaning up and improving the robustness and performance of the ORC APIs. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@306058 91177308-0d34-0410-b5e6-96231b3b80d8
2017-06-07Move Object format code to lib/BinaryFormat.Zachary Turner
This creates a new library called BinaryFormat that has all of the headers from llvm/Support containing structure and layout definitions for various types of binary formats like dwarf, coff, elf, etc as well as the code for identifying a file from its magic. Differential Revision: https://reviews.llvm.org/D33843 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304864 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-26[Examples] Fix some Clang-tidy modernize-use-using and Include What You Use ↵Eugene Zelenko
warnings; other minor fixes (NFC). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@303944 91177308-0d34-0410-b5e6-96231b3b80d8
2017-05-07[Kaleidoscope] toy.cpp use after move fixPeter Szecsi
The variable Proto is moved at the beginning of the codegen() function. According to the comment above, the pointed object should be used due the reference P. Differential Revision: https://reviews.llvm.org/D32939 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302369 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-11Module::getOrInsertFunction is using C-style vararg instead of variadic ↵Serge Guelton
templates. From a user prospective, it forces the use of an annoying nullptr to mark the end of the vararg, and there's not type checking on the arguments. The variadic template is an obvious solution to both issues. Differential Revision: https://reviews.llvm.org/D31070 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299949 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-20llvm/examples/Kaleidoscope/BuildingAJIT: More fixup corresponding to r295636.NAKAMURA Takumi
I missed updating them since I just ran check-llvm (with examples) in r295645. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295646 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-20llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h: Fixup corresponding to ↵NAKAMURA Takumi
r295636. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295645 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-12Kaleidoscope-Ch7: Add TranformUtils for ↵NAKAMURA Takumi
llvm::createPromoteMemoryToRegisterPass() added in r294870. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294881 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-11Update Kaleidoscope tutorial and improve Windows supportMehdi Amini
Many quoted code blocks were not in sync with the actual toy.cpp files. Improve tutorial text slightly in several places. Added some step descriptions crucial to avoid crashes (like InitializeNativeTarget* calls). Solve/workaround problems with Windows (JIT'ed method not found, using custom and standard library functions from host process). Patch by: Moritz Kroll <moritz.kroll@gmx.de> Differential Revision: https://reviews.llvm.org/D29864 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294870 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-10[CMake] Fix pthread handling for out-of-tree buildsEric Fiselier
LLVM defines `PTHREAD_LIB` which is used by AddLLVM.cmake and various projects to correctly link the threading library when needed. Unfortunately `PTHREAD_LIB` is defined by LLVM's `config-ix.cmake` file which isn't installed and therefore can't be used when configuring out-of-tree builds. This causes such builds to fail since `pthread` isn't being correctly linked. This patch attempts to fix that problem by renaming and exporting `LLVM_PTHREAD_LIB` as part of`LLVMConfig.cmake`. I renamed `PTHREAD_LIB` because It seemed likely to cause collisions with downstream users of `LLVMConfig.cmake`. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294690 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-28Use print() instead of dump() in codeMatthias Braun
The dump() functions are meant to be used in a debugger, code should typically use something like print(errs()); git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293365 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-26Chapter3/KaleidoscopeJIT.h: Fix a warning. [-Wunused-lambda-capture]NAKAMURA Takumi
"this", aka class members, is not referred in the body. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293159 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17BrainF example: fixing output buffering issueBoris Ulasevich
Differential Revision: https://reviews.llvm.org/D27824 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292216 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-15BrainF example: fixing segfault caused by outdated code with missing MCJIT ↵Boris Ulasevich
dependency Differential Revision: https://reviews.llvm.org/D26280 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289857 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08Prune unused libdeps.NAKAMURA Takumi
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289060 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-20ExceptionDemo: remove some undefined behaviourSaleem Abdulrasool
The casting based reading of the LSDA could attempt to read unsuitably aligned data. Avoid that case by explicitly using a memcpy. A similar approach is used in libc++abi to address the same UB. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287479 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-20ExceptionDemo: prefer headers over redeclarationsSaleem Abdulrasool
Rather than redeclaring the interfaces for exceptions, prefer using the `unwind.h` header. This is vended by at least gcc and clang, and can also be found by an external unwinding library (e.g. libunwind). Doing this simplifies the example to the exception handling itself. Minor tweaks are the result of _Unwind_Context_t not being defined, which is just a typedef for struct _Unwind_Context *. NFC. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287478 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-18[Examples] Fix some Clang-tidy modernize-use-default and Include What You ↵Eugene Zelenko
Use warnings; other minor fixes. Differential revision: https://reviews.llvm.org/D26433 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@287384 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-11[Orc] Update the BuildingAJIT Chapter 5 server class for the recent RPC changes.Lang Hames
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286642 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-11[ORC] Re-apply 286620 with fixes for the ErrorSuccess class.Lang Hames
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286639 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-11[ORC] Revert r286620 while I investigate a bot failure.Lang Hames
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286621 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-11[ORC] Refactor the ORC RPC utilities to add some new features.Lang Hames
(1) Add support for function key negotiation. The previous version of the RPC required both sides to maintain the same enumeration for functions in the API. This means that any version skew between the client and server would result in communication failure. With this version of the patch functions (and serializable types) are defined with string names, and the derived function signature strings are used to negotiate the actual function keys (which are used for efficient call serialization). This allows clients to connect to any server that supports a superset of the API (based on the function signatures it supports). (2) Add a callAsync primitive. The callAsync primitive can be used to install a return value handler that will run as soon as the RPC function's return value is sent back from the remote. (3) Launch policies for RPC function handlers. The new addHandler method, which installs handlers for RPC functions, takes two arguments: (1) the handler itself, and (2) an optional "launch policy". When the RPC function is called, the launch policy (if present) is invoked to actually launch the handler. This allows the handler to be spawned on a background thread, or added to a work list. If no launch policy is used, the handler is run on the server thread itself. This should only be used for short-running handlers, or entirely synchronous RPC APIs. (4) Zero cost cross type serialization. You can now define serialization from any type to a different "wire" type. For example, this allows you to call an RPC function that's defined to take a std::string while passing a StringRef argument. If a serializer from StringRef to std::string has been defined for the channel type this will be used to serialize the argument without having to construct a std::string instance. This allows buffer reference types to be used as arguments to RPC calls without requiring a copy of the buffer to be made. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286620 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-11Fix examples files to reflect header split in r286566.Teresa Johnson
I missed these files in examples/ git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286570 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-02Fix Clang-tidy readability-redundant-string-cstr warningsMalcolm Parsons
Reviewers: beanz, lattner, jlebar Subscribers: jholewinski, llvm-commits, mehdi_amini Differential Revision: https://reviews.llvm.org/D26235 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@285832 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-19[BuildingAJIT] Use the remote target triple to construct the TargetMachine inLang Hames
Chapter 5. Chapter 5 demonstrates remote JITing: code is executed on the remote, not the machine running the REPL, so it's the remote's triple (and TargetMachine) that we need. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284657 91177308-0d34-0410-b5e6-96231b3b80d8
2016-10-19[BuildingAJIT] Make the chapter 5 server export symbols.Lang Hames
This will allow chapter 5 to work on Linux. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@284637 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-19[Kaleidoscope] Make Chapter 2 use llvm::make_unique, rather than a helper.Lang Hames
This essentially reverts r251936, minimizing the difference between Chapter2 and Chapter 3, and making Chapter 2's code match the tutorial text. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281945 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-11[ORC] Update examples for header changes in r281171.Lang Hames
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281178 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-26Fix singlton -> singleton typo.Eric Christopher
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279801 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-17Replace a few more "fall through" comments with LLVM_FALLTHROUGHJustin Bogner
Follow up to r278902. I had missed "fall through", with a space. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278970 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-11Use the range variant of find instead of unpacking begin/endDavid Majnemer
If the result of the find is only used to compare against end(), just use is_contained instead. No functionality change is intended. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@278433 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-01[ExecutionEngine][MCJIT][Orc] Replace RuntimeDyld::SymbolInfo with JITSymbol.Lang Hames
This patch replaces RuntimeDyld::SymbolInfo with JITSymbol: A symbol class that is capable of lazy materialization (i.e. the symbol definition needn't be emitted until the address is requested). This can be used to support common and weak symbols in the JIT (though this is not implemented in this patch). For consistency, RuntimeDyld::SymbolResolver is renamed to JITSymbolResolver. For space efficiency a new class, JITEvaluatedSymbol, is introduced that behaves like the old RuntimeDyld::SymbolInfo - i.e. it is just a pair of an address and symbol flags. Instances of JITEvaluatedSymbol can be used in symbol-tables to avoid paying the space cost of the materializer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277386 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15[Kaleidoscope][BuildingAJIT] Start filling in text for chapter 3.Lang Hames
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275518 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-02New Kaleidoscope chapter: Creating object filesWilfred Hughes
This new chapter describes compiling LLVM IR to object files. The new chaper is chapter 8, so later chapters have been renumbered. Since this brings us to 10 chapters total, I've also needed to rename the other chapters to use two digit numbering. Differential Revision: http://reviews.llvm.org/D18070 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@274441 91177308-0d34-0410-b5e6-96231b3b80d8
2016-06-11[MCJIT] Update MCJIT and get the fibonacci example working again.Lang Hames
MCJIT will now set the DataLayout on a module when it is added to the JIT, rather than waiting until it is codegen'd, and the runFunction method will finalize the module containing the function to be run before running it. The fibonacci example has been updated to include and link against MCJIT. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272455 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-31[Orc] Add conversion to/from RuntimeDyld::SymbolInfo for JITSymbol.Lang Hames
This tidies up some code that was manually constructing RuntimeDyld::SymbolInfo instances from JITSymbols. It will save more mess in the future when JITSymbol::getAddress is extended to return an Expected<TargetAddress> rather than just a TargetAddress, since we'll be able to embed the error checking in the conversion. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271350 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-30[Kaleidoscope][BuildingAJIT] Don't build Chapter 5 on Windows for now.Lang Hames
The TCP setup code is currently *nix based and does not build on Windows. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271194 91177308-0d34-0410-b5e6-96231b3b80d8