Commit Graph

403 Commits

Author SHA1 Message Date
Boris Ulasevich b76f6c2745 BrainF example: fixing segfault caused by outdated code with missing MCJIT dependency
Differential Revision: https://reviews.llvm.org/D26280

llvm-svn: 289857
2016-12-15 19:29:42 +00:00
NAKAMURA Takumi 689493bb12 Prune unused libdeps.
llvm-svn: 289060
2016-12-08 15:28:02 +00:00
Saleem Abdulrasool b14fc390dc 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.

llvm-svn: 287479
2016-11-20 02:36:38 +00:00
Saleem Abdulrasool c0e4e7d990 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.

llvm-svn: 287478
2016-11-20 02:36:36 +00:00
Eugene Zelenko ae7ac95cc9 [Examples] Fix some Clang-tidy modernize-use-default and Include What You Use warnings; other minor fixes.
Differential revision: https://reviews.llvm.org/D26433

llvm-svn: 287384
2016-11-18 21:57:58 +00:00
Lang Hames d8ec15184e [Orc] Update the BuildingAJIT Chapter 5 server class for the recent RPC changes.
llvm-svn: 286642
2016-11-11 21:55:25 +00:00
Lang Hames 1f2bf2d3e1 [ORC] Re-apply 286620 with fixes for the ErrorSuccess class.
llvm-svn: 286639
2016-11-11 21:42:09 +00:00
Lang Hames 4f734f254e [ORC] Revert r286620 while I investigate a bot failure.
llvm-svn: 286621
2016-11-11 19:46:46 +00:00
Lang Hames ae1fdddbc4 [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.

llvm-svn: 286620
2016-11-11 19:42:44 +00:00
Teresa Johnson 5923864597 Fix examples files to reflect header split in r286566.
I missed these files in examples/

llvm-svn: 286570
2016-11-11 06:02:04 +00:00
Malcolm Parsons 06ac79c210 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

llvm-svn: 285832
2016-11-02 16:43:50 +00:00
Lang Hames 1009b0b30f [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.

llvm-svn: 284657
2016-10-19 22:41:03 +00:00
Lang Hames 9ca9a31948 [BuildingAJIT] Make the chapter 5 server export symbols.
This will allow chapter 5 to work on Linux.

llvm-svn: 284637
2016-10-19 20:22:12 +00:00
Lang Hames bcdb994014 [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.

llvm-svn: 281945
2016-09-19 23:00:27 +00:00
Lang Hames 958b699883 [ORC] Update examples for header changes in r281171.
llvm-svn: 281178
2016-09-11 21:34:13 +00:00
Eric Christopher 269cd8d1d2 Fix singlton -> singleton typo.
llvm-svn: 279801
2016-08-26 02:00:21 +00:00
Justin Bogner cd1d5aaf2e Replace a few more "fall through" comments with LLVM_FALLTHROUGH
Follow up to r278902. I had missed "fall through", with a space.

llvm-svn: 278970
2016-08-17 20:30:52 +00:00
David Majnemer 0d955d0bf5 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.

llvm-svn: 278433
2016-08-11 22:21:41 +00:00
Lang Hames ad4a911fea [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.

llvm-svn: 277386
2016-08-01 20:49:11 +00:00
Lang Hames 7cd3ac724c [Kaleidoscope][BuildingAJIT] Start filling in text for chapter 3.
llvm-svn: 275518
2016-07-15 01:39:49 +00:00
Wilfred Hughes 945f43e94b 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

llvm-svn: 274441
2016-07-02 17:01:59 +00:00
Lang Hames 717eacfcf4 [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.

llvm-svn: 272455
2016-06-11 05:47:04 +00:00
Lang Hames 656532075b [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.

llvm-svn: 271350
2016-05-31 23:14:26 +00:00
Lang Hames f96bc6eb0c [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.

llvm-svn: 271194
2016-05-30 01:18:32 +00:00
Lang Hames a243ba9cad [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.

llvm-svn: 271193
2016-05-30 00:09:26 +00:00
Lang Hames 852c55491b [Kaleidoscope][Orc] Remove the reference to the Orc directory that was removed
in r271059.

llvm-svn: 271061
2016-05-27 22:21:12 +00:00
Lang Hames 2abf6bdfc2 [Kaleidoscope] Remove the old Kaleidoscope/ORC tutorial series.
This code has been superseded by the new Building A JIT series.

llvm-svn: 271059
2016-05-27 22:17:56 +00:00
Lang Hames d976fc99e6 [Kaleidoscope][BuildingAJIT] Add code for chapter 4.
This chapter will cover lazy compilation directly from ASTs using the Compile
Callbacks and Indirect Stubs APIs.

llvm-svn: 271054
2016-05-27 21:50:13 +00:00
Lang Hames f6d502d819 [Kaleidoscope][BuildingAJIT] Remove leftover debugging output statements.
llvm-svn: 270919
2016-05-26 21:27:52 +00:00
Lang Hames d7f3d9d878 [Kaleidoscope][BuildingAJIT] Add explicit dependence on TransformUtils to Chapter3.
llvm-svn: 270914
2016-05-26 21:00:29 +00:00
Lang Hames 7b6f914ba1 [Kaleidoscope][BuildingAJIT] Add code for Chapter 3.
llvm-svn: 270909
2016-05-26 20:35:39 +00:00
Lang Hames 4a59a34597 [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.

llvm-svn: 270899
2016-05-26 19:44:33 +00:00
Lang Hames deb27681d7 [Kaleidoscope][BuildingAJIT] Make the optimizeModule method for Chapter2
private.

llvm-svn: 270807
2016-05-26 00:24:18 +00:00
Lang Hames 684ec17cd9 [Kaleidoscope][BuildingAJIT] Add code for the 2nd chapter of the BuildingAJIT
tutorial.

llvm-svn: 270794
2016-05-25 23:25:23 +00:00
Lang Hames 1469f7f4a7 [Kaleidoscope][BuildingAJIT] Delete trailing whitespace.
llvm-svn: 270787
2016-05-25 22:48:43 +00:00
Lang Hames e0fc5aef18 [Kaleidoscope][BuildingAJIT] Add a description of the KaleidoscopeJIT addModule
method to Chapter1 of the BuildingAJIT tutorial.

llvm-svn: 270778
2016-05-25 22:27:25 +00:00
Eugene Zelenko 2b8e41705e Fix some Include What You Use warnings in examples; other minor fixes.
Differential revision: http://reviews.llvm.org/D20607

llvm-svn: 270645
2016-05-25 01:18:36 +00:00
Lang Hames 7331cc3774 [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.

llvm-svn: 270487
2016-05-23 20:34:19 +00:00
Lang Hames 247968041a [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.

llvm-svn: 270381
2016-05-22 22:48:36 +00:00
Eugene Zelenko f981ec4582 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

llvm-svn: 270008
2016-05-19 01:08:04 +00:00
Lang Hames 4821c24d08 [Orc] Rename OrcArchitectureSupport to OrcABISupport and add Win32 ABI support.
This enables lazy JITing on Windows x86-64.

Patch by David. Thanks David!

llvm-svn: 268845
2016-05-07 03:36:38 +00:00
Mehdi Amini 03b42e41bf Remove every uses of getGlobalContext() in LLVM (but the C API)
At the same time, fixes InstructionsTest::CastInst unittest: yes
you can leave the IR in an invalid state and exit when you don't
destroy the context (like the global one), no longer now.

This is the first part of http://reviews.llvm.org/D19094

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 266379
2016-04-14 21:59:01 +00:00
Lang Hames 5d045a9031 [Kaleidoscope] Rename Error -> LogError in Chapters 2-5.
This keeps the naming consistent with Chapters 6-8, where Error was renamed to
LogError in r264426 to avoid clashes with the new Error class in libSupport.

llvm-svn: 264427
2016-03-25 17:41:26 +00:00
Lang Hames f9878c54ae [Kaleidoscope] Fix 'Error' name clashes.
llvm-svn: 264426
2016-03-25 17:33:32 +00:00
Chandler Carruth ec5872bc42 [PM] Update Kaleidoscope with the new header file.
llvm-svn: 263223
2016-03-11 12:10:15 +00:00
Rafael Espindola 5cd721ae12 Refactor duplicated code for linking with pthread.
llvm-svn: 262344
2016-03-01 15:54:40 +00:00
Chris Bieneman e49730d4ba Remove autoconf support
Summary:
This patch is provided in preparation for removing autoconf on 1/26. The proposal to remove autoconf on 1/26 was discussed on the llvm-dev thread here: http://lists.llvm.org/pipermail/llvm-dev/2016-January/093875.html

"I felt a great disturbance in the [build system], as if millions of [makefiles] suddenly cried out in terror and were suddenly silenced. I fear something [amazing] has happened."
- Obi Wan Kenobi

Reviewers: chandlerc, grosbach, bob.wilson, tstellarAMD, echristo, whitequark

Subscribers: chfast, simoncook, emaste, jholewinski, tberghammer, jfb, danalbert, srhines, arsenm, dschuff, jyknight, dsanders, joker.eph, llvm-commits

Differential Revision: http://reviews.llvm.org/D16471

llvm-svn: 258861
2016-01-26 21:29:08 +00:00
NAKAMURA Takumi 8d3685a466 Fix examples corresponding to r257302.
llvm-svn: 257313
2016-01-11 05:04:20 +00:00
Lang Hames e52502c45e [Orc] Fix Kaleidoscope example for change in r254693.
llvm-svn: 254695
2015-12-04 02:32:32 +00:00
Duncan P. N. Exon Smith 5717ecba8e examples: Remove implicit ilist iterator conversions, NFC
llvm-svn: 252379
2015-11-07 00:55:46 +00:00