5165 Commits

Author SHA1 Message Date
Jonas Hahnfeld
927f761b8b TCling: Re-implement autoload via MaterializationUnits
Replace the existing LazyFunctionCreator interface by a function
to add DefinitionGenerators to be passed via the chain Interpreter
-> IncrementalExecutor -> IncrementalJIT.
Implement a DefinitionGenerator in TCling(Callbacks) to define
MaterializationUnits for autoloading symbols. This also allows to
remove the double DynamicLibrarySearchGenerator now that the created
AutoloadLibraryMUs inject the addresses into the JIT after loading
the required library.
2022-12-09 08:44:19 +01:00
Axel Naumann
619f5e83a2 Silence Orc missing symbols message:
IncrementalExecutor has its own, showing what is requesting the
symbols, which is more useful than the diagnostic of Orc. OTOH
Orc might emit more errors than just missing symbols, and if
there are multiple missing symbols, IncrementalExecutor only
shows the first.

So enable `Verbose` also for IncrementalJIT, showing the original
missing symbols as diagnosed by Orc.

This fixes roottest_cling_other_checkMissingSymbolExitCode which
fails due to the extra diagnostic error line.
2022-12-09 08:44:19 +01:00
Axel Naumann
c28fc71858 Remove duplicate / impossible condition. 2022-12-09 08:44:19 +01:00
Jonas Hahnfeld
f63fdda04e Weaken definitions of typeinfos and vtables
Introduce a backend pass that changes the linkage of external symbols
starting with "_ZT" (ie. typeinfo names, typeinfos, and vtables) to
weak symbols. This avoids duplicate symbol errors with the new JIT
linker.

FIXME: This is a hack, we should teach the frontend to emit these
only once, or mark all duplicates as available_externally (if that
improves performance due to optimizations).
2022-12-09 08:44:19 +01:00
Jonas Hahnfeld
e338773863 Avoid duplicate symbols from RuntimeUniverse.h
Make InterpreterGeneratedCodeDiagnosticsMaybeIncorrect static, which
is then turned into a weak symbol by KeepLocalGVPass.
2022-12-09 08:44:19 +01:00
Jonas Hahnfeld
d8451f6822 Print default template arguments
Fixes (at least) roottest-cling-stl-default-VectorSort and
roottest-cling-templateMembers-runoperatorEqual.
2022-12-09 08:44:19 +01:00
Jonas Hahnfeld
3bbcfe34b1 Ignore duplicate kept GlobalValues
Set WeakAnyLinkage instead of ExternalLinkage to tell the JIT linker
that it should not error on duplicate symbols.
2022-12-09 08:44:19 +01:00
Jonas Hahnfeld
b721467e15 Fix emission of vtables
It is (again) necessary to call DefineUsedVTables() to enable (at
least) the emission of implicitly defined destructors overriding
the virtual destructor in a base class, see the added test.
2022-12-09 08:44:19 +01:00
Vassil Vassilev
ed72130ee6 Fix the special case for Windows. FIXE: Try remove ifdef 2022-12-09 08:44:19 +01:00
Vassil Vassilev
b4b96a6d85 The JIT now is more consistent on OSX with the linker-level mangling
OSX (due to legacy to disambigate between asm and C symbols) implements an extra
linker-level mangling which adds another `_` in the name. However, that is only
in the on-disk representation and needs to be dropped upon calling dlsym.

