Commit Graph

79 Commits

Author SHA1 Message Date
Devajith Valaparambil Sreeramaswamy
4f2c339d5c Remove m_MemoryBuffers completely 2024-05-06 16:59:09 +02:00
Devajith Valaparambil Sreeramaswamy
f4471da415 Move parts of Parse to another function 2024-05-06 16:59:09 +02:00
Sergey Linev
0525bca060 Use nullptr in cling
Avoid warnings when -Wzero-as-null-pointer-constant is specified
2023-01-30 08:29:07 +01:00
Jonas Hahnfeld
092c9c981f Increase initial offset into virtual file
Otherwise the PresumedLoc's suddely get valid once we avoid a
completely empty soure buffer in the next commit.
2022-12-13 09:59:05 +01:00
Javier Lopez-Gomez
dd1a74f009 Enable replacement of the default diagnostic consumer
These changes enable the replacement of the default DiagnosticConsumer provided
by CIFactory.  Concretely, two member functions have been added to the
Interpreter class:

- replaceDiagnosticConsumer(): replaces the default CIFactory-provided DiagnosticConsumer.

- hasReplacedDiagnosticConsumer(): returns whether the default diagnostic
consumer has been replaced.
2021-09-09 14:59:06 +02:00
Vassil Vassilev
cd484295c1 Teach cling to give unique source locations.
In number of cases over the last years we have seen a need to call clang APIs
with valid source locations. The interpreter generates code and valid locations
can be problematic.

This patch allows cling to return a valid source location even when no code was
processed. This way we can provide our modules infrastructure proper source
locations to activate the module visibility rules on locations which have common
predecessor. The common predecessor is essential when we compare entities for
diagnostics or reasoning about module visibility.
2020-02-25 21:47:05 +01:00
Simeon Ehrig
2489cf13b1 Replaced incremental PTX compiler with a internal implementation
Replaced the old version of the PTX compiler which used external tools and llvm::ExecuteAndWait with an internal implementation. The new incremental PTX compiler uses a modified version of the cling::Interpreter instance. The instance can process the PTX built-ins and generates LLVM IR. The LLVM IR is be compiled to PTX via an additional NVPTX backend implemented in the IncrementalCUDADeviceCompiler.

The new implementation has many advantages:
- it's much faster than the old version
- less error-prone because the ASTPrinter and some unnecessary cling transformations are avoided
- reduction of problems in searching for external tools (can be very complicated on HPC systems)

The IncrementalCUDADeviceCompiler is moved from the cling::IncrementalParser to the cling::Interpreter, because the second interpreter needs the input without wrappers or transformations.
2019-11-07 19:29:15 +01:00
Axel Naumann
6a73fd08d2 Help ValuePrinter find the transaction:
If the ValuePrinter runtime header gets included,
a transaction might be emitted, and the transaction
containing the function body cannot be found anymore.
This causes roottest/root/meta/getFuncBody.C to fail
with runtime modules.
2019-09-01 09:15:17 +02:00
Vassil Vassilev
74685d3725 Store rdict files as module file extensions.
This patch moves the ROOT-specific rdict.pcm optimization in the EXTENSION_BLOCK
of a C++ module file.

This reduces the generated artifacts and simplifies the loading of a rdict pcm
file as it is now part of the C++ module file. This patch paves our way to
using the global module indexing.
2019-06-19 18:59:07 +02:00
Vassil Vassilev
272905eced Implement clang plugin support.
Clang allows third party shared libraries to provide user-defined
extensions. For example, a custom libTemplateInstantiation.so can
visualize all template instantiation chains in clang. To enable it
one needs to pass a set of options such as -fplugin.

Cling should be able to inherently work with clang plugins. However,
cling still does not make full use of the clang driver where the plugin
setup is handled.

This patch enables plugins in cling and extends them in some aspects.
In particular, cling allows loading of plugins from shared libraries
but also if they are linked to the same library where cling is. This is
very useful in cases where cling runs itself in a shared library (eg
libCling). Users of libCling (such as ROOT) prefer to keep all llvm and
clang related symbols local to avoid symbol clashes if there is another
version of clang and llvm linked against a package. This can be done by
dlopen-ing libCling with RTLD_LOCAL visibility mode. Then the only way
for clang plugins to work in this scenario is to be linked to libCling.

