700 Commits

Author SHA1 Message Date
Lang Hames
d467396ae0 [emamples][OrcV2Examples] Fix a missing newline in LLJITRemovableCode output. 2023-07-30 08:51:42 -07:00
Jie Fu
c2cabe479b [examples] Fix -Wcast-qual in OrcV2Examples after D153911 (NFC)
/Users/jiefu/llvm-project/llvm/examples/OrcV2Examples/OrcV2CBindingsBasicUsage/OrcV2CBindingsBasicUsage.c:77:52: error: cast from 'char **' to 'const char **' must have all intermediate pointers const qualified to be safe [-Werror,-Wcast-qual]
  LLVMParseCommandLineOptions(argc, (const char **)argv, "");
                                                   ^
/Users/jiefu/llvm-project/llvm/examples/OrcV2Examples/OrcV2CBindingsAddObjectFile/OrcV2CBindingsAddObjectFile.c:63:52: error: cast from 'char **' to 'const char **' must have all intermediate pointers const qualified to be safe [-Werror,-Wcast-qual]
  LLVMParseCommandLineOptions(argc, (const char **)argv, "");
                                                   ^
/Users/jiefu/llvm-project/llvm/examples/OrcV2Examples/OrcV2CBindingsDumpObjects/OrcV2CBindingsDumpObjects.c:62:52: error: cast from 'char **' to 'const char **' must have all intermediate pointers const qualified to be safe [-Werror,-Wcast-qual]
  LLVMParseCommandLineOptions(argc, (const char **)argv, "");
                                                   ^
...
2023-07-19 14:55:58 +08:00
Carlo Bramini
a6ea0185d6 [llvm] CYGWIN: Fix build of some plugins/library/unittests
CYGWIN uses the same format of WIN32 for shared libraries.
As the comment says: "a shared library can't have undefined references", in this case CYGWIN must be handled like WIN32 by CMakeLists.txt, otherwise you will get several errors when linking because some symbols are undefined.
Attached patch fixes this issue and allows to complete the build process for those targets.

Differential Revision: https://reviews.llvm.org/D154794
2023-07-10 22:43:03 +03:00
Elliot Goodrich
b0abd4893f [llvm] Add missing StringExtras.h includes
In preparation for removing the `#include "llvm/ADT/StringExtras.h"`
from the header to source file of `llvm/Support/Error.h`, first add in
all the missing includes that were previously included transitively
through this header.
2023-06-25 15:42:22 +01:00
Lang Hames
13f5125f9d [tutorials] Add missing ExecutorSymbolDef header.
Similar to c118d05f9ed, but applied to the base Kaleidoscope series.
2023-06-21 08:51:17 -07:00
Lang Hames
c118d05f9e [tutorials][BuildingAJIT] Add missing ExecutorSymbolDef header. 2023-06-21 08:35:37 -07:00
Lang Hames
d120d77f72 [ORC] Simplify construction of EPCIndirectionUtils.
ExecutionSessions always have an ExecutorProcessControl object now, so we can
construct EPCIndirectionUtil objects directly from an ExecutionSession.
2023-06-07 16:28:07 -07:00
Tobias Hieta
b71edfaa4e
[NFC][Py Reformat] Reformat python files in llvm
This is the first commit in a series that will reformat
all the python files in the LLVM repository.

Reformatting is done with `black`.

See more information here:

https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style

Reviewed By: jhenderson, JDevlieghere, MatzeB

Differential Revision: https://reviews.llvm.org/D150545
2023-05-17 10:48:52 +02:00
Lang Hames
b92839c954 Re-apply "[ORC][LLJIT] Use JITLink by default on ELF/x86-64." with fixes.
This reapplies 85c649bc02a, which was reverted in 35767e43d62 due to failures
with some example programs. The fix was to add export_executable_symbols to the
example programs.
2023-04-23 10:20:09 +00:00
Lang Hames
231107a8b5 Re-apply "[ORC] LLJIT updates: ExecutorNativePlatform, default ..." with fixes.
This reapplies 371cb1af61d, which was reverted in 0b2240eda01 due to bot
failures.