OrcV2 gives us a handle to the symbol with starts with `__` allowing us to
invert the logic of the symbol search where we drop the `__` for dlsym.
2022-12-09 08:44:19 +01:00
Jonas Hahnfeld
b7aaa96719 Print 'a<b<c> >' rather than 'a<b<c>>' in ValuePrinter
See earlier commit for the Transform.C test.
2022-12-09 08:44:19 +01:00
Jonas Hahnfeld
ae776451fc Move Autoload annotation after scope keyword
Otherwise tests/Autoloading/AutoForwarding.C complains that "an
attribute list cannot appear here".
2022-12-09 08:44:19 +01:00
Jonas Hahnfeld
106e1771aa Fix some trivial compiler warnings
"moving a local object in a return statement prevents copy elision" as
well as an unused variable and function referenced only from an assert.
2022-12-09 08:44:19 +01:00
Jonas Hahnfeld
1cba6d415c Do not externalize unnamed GlobalValues
It doesn't make sense and the JIT crashes, see upstream bug report
https://github.com/llvm/llvm-project/issues/54813
2022-12-09 08:44:19 +01:00
Jonas Hahnfeld
b20a403638 Fix CUDA architecture selection
--cuda-gpu-arch aliases --offload-arch, so the option parser will
canonicalize to the latter.
2022-12-09 08:44:19 +01:00
Vassil Vassilev
b9ac132337 Try fixing the multicore 2022-12-09 08:44:19 +01:00
Vassil Vassilev
6428d2c15c Do not install {Clang,Cling}Config.cmake in the project lib dir.
This should fix the clad builds and unpollute the ROOTSYS/lib.
2022-12-09 08:44:19 +01:00
Vassil Vassilev
c8e1a89726 Add another symbol generator to resolve the generated lazy symbol.
The in-process symbol generator resolves symbols available in the process and
all dlopened libraries. However, upon unresolved symbol, we trigger our lazy
loading function creator callbacks which load the relevant library. Then we
need another in-process symbol generator to catch the newly created symbol so
that the JIT is happy.

This solution is suboptimal and in the comments is provided a cleaner
implementation, however, this implementation loads libraries for weak symbols
that the JIT could generate. This needs to be further investigated.
2022-12-09 08:44:19 +01:00
Vassil Vassilev
090176dcfd Use consistent TUKind for the Preproocessor and Sema.
This fixes an assertion.
2022-12-09 08:44:19 +01:00
Vassil Vassilev
a68d95843b getClangToolFullVersion doesn't show empty space anymore.
See llvm/llvm-project@bbea4d5e6b
2022-12-09 08:44:19 +01:00
Vassil Vassilev
19442cee3a Complete the upgrade to LLVM/Clang 13 for cling. 2022-12-09 08:44:19 +01:00
Vassil Vassilev
ce20a30022 Unconditionally install ClingTargets.cmake, required by ClingConfig.cmake
This fixes our -Dbuiltin_cling=Off option.
2022-12-09 08:44:18 +01:00
Vassil Vassilev
3ea6cd0e18 Re-teach getAddressOfGlobal to tell if something came from the JIT.
This patch also inverts the parameter from ExcludeHostSymbols to
IncludeHostSymbols to improve readability.

As written in one of the FIXMEs this is a temporary solution which allows us to
go further with the llvm-13 upgrade. We can rework the getAddress* functionality
to reuse more the ORCV2 infrastructure and more importantly to use that
infrastructure in the recommended way.
2022-12-09 08:44:18 +01:00
Vassil Vassilev
6656a92d22 Diagnostic text changed 2022-12-09 08:44:18 +01:00
Vassil Vassilev
8115be39be Rename addSymbol to match what it does and remove redundant params. 2022-12-09 08:44:18 +01:00
Vassil Vassilev
a804b3d9eb LLVM now requires C++14.
Patch by Lang Hames.
2022-12-09 08:44:18 +01:00
Vassil Vassilev
a656f18868 Print a<b<c> >' rather than 'a<b<c>>' in the Transform.C test.
See llvm/llvm-project@159a9f7e76
2022-12-09 08:44:18 +01:00
Vassil Vassilev
de1c0feddc Update the comment, we still need this if g++ > 5 2022-12-09 08:44:18 +01:00
Vassil Vassilev
6c35a3a41e The OrcV2 now can iterate over the globals and run the static init for us. 2022-12-09 08:44:18 +01:00
Vassil Vassilev
44de0d81dd Rework the symbol injection mechanism to also allow symbol replacement. 2022-12-09 08:44:18 +01:00
Vassil Vassilev
112e25e92a Jitlink does not support all necessary platfroms, switch to RuntimeDyld. 2022-12-09 08:44:18 +01:00
Vassil Vassilev
51905a3b6f IncrementalJIT::getSymbolAddress is expected to return 0 and never complain. 2022-12-09 08:44:18 +01:00
Vassil Vassilev
c8ffc972b7 Implement a solution to the JIT-owned llvm::Modules.
When removing code, we need to recover Clang's CodeGen and this happens by
iterating over the clang::Decls and the llvm::Module for a given Transaction in
the TransactionUnloader.