Patch by Aleksandr Efremov and me.
2018-07-28 13:17:44 +02:00
Simeon Ehrig
9a4418b3c0 Improvements for Pull Request #240
- little changes at comments and code style
- try to use const in IncrementalCUDADeviceCompiler, where is possible
- move CUDA device code compiler instance to IncrementalParser
- change the members of CuArgs to const and adjust the setCuArgs method
- use std::vector<string> instead llvm::Smallvector<const char *> to build argv for executeAndWait
- improve the error messages of generatePCH(), generatePTX() and generateFatbinary()
- replace m_Counter with a copy in IncrementalCUDADeviceCompiler to avoid involuntary changes
2018-06-25 08:29:07 +02:00
Axel Naumann
3918184d11 StartModule(), makeModuleName() do not need to be public. 2017-06-28 14:08:13 +02:00
Frederich Munch
c0ccc621da Refactor common code for creating modules in IncrementalParser. 2017-06-28 14:08:13 +02:00
Raphael Isemann
b2ed65dbbf Remove unimplemented shouldIgnore from IncrementalParser. (#545)
The function implementation was moved to a static function in
the DeclCollector in commit 858120920f51a3ea8f689d19f2a2fa1cc3981eb1
about 'Emit Decls as DeclCollector sees them'.
2017-05-03 11:44:18 +02:00
Frederich Munch
efd446871c Fix LLVM API misuse when trying to replace and keep a DiagnosticConsumer. 2017-02-02 11:44:05 +01:00
Frederich Munch
6aa837920e Check initialization is proceeding as expecting.
Don't blindly run through initialization; make sure things are going according to plan.
If not handle it and run destructors without crashing.
Return standard error codes from main.
2017-02-01 13:14:11 +01:00
Frederich Munch
0e6023ed67 Add argument to IncrementalParser::commitTransaction to avoid clearing the DiagnosticsConsumer. Remove temporary variable. 2017-02-01 13:14:10 +01:00
Axel Naumann
2e4b59990d Move BackendPasses to IncrementalExecutor.
They need the TargetMachine - and that's in the IncrementalExecutor.
2016-11-15 16:44:32 +01:00
Axel Naumann
3711cd0658 Unloaded Decls are now put back into CodeGen, no need to mark used. 2016-11-07 13:02:51 +01:00
Frederich Munch
60ecba7d61 Make CIFactory a namespace, not a class.
Signed-off-by: Vassil Vassilev <vvasilev@cern.ch>
2016-08-18 15:44:18 +02:00
Frederich Munch
5ee1cfb7c3 Refactor all argument parsing into InvocationOptions.cpp.
Signed-off-by: Vassil Vassilev <vvasilev@cern.ch>
2016-08-18 15:44:18 +02:00
Axel Naumann
762942581e Remove unused function IncrementalParser::Parse(). 2016-07-22 16:14:11 +02:00
Axel Naumann
97c5bafb2f Merge transaction unlinking into deregisterTransaction; pass nullptr if Transaction gets unloaded. 2016-06-26 10:29:17 +02:00
Axel Naumann
1ec7136eeb Refactor, centralize all TransactionUnloading in Interpreter. 2016-06-26 10:29:17 +02:00
CristinaCristescu
1cb874532b Correct DiagnoseIfInterpreterException in iterpreter. 2016-04-08 15:44:11 +02:00
CristinaCristescu
1472015449 Create function member of IncrementalParser for setting the transformers.
The transformers have to be set later in the initialization for 2 reasons:
- to avoid the null deref check before the check pointer function is declared
in the RuntimeUniverse;
- to avoid useless checks.
2016-04-08 15:44:11 +02:00
Elisavet Sakellari
8f51dd1617 Remove default values in IncrementalParser functions 2016-01-14 20:44:14 +01:00
Elisavet Sakellari
ee92892ad4 First commit for the Multiple Interpreters 2016-01-14 20:44:14 +01:00
Axel Naumann
3136974871 Fix doxygen warnings. 2015-03-20 15:45:03 +01:00
Axel Naumann
8497d89e4a Spell !.size() as .empty(). 2015-03-20 12:43:51 +01:00
Axel Naumann
fa573cf5de Inform commitTransaction() about the ParseResult. 2015-03-18 15:15:01 +01:00
Axel Naumann
fc9b3aa997 Separate Transaction* and parser success: a nullptr Transaction* was ambiguous. 2015-03-16 14:58:58 +01:00
Axel Naumann
260f8d4f2a Now that parsing also emits, non-parsed Decls need to be emitted "by hand". 2015-03-16 14:58:58 +01:00
Axel Naumann
166032069e Emit Decls as DeclCollector sees them.
Now that we can easily revert Transactions' IR (by unloading their
module) we do not need to queue the Decls before emitting them.
This enables EndOfTU actions to be emitted seeminglessly, without
extra transactions, or explicit post-EndOfTU-emission: each
Transaction will have its TU finalized exactly once.