The clang-repl test failure is fixed by dropping the process symbols definition
generator that was manually attached to the main JITDylib, since LLJIT now
exposes process symbols by default. (The bug was triggered when JIT'd code used
the process atexit provided by the generator, rather than the JIT atexit which
has been moved into the platform JITDylib).

Any LLJIT clients that see crashes in static destructors should likewise remove
any process symbol generators attached to their main JITDylib.
2023-04-08 02:40:58 +00:00
Stefan Gränitz
4c7f53b99c [Orc] Add AutoRegisterCode option for DebugObjectManagerPlugin
Configure the plugin to automatically call the debugger rendezvous breakpoint `__jit_debug_register_code()` for every translation unit (enabled) or never at all (disabled). Default API and behavior remain unchanged.

If AutoRegisterCode is turned off, it's the client's own responsibility to call the rendezvous breakpoint function at an appropriate time.
Depending on the complexity of the debugger's rendezvous breakpoint implementation, this can provide significant performance improvements in cases where many debug objects are added in sequence.

Reviewed By: lhames

Differential Revision: https://reviews.llvm.org/D147310
2023-04-03 15:38:07 +02:00
Lang Hames
8b1771bd9f [ORC] Move most ORC APIs to ExecutorAddr, introduce ExecutorSymbolDef.
ExecutorAddr was introduced in b8e5f918166 as an eventual replacement for
JITTargetAddress. ExecutorSymbolDef is introduced in this patch as a
replacement for JITEvaluatedSymbol: ExecutorSymbolDef is an (ExecutorAddr,
JITSymbolFlags) pair, where JITEvaluatedSymbol was a (JITTargetAddress,
JITSymbolFlags) pair.

A number of APIs had already migrated from JITTargetAddress to ExecutorAddr,
but many of ORC's internals were still using the older type. This patch aims
to address that.

Some public APIs are affected as well. If you need to migrate your APIs you can
use the following operations:

* ExecutorAddr::toPtr replaces jitTargetAddressToPointer and
  jitTargetAddressToFunction.

* ExecutorAddr::fromPtr replace pointerToJITTargetAddress.

* ExecutorAddr(JITTargetAddress) creates an ExecutorAddr value from a
  JITTargetAddress.

* ExecutorAddr::getValue() creates a JITTargetAddress value from an
  ExecutorAddr.

JITTargetAddress and JITEvaluatedSymbol will remain in JITSymbol.h for now, but
the aim will be to eventually deprecate and remove these types (probably when
MCJIT and RuntimeDyld are deprecated).
2023-03-27 17:37:58 -07:00
Lang Hames
2ad8e6e082 [examples] Add export_executable_symbols to HowToUseLLJIT example.
LLJIT needs access to symbols (e.g. llvm_orc_registerEHFrameSectionWrapper)
that will be defined in the executable when LLVM is linked statically.

Should fix https://github.com/llvm/llvm-project/issues/61712.
2023-03-26 18:27:54 +00:00
Arthur Eubanks
7c3c981442 [Passes] Remove some legacy passes
DFAJumpThreading
JumpThreading
LibCallsShrink
LoopVectorize
SLPVectorizer
DeadStoreElimination
AggressiveDCE
CorrelatedValuePropagation
IndVarSimplify

These are part of the optimization pipeline, of which the legacy version is deprecated and being removed.
2023-03-10 17:17:00 -08:00
Nikita Popov
4d513bd9a5 [Orc] Remove LLVMInitializeCore() calls from examples
Per discussion on D144970, these are no longer necessary.
2023-03-01 09:56:59 +01:00
Nikita Popov
abdefc895d [Orc] Try to fix linker error
Try to fix flang-aarch64-sharedlibs build.

