Commit Graph

428 Commits

Author SHA1 Message Date
Peter Szecsi
2c224bcd52 [Kaleidoscope] toy.cpp use after move fix
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-05-07 11:00:01 +00:00
Serge Guelton
9d54400bba Module::getOrInsertFunction is using C-style vararg instead of variadic 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-04-11 15:01:18 +00:00
NAKAMURA Takumi
674da3c841 llvm/examples/Kaleidoscope/BuildingAJIT: More fixup corresponding to r295636.
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-20 10:07:41 +00:00
NAKAMURA Takumi
19dff40fd1 llvm/examples/Kaleidoscope/include/KaleidoscopeJIT.h: Fixup corresponding to r295636.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295645 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-20 09:56:24 +00:00
NAKAMURA Takumi
f92e231ad4 Kaleidoscope-Ch7: Add TranformUtils for llvm::createPromoteMemoryToRegisterPass() added in r294870.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294881 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-12 01:18:32 +00:00
Mehdi Amini
e0ae1eda9c Update Kaleidoscope tutorial and improve Windows support
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-11 21:26:52 +00:00
Eric Fiselier
a61fc423f3 [CMake] Fix pthread handling for out-of-tree builds
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-02-10 01:59:20 +00:00
Matthias Braun
d6da5dbf7b Use print() instead of dump() in code
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-28 02:47:46 +00:00
NAKAMURA Takumi
82579da889 Chapter3/KaleidoscopeJIT.h: Fix a warning. [-Wunused-lambda-capture]
"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-26 08:31:14 +00:00
Boris Ulasevich
d81b53817b BrainF example: fixing output buffering issue
Differential Revision: https://reviews.llvm.org/D27824

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292216 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-17 13:27:28 +00:00
Boris Ulasevich
0eeb59d037 BrainF example: fixing segfault caused by outdated code with missing MCJIT 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-15 19:29:42 +00:00
NAKAMURA Takumi
c3e85bfe21 Prune unused libdeps.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@289060 91177308-0d34-0410-b5e6-96231b3b80d8
2016-12-08 15:28:02 +00:00
Saleem Abdulrasool
802a1be56a ExceptionDemo: remove some undefined behaviour
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-20 02:36:38 +00:00
Saleem Abdulrasool
308b046dd4 ExceptionDemo: prefer headers over redeclarations
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-20 02:36:36 +00:00
Eugene Zelenko
38ccacb5ed [Examples] Fix some Clang-tidy modernize-use-default and Include What You 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-18 21:57:58 +00:00
Lang Hames
2322de66fe [Orc] Update the BuildingAJIT Chapter 5 server class for the recent RPC changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286642 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-11 21:55:25 +00:00
Lang Hames
085827f843 [ORC] Re-apply 286620 with fixes for the ErrorSuccess class.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286639 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-11 21:42:09 +00:00
Lang Hames
b35b701639 [ORC] Revert r286620 while I investigate a bot failure.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@286621 91177308-0d34-0410-b5e6-96231b3b80d8
2016-11-11 19:46:46 +00:00
Lang Hames
d8314f03b1 [ORC] Refactor the ORC RPC utilities to add some new features.
(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-11 19:42:44 +00:00
Teresa Johnson
895b529ff6 Fix examples files to reflect header split in r286566.
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-11 06:02:04 +00:00
Malcolm Parsons
4c12732226 Fix Clang-tidy readability-redundant-string-cstr warnings
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-11-02 16:43:50 +00:00
Lang Hames
207b6abad4 [BuildingAJIT] Use the remote target triple to construct the TargetMachine in
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 22:41:03 +00:00
Lang Hames
b5046bac11 [BuildingAJIT] Make the chapter 5 server export symbols.
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-10-19 20:22:12 +00:00
Lang Hames
4cd6605af1 [Kaleidoscope] Make Chapter 2 use llvm::make_unique, rather than a helper.
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-19 23:00:27 +00:00
Lang Hames
dd7c4ea725 [ORC] Update examples for header changes in r281171.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@281178 91177308-0d34-0410-b5e6-96231b3b80d8
2016-09-11 21:34:13 +00:00
Eric Christopher
7092439c66 Fix singlton -> singleton typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@279801 91177308-0d34-0410-b5e6-96231b3b80d8
2016-08-26 02:00:21 +00:00
Justin Bogner
7d7a23e700 Replace a few more "fall through" comments with LLVM_FALLTHROUGH
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-17 20:30:52 +00:00
David Majnemer
975248e4fb Use the range variant of find instead of unpacking begin/end
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-11 22:21:41 +00:00
Lang Hames
075c1e2e1a [ExecutionEngine][MCJIT][Orc] Replace RuntimeDyld::SymbolInfo with JITSymbol.
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-08-01 20:49:11 +00:00
Lang Hames
8e1c20f813 [Kaleidoscope][BuildingAJIT] Start filling in text for chapter 3.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@275518 91177308-0d34-0410-b5e6-96231b3b80d8
2016-07-15 01:39:49 +00:00
Wilfred Hughes
f9c643b6e0 New Kaleidoscope chapter: Creating object files
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-07-02 17:01:59 +00:00
Lang Hames
df424f76e5 [MCJIT] Update MCJIT and get the fibonacci example working again.
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-06-11 05:47:04 +00:00
Lang Hames
1fa1983597 [Orc] Add conversion to/from RuntimeDyld::SymbolInfo for JITSymbol.
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-31 23:14:26 +00:00
Lang Hames
9aaeb83f58 [Kaleidoscope][BuildingAJIT] Don't build Chapter 5 on Windows for now.
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
2016-05-30 01:18:32 +00:00
Lang Hames
203f697825 [Kaleidoscope][BuildingAJIT] Add code for Chapter 5 - remote JITing.
This chapter demonstrates lazily JITing from ASTs with the expressions being
executed on a remote machine via a TCP connection. It needs some polish, but is
substantially complete.

Currently x86-64 SysV ABI (Darwin and Linux) only, but other architectures
can be supported by changing the server code to use alternative ABI support
classes from llvm/include/llvm/ExecutionEngine/Orc/OrcABISupport.h.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271193 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-30 00:09:26 +00:00
Lang Hames
fe7405cb98 [Kaleidoscope][Orc] Remove the reference to the Orc directory that was removed
in r271059.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271061 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 22:21:12 +00:00
Lang Hames
7a2177551f [Kaleidoscope] Remove the old Kaleidoscope/ORC tutorial series.
This code has been superseded by the new Building A JIT series.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271059 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 22:17:56 +00:00
Lang Hames
b0acadce69 [Kaleidoscope][BuildingAJIT] Add code for chapter 4.
This chapter will cover lazy compilation directly from ASTs using the Compile
Callbacks and Indirect Stubs APIs.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@271054 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-27 21:50:13 +00:00
Lang Hames
dfc9470f33 [Kaleidoscope][BuildingAJIT] Remove leftover debugging output statements.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270919 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-26 21:27:52 +00:00
Lang Hames
ffdfc78e37 [Kaleidoscope][BuildingAJIT] Add explicit dependence on TransformUtils to Chapter3.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270914 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-26 21:00:29 +00:00
Lang Hames
e0c300733e [Kaleidoscope][BuildingAJIT] Add code for Chapter 3.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270909 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-26 20:35:39 +00:00
Lang Hames
67faeedf47 [Kaleidoscope][BuildingAJIT] Fix a bug in the symbol resolver in Chapter2.
Symbol resolution should be done on the top layer of the stack unless there's a
good reason to do otherwise. In this case it would have worked because
OptimizeLayer::addModuleSet eagerly passes all modules down to the
CompileLayer, meaning that searches in CompileLayer will find the definitions.
In later chapters where the top layer's addModuleSet isn't a pass-through, this
would break.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270899 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-26 19:44:33 +00:00
Lang Hames
fd4178f436 [Kaleidoscope][BuildingAJIT] Make the optimizeModule method for Chapter2
private.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270807 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-26 00:24:18 +00:00
Lang Hames
1ab578794e [Kaleidoscope][BuildingAJIT] Add code for the 2nd chapter of the BuildingAJIT
tutorial.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270794 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 23:25:23 +00:00
Lang Hames
f4f40d85e6 [Kaleidoscope][BuildingAJIT] Delete trailing whitespace.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270787 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 22:48:43 +00:00
Lang Hames
ba9118ae86 [Kaleidoscope][BuildingAJIT] Add a description of the KaleidoscopeJIT addModule
method to Chapter1 of the BuildingAJIT tutorial.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270778 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 22:27:25 +00:00
Eugene Zelenko
578a1d21a0 Fix some Include What You Use warnings in examples; other minor fixes.
Differential revision: http://reviews.llvm.org/D20607


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270645 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-25 01:18:36 +00:00
Lang Hames
5d82919adc [Kaleidoscope] Add an initial "Building an ORC JIT" tutorial chapter.
This is a work in progress - the chapter text is incomplete, though
the example code compiles and runs.

Feedback and patches are, as usual, most welcome.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270487 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-23 20:34:19 +00:00
Lang Hames
60e94e81eb [Kaleidoscope] Fix static global ordering to prevent crash on exit.
If TheModule is declared before LLVMContext then it will be destructed after it,
crashing when it tries to deregister itself from the destructed context.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270381 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-22 22:48:36 +00:00
Eugene Zelenko
efac554031 Fix some Clang-tidy modernize-use-bool-literals and Include What You Use warnings in examples; other minor fixes.
Differential revision: http://reviews.llvm.org/D20397


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@270008 91177308-0d34-0410-b5e6-96231b3b80d8
2016-05-19 01:08:04 +00:00