This in turn allows us to turn on Debug emission - which relies on
being invoked exactly once per Module.

Transformers must be invoked before emitting Decls. They are now
invoked for each Decl; WrapperTransformers are invoked when seeing
a wrapper decl. They do not see the "full transaction AST" anymore
- luckily none of our transformers requires this and actually become
simpler because of this change.

This also fixes a bug where the relative sequencing of parsed and
deserialized Decls was lost (parsed was emitted before deserialized).

Remove unused IRTransactions; they should really be llvm::Pass-es.
We don't have them anyway.

Disable a few transformations if the Decl isFromASTFile.

When reverting a Transaction, also revert its nested ones.

In the ValueExtractionSynthesizer, pass the ValuePrinter option as
int, instead of the transaction pointer - that might have changed
(at least its options) by the time we invoke the wrapper.

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# Explicit paths specified without -i or -o; assuming --only paths...
# rebase in progress; onto b3d9f92
# You are currently splitting a commit while rebasing branch 'declcollector-emits-v2' on 'b3d9f92'.
#
# Changes to be committed:
#	modified:   interpreter/cling/include/cling/Interpreter/RuntimeUniverse.h
#	modified:   interpreter/cling/lib/Interpreter/AutoSynthesizer.cpp
#	modified:   interpreter/cling/lib/Interpreter/AutoSynthesizer.h
#	modified:   interpreter/cling/lib/Interpreter/CheckEmptyTransactionTransformer.cpp
#	modified:   interpreter/cling/lib/Interpreter/CheckEmptyTransactionTransformer.h
#	modified:   interpreter/cling/lib/Interpreter/DeclCollector.cpp
#	modified:   interpreter/cling/lib/Interpreter/DeclCollector.h
#	modified:   interpreter/cling/lib/Interpreter/DeclExtractor.cpp
#	modified:   interpreter/cling/lib/Interpreter/DeclExtractor.h
#	modified:   interpreter/cling/lib/Interpreter/DynamicLookup.cpp
#	modified:   interpreter/cling/lib/Interpreter/DynamicLookup.h
#	modified:   interpreter/cling/lib/Interpreter/IncrementalParser.cpp
#	modified:   interpreter/cling/lib/Interpreter/IncrementalParser.h
#	modified:   interpreter/cling/lib/Interpreter/NullDerefProtectionTransformer.cpp
#	modified:   interpreter/cling/lib/Interpreter/NullDerefProtectionTransformer.h
#	modified:   interpreter/cling/lib/Interpreter/TransactionTransformer.cpp
#	modified:   interpreter/cling/lib/Interpreter/TransactionTransformer.h
#	modified:   interpreter/cling/lib/Interpreter/TransactionUnloader.cpp
#	modified:   interpreter/cling/lib/Interpreter/ValueExtractionSynthesizer.cpp
#	modified:   interpreter/cling/lib/Interpreter/ValueExtractionSynthesizer.h
#	modified:   interpreter/cling/lib/Interpreter/ValuePrinterSynthesizer.cpp
#	modified:   interpreter/cling/lib/Interpreter/ValuePrinterSynthesizer.h
#
# Untracked files:
#	.idea/
#	0001-Fix-llvm-merge-issue.patch
#	0002-Fix-warnings.patch
#	0003-Keep-weak-symbols-around-subsequent-transactions-mig.patch
#	T.cxx
#	T.cxx~
#	TMVA.root
#	a.out
#	boost.root
#	config/Makefile.depend~
#	core/textinput/src/textinput/TerminalDisplayWin.cpp.orig
#	ct.root
#	data.root
#	interpreter/cling/76fc2055249da7b03148a7d4197a279e9943f012.patch
#	interpreter/cling/lib/Interpreter/CIFactory.cpp~
#	interpreter/cling/lib/Interpreter/DeclCollector.h~
#	interpreter/cling/lib/Interpreter/DynamicLibraryManager.cpp~
#	modulemap-one-header-per-file.txt
#	osrm-routed
#	tiles.tar.bz2
#	tmva_class_example.root
#	tutorials/v3.root
#	weights/
#
2015-03-16 14:58:58 +01:00
Axel Naumann
39e505288b Improve and re-use existing addTransaction(). 2015-02-18 14:51:21 +01:00
Axel Naumann
4bc5c13beb Add backend passes back in. Fixes (some of) MacOS.
Once clang BackendUtils become more relevant for our use case
we should switch to that, instead of simulating its behavior.
2015-02-11 22:05:21 +01:00
Axel Naumann
eb75ab36ef Add the transaction to define its lifetime.
This should be migrated to use unique_ptr in the interfaces instead
of relying on comments...
2015-02-11 10:57:48 +01:00
Axel Naumann
baf51f6b04 Create a new llvm::Module per codegen'ed transaction.
MCJIT needs to finalize modules. To simplify the interface with MCJIT, each
transaction now has its own module. It gets created when the previous module
gets passed to the execution engine; the first one is created by
clang::CreateLLVMCodeGen(). CodeGen now releases the module such that it can be
added to the execution engine.