7344f8a8442a9c3cef159445f71b4f2886ed2798 introduced a use of
LLVMCreatePassBuilderOptions(), which is part of the Passes
library, while previously only InstCombine was linked.
2023-02-28 17:42:47 +01:00
Nikita Popov
7344f8a844 [Orc] Use new pass manager in example
Invoke InstCombine via the new pass manager, instead of the
legacy pass manager.
2023-02-28 16:53:09 +01:00
Archibald Elliott
d768bf994f [NFC][TargetParser] Replace uses of llvm/Support/Host.h
The forwarding header is left in place because of its use in
`polly/lib/External/isl/interface/extract_interface.cc`, but I have
added a GCC warning about the fact it is deprecated, because it is used
in `isl` from where it is included by Polly.
2023-02-10 09:59:46 +00:00
Arthur Eubanks
84728a3d75 [Inliner] Remove legacy simple inliner
It's part of the optimization pipeline, of which the legacy pass manager version is deprecated.
2023-02-09 10:36:58 -08:00
Dhruv Chawla
1625530d76 [Kaleidoscope] Update code snippets in text to match full code listings
There were quite a few places in the tutorial where the snippets were not up to date with the full code listings given. I have updated all of the ones I could find, which mostly involves changing `.` to `->` when accessing through a `std::unique_ptr`, changing `while (1)` to `while (true)`, and other such small changes.

There are still however a few places where I am not sure what to do, such as:
- Chapter 4: `ParseTopLevelExpr()` in chapter 3 sets the ProtoTypeAST
             name to "", however it is referred to as "__anon_expr"
             in chapter 4. Would it be required to mention this change
             in chapter 4?
- Chapter 9: The code snippets refer to the top level expression as
             "main", however the full code listing refers to it as
             "__anon_expr". I think given the context of the chapter
             it makes sense to refer to it as "main", so I have
             updated the code listing to reflect that.
- Chapter 9: In chapter 9 the diff given for `HandleTopLevelExpression()`
             deletes code that is not mentioned anywhere else, so I am
             not sure what is to be done there.
- Miscellaneous: I don't think this is very important, however the
                 casing used for the first word of error messages
                 tends to vary between upper and lower case between
                 chapters and I do not know if it is worth reconciling
                 these differences.

Reviewed By: xgupta

Differential Revision: https://reviews.llvm.org/D142323
2023-01-31 23:31:02 +05:30
Sebastian Peryt
d291f1fd09 [LegacyPM] Port example pass SimplifyCFG to new PM
This is part of effort in removing -enable-new-pm flag.
As a prat of this effort one of example passes SimplifyCFG must
be ported to new PM which will allow to remove the flag
calls from the tests that are using this pass.

Reviewed By: aeubanks

Differential Revision: https://reviews.llvm.org/D137103
2023-01-10 15:42:01 -08:00
Lang Hames
23c1822d1a [examples] Fix leaks in OrcV2 c-bindings examples.
rdar://103599609
2022-12-23 21:11:47 -08:00
Lang Hames
a4e3457fb7 [examples] Direct HowToUseJIT readers to HowToUseLLJIT instead.
HowToUseJIT describes the older APIs. We want to discourage their use in new
projects.
2022-12-23 01:10:27 -08:00
Archibald Elliott
16c4c4e04c [Examples] Fix TargetParser Dependency 2022-12-20 12:51:57 +00:00
Archibald Elliott
f09cf34d00 [Support] Move TargetParsers to new component
This is a fairly large changeset, but it can be broken into a few
pieces:
- `llvm/Support/*TargetParser*` are all moved from the LLVM Support
  component into a new LLVM Component called "TargetParser". This
  potentially enables using tablegen to maintain this information, as
  is shown in https://reviews.llvm.org/D137517. This cannot currently
  be done, as llvm-tblgen relies on LLVM's Support component.