The problem is that now OrcV2 takes the ownership of the llvm::Module from the
Transaction for itself and then it can notify us when the module was compiled on
demand. Unfortuantely, there is no good way to guarantee that the same module
will be attached to the same transaction. This approach allows the
TransactionUnloader::unloadModule logic to recover CodeGen.

In a longer term, when we switch to partial translation units from clang-repl
we might be able to recover CodeGen without needing to know details about the
generated llvm::Module.
2022-12-09 08:44:18 +01:00
Vassil Vassilev
c903730344 Drop the unused Interpreter::addSymbol function.
It just adds to the complexity and confusion of the addSymbol implementation
2022-12-09 08:44:18 +01:00
Vassil Vassilev
357a4c8377 OrcV2 is more strict with linkage.
When we compile incremental inputs we store each input in a separate
llvm::Module. In order to preserve the semantics, we make all symbols from
each module with external linkage, that is, accessible from other modules.

This model works well for almost all symbols, except for the clang-generated
ones which have the same name. For example clang stores strings in variables
`.strN` which may clash accross modules. Luckily, these strings are used within
a single module and thus we can avoid the JIT error by keeping them with their
non-external linkage.
2022-12-09 08:44:18 +01:00
Stefan Gränitz
7b27b283f9 Implement --debug-only option in order to easily dump LLVM debug output
For example: `cling --debug-only="orc,jitlink"`
2022-12-09 08:44:18 +01:00
Vassil Vassilev
6254189e8b Connect the JIT with the lazy symbol creation infrastructure. 2022-12-09 08:44:18 +01:00
Vassil Vassilev
6385f4c1be The new API requires the address of the files 2022-12-09 08:44:18 +01:00
Vassil Vassilev
af078b845e llvm::StringRef::*lower became insensitive.
See llvm/llvm-project@2e4a2b8430
2022-12-09 08:44:18 +01:00
Vassil Vassilev
f2520d9a39 PrintHelp is now lower case. 2022-12-09 08:44:18 +01:00
Vassil Vassilev
085224eb0c Use AnnotateAttr::CreateImplicit function which is now available.
See llvm/llvm-project@d093401a26
2022-12-09 08:44:18 +01:00
Vassil Vassilev
fde158fced OPT_fmodule_name was dropped. 2022-12-09 08:44:18 +01:00
Vassil Vassilev
871a7366ac LookupFile returns FileEntryRef. 2022-12-09 08:44:18 +01:00
Vassil Vassilev
790815d584 Target::adjust takes DiagnosticsEngine 2022-12-09 08:44:18 +01:00
Vassil Vassilev
b1b1d72178 CreateASTDumper takes another bool arg.
See llvm/llvm-project@e135cf8a03
2022-12-09 08:44:17 +01:00
Vassil Vassilev
04cb65dcb2 DirectoryLookup takes a DirectoryRef.
See llvm/llvm-project@0377ca641c
2022-12-09 08:44:17 +01:00
Vassil Vassilev
a40bf8e573 DisablePCHValidation became an enum
See llvm/llvm-project@b0e89906f5
2022-12-09 08:44:17 +01:00
Vassil Vassilev
c72f7a1109 ParseUnqualifiedId has new set of params.
See llvm/llvm-project@0dd0b1017c
2022-12-09 08:44:17 +01:00
Vassil Vassilev
ec413fe1a8 setSuppressAllDiagnostics has no default anymore.
Remove duplicate line of code.
2022-12-09 08:44:17 +01:00
Vassil Vassilev
0c183d3adf APSInt::toString returning std::string was removed.
See llvm/llvm-project@61cdaf66fe
2022-12-09 08:44:17 +01:00