This enables simple use cases of cling with MCJIT; most notably cross-module
linking is still missing.
2015-02-11 10:57:34 +01:00
Axel Naumann
899a5dde32 Use the end of the latest memory buffer as Diag pop point.
We might have a memory buffer taht causes the creation of other memory
buffers - which hang from our parent memory buffer, and get parsed before
we pop the diagnostics. The pop location must thus not be the end of our
memory buffer - because those later memory buffers might have created
later DiagStorePoints. Simply use the end location of the last memory
buffer - there cannot be any later Diag pop than that within our call.
2015-01-23 16:24:14 +01:00
Vassil Vassilev
22f891e9be llvm::OwningPtr to std::unique_ptr. 2014-08-14 14:56:38 +02:00
Philippe Canal
576ca3ca96 Remove trailing spaces 2014-08-13 16:08:36 +02:00
Axel Naumann
af66248191 Accessor to current transaction, useful e.g. for callbacks. 2014-05-14 15:32:58 +02:00
Vassil Vassilev
ffc9fe50b5 Disable useless warnings only for the wrapper functions.
We simulate programatically:
void __cling_Unique {
  #pragma push
  #pragma ... ignore ...
  {code}
  #pragma pop
}
2014-04-01 17:09:58 +02:00
Vassil Vassilev
4d5e607256 Merge unloadTransaction and rollbackTransaction. 2014-03-24 14:25:58 +01:00
Axel Naumann
5045248a76 Dealy running static init until gCling is defined; local_cxa_atexit() needs it. 2014-03-04 19:55:00 +01:00
Axel Naumann
6325e7ed19 Keep trying to remap __cxa_atexit until succeeded.
__cxa_atexit is generated by clang::CodeGen upon seeing the first static
destructor. Instead of trying to provoke that we just continue to search for it.
2014-03-04 19:55:00 +01:00
Axel Naumann
baca204185 Simplify cxa_atexit(), first part.
Remove trigger__cxa_atexit(), we will just remap until successful.
Remove unused dso parameter.
Instead of friending just provide a function.
Pass a transaction, the typesafe way.
2014-03-04 19:54:59 +01:00
Vassil Vassilev
1bf7c49086 Move unloading of N transactions outside IncrementalParser 2014-02-27 12:49:11 +01:00
Axel Naumann
44481ace1e Fix license; remove $Id$ version. 2014-01-07 11:14:04 +01:00
Vassil Vassilev
91c54bda2e Add more handy interface that takes a number of transactions to be rolled back. 2013-10-29 20:19:25 +01:00