- This also moves two files from Support which use and depend on
  information in the TargetParser:
  - `llvm/Support/Host.{h,cpp}` which contains functions for inspecting
    the current Host machine for info about it, primarily to support
    getting the host triple, but also for `-mcpu=native` support in e.g.
    Clang. This is fairly tightly intertwined with the information in
    `X86TargetParser.h`, so keeping them in the same component makes
    sense.
  - `llvm/ADT/Triple.h` and `llvm/Support/Triple.cpp`, which contains
    the target triple parser and representation. This is very intertwined
    with the Arm target parser, because the arm architecture version
    appears in canonical triples on arm platforms.
- I moved the relevant unittests to their own directory.

And so, we end up with a single component that has all the information
about the following, which to me seems like a unified component:
- Triples that LLVM Knows about
- Architecture names and CPUs that LLVM knows about
- CPU detection logic for LLVM

Given this, I have also moved `RISCVISAInfo.h` into this component, as
it seems to me to be part of that same set of functionality.

If you get link errors in your components after this patch, you likely
need to add TargetParser into LLVM_LINK_COMPONENTS in CMake.

Differential Revision: https://reviews.llvm.org/D137838
2022-12-20 11:05:50 +00:00
Lang Hames
bf6d7ca987 [ORC] Add JITDylib argument to ResourceManager notify-removing/transferring ops.
In some cases it's helpful to group trackers by JITDylib. E.g. Platform classes
may want to track initializer symbols with a `JITDylib -> Tracker -> [ Symbol ]`
map. This makes it easy to collect all symbols for the JITDylib, while still
allowing efficient removal of a single tracker. Passing the JITDylib as an
argument to ResourceManager::notifyRemovingResources and
ResourceManager::notifyTransferringResources supports such use-cases.
2022-12-19 14:56:08 -08:00
Nikita Popov
9d3f9adf04 [Examples] Fix build (NFC)
Can't use VLA at file scope.
2022-12-19 09:38:44 +01:00
Wenzel Jakob
10d0bd44ae [C-API] Add example code to exercise new MCJIT-like-memory-manager API.
This example shows how to use the newly added
LLVMOrcCreateRTDyldObjectLinkingLayerWithMCJITMemoryManagerLikeCallbacks API.
2022-12-17 14:15:07 +11:00
Vasileios Porpodas
cb5ebfa282 [NFC] Cleanup: Remove instances of Function::getBasicBlockList()
This is part of a series of patches that aim at making Function::getBasicBlockList() private.

Differential Revision: https://reviews.llvm.org/D140121
2022-12-15 13:08:25 -08:00
Vasileios Porpodas
32b38d248f [NFC] Rename Instruction::insertAt() to Instruction::insertInto(), to be consistent with BasicBlock::insertInto()
Differential Revision: https://reviews.llvm.org/D140085
2022-12-15 12:27:45 -08:00
Vasileios Porpodas
80f2f1eabc [NFC] Rename Function::insertBasicBlockAt() to Function::insert().
I think this is a better name because it is what STL uses.

Differential Revision: https://reviews.llvm.org/D140068
2022-12-15 10:03:37 -08:00
Vasileios Porpodas
8580de156f [NFC] Fixes ModuleMaker example build failure caused by c143b77b30fc23f70aac94be66e412651771c0fc
Differential Revision: https://reviews.llvm.org/D140052
2022-12-14 14:52:02 -08:00
Vasileios Porpodas
dd3d679179 [NFC] Fixes BrainF example build failure caused by c143b77b30fc23f70aac94be66e412651771c0fc 2022-12-14 14:16:04 -08:00
Vasileios Porpodas
a19ae77d2a [IR][NFC] Adds Function::insertBasicBlockAt() to replace things like F->getBasicBlockList().insert()
This is part of a series of patches that aim at making Function::getBasicBlockList() private.

Differential Revision: https://reviews.llvm.org/D139906
2022-12-12 20:22:55 -08:00
Kazu Hirata
934942c033 [llvm] Don't include Optional.h (NFC)
These source files no longer use Optional<T>, so they do not need to
include Optional.h.

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
2022-12-06 22:34:50 -08:00
Nikita Popov
92c96f29fa [Kaleidoscope] Fix build after std::optional changes 2022-12-05 08:37:08 +01:00
Arthur Eubanks
cff6d125fb [Bye] Remove legacy pipeline registration
D137915 has somehow caused a flang bot to fail: https://lab.llvm.org/buildbot/#/builders/191/builds/11279.

Given that the issue is with the legacy pipeline registration code and the legacy pipeline registration infrastructure is to be removed soon, remove this part of Bye.
2022-11-18 13:47:19 -08:00
Arthur Eubanks
5404fe3456 Revert "[LegacyPM] Remove pipeline extension mechanism"
This reverts commit 4ea6ffb7e8edcea7f2cfb22acc907640a9ba44b9.

Breaks various backends.
2022-10-28 10:26:58 -07:00
Arthur Eubanks
4ea6ffb7e8 [LegacyPM] Remove pipeline extension mechanism
Part of gradually removing the legacy PM optimization pipeline.

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D136622
2022-10-28 10:16:52 -07:00
Lang Hames
e7673d982d [ORC] Force linking of eh-frame registration functions from LLJIT.cpp.
Since aedeb8d5570, which switched to EPC-based eh-frame registrationin LLJIT,
the eh-frame registration functions need to be forcibly linked into the target
process.

Failure to link the eh-frame registration functions triggered a test failure in
https://green.lab.llvm.org/green/job/clang-stage1-RA/31497, which was fixed by
forcibly linking the registration functions into that test case in saf2b2214b4
(rdar://101083784), however it has also caused some tests (e.g. the C API unit
tests) that depend on successful construction of an LLJIT instance to be
skipped.

Moving the forcible registration into LLJIT.cpp fixes the general issue.
2022-10-23 13:55:55 -07:00
Lang Hames
af2b2214b4 [examples][ORC] Make sure eh-frame registration code is linked into an example.
Since aedeb8d5570, which switched to EPC-based eh-frame registration, the
eh-frame registration functions need to be forcibly linked into the target
process.

We need a general solution to this problem, but for now just force it in this
example to fix the test failures in
https://green.lab.llvm.org/green/job/clang-stage1-RA/31497

rdar://101083784
2022-10-19 15:03:42 -07:00
Lang Hames
158ad803ee [examples] Fix deprecated use of llvm::empty. 2022-10-09 22:00:43 -07:00
Fangrui Song
de9d80c1c5 [llvm] LLVM_FALLTHROUGH => [[fallthrough]]. NFC
With C++17 there is no Clang pedantic warning or MSVC C5051.
2022-08-08 11:24:15 -07:00
Lang Hames
424626953e [examples][ORC] Add missing call to LLVMDisposeBuilder to example.
The missing call was pointed out in https://llvm.org/PR56953, though it's not
the focus of that issue.
2022-08-05 13:52:03 -07:00
Nikita Popov
62ec8e94b8 [Examples] Fix SimplifyCFG example
After fffabd53482f34f96ab9273486538f587e3d91fc, the v2 and v3
versions produce poison instead of undef. Also adjust the v1
version, as well as the test expectations, to make the example
pass again.
2022-08-01 07:22:35 +02:00
Marc Auberer
972fe43133 [Kaleidoscope] Remove unused function argument
Removes an unused function argument from a code listing in the Kaleidoscope turorial in step 9.

Reviewed By: dblaikie, MaskRay

Differential Revision: https://reviews.llvm.org/D128628
2022-06-30 20:47:01 +00:00
David Blaikie
9f94d63a6a Add missing (void) for function declarations in C 2022-06-28 00:45:17 +00:00
Fangrui Song
95a134254a Remove unneeded cl::ZeroOrMore for cl::opt/cl::list options 2022-06-05 01:07:51 -07:00
Fangrui Song
d86a206f06 Remove unneeded cl::ZeroOrMore for cl::opt/cl::list options 2022-06-05 00:31:44 -07:00
Fangrui Song
d0d1c416cb Remove unneeded cl::ZeroOrMore for cl::list options 2022-06-04 23:51:13 -07:00