Commit Graph

4307 Commits

Author SHA1 Message Date
Vassil Vassilev
fdca86db1d Set the SourceManager flag to enable -fmodules-embed-all-files.
This marks all files in the PCH/PCM transient. This allows clang to
stream them back within the zip in the PCH rather than requiring the
files to be physically present on disk.

This should resolve an introduced regression which materializes if
the files are moved/deleted after the generation of the PCH.
2017-11-30 14:52:08 +01:00
Bertrand Bellenot
92213e719a Switch object format from ELF to COFF and fix symbols lookup
- Switch object format from ELF (Linux) to COFF (Windows)
- Fix mangled symbols lookup on Windows: remove leading '_' and use malloc to simulate __imp_ variables (that are indirection pointers)
2017-11-29 22:30:07 +01:00
vagrant
54dbb830b3 Disable module file validation.
We need to disable the validation of PCM files because rootcling
serializes what it sees. For instance, we even serialize in the PCM
file some temporary lookup buffers and the contents of the module maps.

We disable the PCH validation but that is not sufficient for PCM. The
TCling code `fInterpreter->getCI()->getPreprocessorOpts().DisablePCHValidation = true`
is not enough because we rely more on the clang driver to setup correctly
our modules-aware interpreter.

This patch just uses the correct flag when setting up cling.

A proper fix to this issue is thoroughly described in RE-0003 (rootcling
refactor proposal).
2017-11-20 17:14:55 +01:00
Philippe Canal
8ca438b0d1 Address ROOT-9114 (Issues with dictionary's enum forward decl)
For now, do not decorate enums, this leads to some errors, likely
due to incorrect merging.  See https://sft.its.cern.ch/jira/browse/ROOT-9114

Note: that passing the set of forward declare and then actual declaration
to clang (both official and ROOT's custom version), there is no problem
seen.
2017-11-18 01:06:27 +01:00
Vassil Vassilev
c513776350 Fix typo, we want to suppress diag not enable it. 2017-11-14 04:13:43 +01:00
Vassil Vassilev
5abbe64ffd Work around an issue being resolved in PR1306. 2017-11-12 14:31:56 +01:00
Axel Naumann
315dfad70e Adapt to new default opt level.
As the default opt level decides which user-set opt levels cling will complain about, "control flow" changes were needed for the tests.
2017-11-07 19:44:33 +01:00
Axel Naumann
a9808afd40 Adapt to format changes in floating point value printing. 2017-11-07 19:44:33 +01:00
Raphael Isemann
c41a49dabb Multiplex the ExternalASTSource in cling
We need to respect the existing ExternalASTSource when setting up the
interpreter. Otherwise the ASTReader (which is the existing source)
doesn't receive the required callbacks to properly load C++ modules.

This patch now creates a multiplexer that contains our new
ASTSource and the existing one if it's necessary. We also
no longer attach the existing sema source which seemingly
was only a workaround that only works for the special case
were the external sema source and the external AST source
are the same object.
2017-11-07 05:39:07 +01:00
Raphael Isemann
62eac4d1d2 Fix formatting of the TLS commit 2017-11-07 03:57:48 +01:00
Raphael Isemann
89c6351e3a Fix thread local storage in the cling JIT
TLS is currently not suppored in the JIT on some platforms.

However, it's possible to enable emulated TLS support in LLVM
which means that we now support TLS across many architectures.
The performance downsides of this are the overhead of accessing
the variable due to the additional indirection by the emulation.

However, this overhead is minimal and shouldn't affect most
programs. It also can be easily worked around from the user side.
This can be donefFor example by wrapping TLS variables into a single
TLS struct variable that then contains the other variables. Or just
minimizing referencing the TLS variable and use a normal copy of
the variable instead and write it back later.

Patch created with a lot of help from Lang Hames and Pavel Labath!
2017-11-07 03:57:48 +01:00
Axel Naumann
3bf7bc1a48 Use %g instead of %f, to preserve precision. 2017-11-06 21:20:19 +01:00
Vassil Vassilev
c912c9437d Switch back to O0.
We have a suboptimal behavior in the way cling optimizes code in O2 mode.
Disable it until the issue is understood and fixed.
2017-11-03 16:19:32 +01:00
Axel Naumann
3256a1dc1f Spelling. 2017-11-02 20:14:18 +01:00
Vassil Vassilev
e488ba8466 Rely on Azog to allocate the memory in an exception-aware manner. 2017-11-02 17:59:25 +01:00
Vassil Vassilev
985b2c8740 LLVM 5.0 comes with special library lookup ordering options.
Force using the old behavior and explain why it is not so good idea.
2017-11-02 17:59:25 +01:00
Vassil Vassilev
d6fe62edaf Return 0 if we cannot find an address.
Add an llvm_unreachable to handle potential errors.
2017-11-02 17:59:25 +01:00
Vassil Vassilev
5f3494f950 Do not forget to return from the function.
This was probably due to non-proprely merged conflict.
2017-11-02 17:59:25 +01:00
Vassil Vassilev
3959f528b7 Bump the last known good llvm revision to point to release 5.0 2017-11-02 17:59:25 +01:00
Vassil Vassilev
dfc5cf657d The annotation token became a special one.
We can only consume it with calling a special interface or calling ConsumeAnyToken.
2017-11-02 17:59:25 +01:00
Vassil Vassilev
8bfa1b52c6 Make this code path unreachable.
If we cannot return an address we should assert and handle the diags.
2017-11-02 17:59:25 +01:00
Vassil Vassilev
88c3d07bb9 Follow recent LLVM changes.
The orc jit API evolved as follows:
  * Use better error handling via llvm::Error and llvm::Expected<>
  * Switch back to the single llvm::Module concept as opposed to sets.
  * Use more expressive ownership model: extensive use of smart ptrs.
2017-11-02 17:59:25 +01:00
Vassil Vassilev
6e1865dafb Do not prevent copy elision. 2017-11-02 17:59:24 +01:00
Vassil Vassilev
97f45536c3 Use the setter. 2017-11-02 17:59:24 +01:00
Vassil Vassilev
16c99f41f6 Follow recent changes in the OptTable.
LLVM 5.0 introduces a field to describe possible allowed option values. This
aids the auto completion machanisms.
2017-11-02 17:59:24 +01:00
Vassil Vassilev
1a35776759 file_magic went into its own header file. 2017-11-02 17:59:24 +01:00
Vassil Vassilev
628c1fbc86 BBVectorize flag was unused and went away in LLVM 5.0 2017-11-02 17:59:24 +01:00
Vassil Vassilev
8d0f2c4e1e Bump version to 0.6~dev. 2017-11-02 17:44:11 +01:00
Vassil Vassilev
0f1d6d24d4 Prepare for releasing cling v0.5. 2017-11-02 17:29:12 +01:00
Raphael Isemann
00a59858a5 Manually initialize the module manager before callbacks.
Initializing the module manager overwrites the external Sema/AST sources
with the ASTReader.

As we are using our own sources in cling, we should manually initalize
the module manager when we are in the module mode before we set our
own custom sources (which respect any existing sources like the ones
created by the module manager).
2017-11-02 10:10:48 +01:00
Raphael Isemann
016eaa7620 Prepone callback initialization in cling.
We should setup our callbacks for ExternalASTSource/ExternalSemaSource
before we parse *any* code to prevent that any part of the code
stores a reference to a non-cling external sources. If this happens,
then the clang data structures such redecl chain could go out of
sync if they reference different sources and produce errors like failing
to merge declarations correctly or creating invalid redecl chains.

To fix this, we move this initalization before the initalization of
the incremental parser which is the first part that can generate
any AST nodes. We only do this for the modules case because in
the non-modules case the clang PCH overwrites our callback
in the ExternalASTSource and therefore would destroy our external
source.
2017-11-02 10:10:48 +01:00
Raphael Isemann
d411ed7885 Enable interpreter callbacks again
We actually need those callbacks as they are responsible for
loading decls from unresolved identifiers, which then actually
triggers the loading of the specific header (or in our case
the specific C++ modules).

For now we need this as long as the modules are based on the
rootmap mechanism.
2017-11-02 10:10:48 +01:00
Raphael Isemann
a03e320a33 Revert "[cxxmodules] Prepone callback initialization in cling."
This reverts commit 62fc3e9eddc6c7e78c3becf60092143607cddf50.
2017-11-01 15:33:02 +01:00
Raphael Isemann
8165c1c800 Revert "[cxxmodules] Manually initialize the module manager before callbacks."
This reverts commit 6b3f5a1f04afff77089d39c905b29ce0a411d683.
2017-11-01 15:33:02 +01:00
Raphael Isemann
e20f8edbec Manually initialize the module manager before callbacks.
Initializing the module manager overwrites the external Sema/AST sources
with the ASTReader.

As we are using our own sources in cling, we should manually initalize
the module manager when we are in the module mode before we set our
own custom sources (which respect any existing sources like the ones
created by the module manager).
2017-11-01 15:33:02 +01:00
Raphael Isemann
1ebf53715c Prepone callback initialization in cling.
We should setup our callbacks for ExternalASTSource/ExternalSemaSource
before we parse *any* code to prevent that any part of the code
stores a reference to a non-cling external sources. If this happens,
then the clang data structures such redecl chain could go out of
sync if they reference different sources and produce errors like failing
to merge declarations correctly or creating invalid redecl chains.

To fix this, we move this initalization before the initalization of
the incremental parser which is the first part that can generate
any AST nodes.
2017-11-01 15:33:02 +01:00
Raphael Isemann
0f16f1ac15 Don't always generate a module in CIFactory
Right now we always start generating a module in the CIFactory
when modules are enabled. However, we should only do that when
we actually want to generate a module according to the COpts
(e.g. the user has given a module that we should generate).
2017-10-29 14:14:46 +01:00
Vassil Vassilev
8647fad06d Ask Sema if we enabled modules.
That fixes an issue when running hsimple.C with modules on.
2017-10-28 16:29:08 +02:00
Raphael Isemann
99d1df55ae Fix assert failure with duplicate decls.
When generating the GQt module in rootcling, we hit the assertions
in forceAppend assertions about "Duplicates?!" with this declaration:

```
CXXRecordDecl 0x55555643fae8 </usr/include/qt4/QtCore/qglobal.h:1658:1, line:1794:1> line:1658:21 in GQt.TGQt.h hidden class QSysInfo definition
|-also in GQt.TQtClientWidget.h
|-CXXRecordDecl 0x55555643fc30 <col:1, col:21> col:21 in GQt.TGQt.h hidden implicit class QSysInfo
|-AccessSpecDecl 0x55555643fce8 <line:1659:1, col:7> col:1 in GQt.TGQt.h public
|-EnumDecl 0x55555643fd18 <line:1660:5, line:1662:5> line:1660:10 in GQt.TGQt.h hidden Sizes
| `-EnumConstantDecl 0x55555643fe98 <line:1661:9, col:38> col:9 in GQt.TGQt.h hidden WordSize 'enum QSysInfo::Sizes'
|   `-ImplicitCastExpr 0x55555643fee0 <col:20, col:38> 'unsigned int' <IntegralCast>
|     `-ParenExpr 0x55555643fe70 <col:20, col:38> 'unsigned long'
|       `-BinaryOperator 0x55555643fe48 <col:21, col:37> 'unsigned long' '<<'
|         |-UnaryExprOrTypeTraitExpr 0x55555643fe08 <col:21, col:34> 'unsigned long' sizeof 'void *'
|         `-IntegerLiteral 0x55555643fe28 <col:37> 'int' 3
`-EnumDecl 0x55555643ff00 <line:1672:5, line:1685:5> line:1672:10 in GQt.TGQt.h hidden Endian
  |-EnumConstantDecl 0x55555643ffd8 <line:1673:9> col:9 in GQt.TGQt.h hidden referenced BigEndian 'enum QSysInfo::Endian'
  |-EnumConstantDecl 0x555556440028 <line:1674:9> col:9 in GQt.TGQt.h hidden referenced LittleEndian 'enum QSysInfo::Endian'
  `-EnumConstantDecl 0x5555564400a0 <line:1681:11, col:23> col:11 in GQt.TGQt.h hidden ByteOrder 'enum QSysInfo::Endian'
    `-ImplicitCastExpr 0x5555564400e8 <col:23> 'unsigned int' <IntegralCast>
      `-DeclRefExpr 0x555556440070 <col:23> 'int' EnumConstant 0x555556440028 'LittleEndian' 'enum QSysInfo::Endian'
```

The reason for this is that we have QSysInfo both in the TQtClientWidget
and TGQt submodules and our current translation (which is supposed to
parse all header in the module) sees them both in one transaction.

As we also don't recognize that this decl is from a module, the code
fires the assert even though duplictes are expected with modules.

The reason why we don't recognize it as a declaration form an ASTFile
which disables the assert is that FromASTFile for the decls is
not set. This is because they haven't been loaded by the ASTFileReader
but are directly parsed as submodules in our special case where we
directly parse a module content from rootcling to generate it.

We just workaround in this patch by checking that if the decl is from
the currently generated module, we are pretending it's as if it was
loaded from an AST file.
2017-10-27 10:52:41 +02:00
Danilo Piparo
f081e145e8 Revert "Revert 548eca7 to bring back optimisation level of interpreter to O0"
This reverts commit 79ed4963868c758757c25b7d93ef98fac0e34774.
The commit tried to bring back the optimisation level to O0 but 2 tests fail
if this is done:
- roottest-cling-specialobj-reread
- roottest-root-io-datamodelevolution-make
2017-10-19 21:14:24 +02:00
Danilo Piparo
fde4b32b7c Revert 548eca7 to bring back optimisation level of interpreter to O0
Revert https://github.com/root-project/root/commit/548eca7 bringing back
optimisation level to O0 given the very long time needed to JIT simple
pieces of code.
This takes tens of seconds versus a few seconds:

using namespace ROOT::Experimental;
int test() {
   // build a TDF with 1 event and 1 column "x" that is always equal 42
   TDataFrame dd(1);
   auto d = dd.Define("x", []() { return 42; });

   // book nHistos histograms
   // all with the same cut and filled with the same variable in this simple example
   std::vector<TDF::TResultProxy<TH1D>> histos;
   const auto nHistos = 1000u;
   histos.reserve(nHistos);
   for (auto i = 0u; i < nHistos; ++i)
      histos.emplace_back(d.Histo1D("x"));

   // run event loop, print something to be sure everything is ok
   std::cout << histos.front()->GetMean() << std::endl;
   return 0;
}
2017-10-19 19:28:42 +02:00
Bertrand Bellenot
f8d746464b Silent many warnings on Windows 2017-10-17 15:44:31 +02:00
Axel Naumann
b1e4381dd5 Use the result of find(). 2017-10-11 21:56:45 +02:00
Vassil Vassilev
2a4be7cd70 Simplify llvm::Module emission in the JIT.
This teaches again the IncrementalExecutor to emit only one module at a time.
In the old MCJIT days, the API worked with module sets and cling assumed llvm's
jit infrastructure is moving in this direction.

LLVM 5.0 moves away from this concept and works with single llvm::Modules. This
patch will make the upgrade to LLVM 5.0 smoother.
2017-10-10 18:32:58 +02:00
Vassil Vassilev
fca3ee5f64 Disable a little to restrictive assert.
We are not quite ready to control that precisely the ownership.
2017-10-05 22:31:07 +02:00
Bertrand Bellenot
6bfd18bbc4 formatting (clang-format) 2017-10-05 17:59:08 +02:00
Bertrand Bellenot
988e5b00f2 Fix the Visual Studio 2017 directory location (quick and dirty hack). To be reviewed
The Visual Studio 2017 path is very different than the previous versions, and even the registry entries are completely different, so for now let's try the trivial way first (using the %VCToolsInstallDir% environment variable)
2017-10-05 17:59:08 +02:00
Vassil Vassilev
dfc0e8a2d4 shared_ptr-ize the llvm::Module*.
This is in prepare for the upcoming llvm upgrade. The future orc jit compile
layer needs a std::shared_ptr<llvm::Module>. The current design passes a
llvm::Module* around and any conversions to a shared_ptr cause the
destruction of the llvm::Module which is a long-lived object in cling.
2017-10-05 17:59:08 +02:00
Vassil Vassilev
e409ca55bc Intent cling namespace content. 2017-10-05 17:59:08 +02:00
Raphael Isemann
b24a3f704c clang-formated ForwardDeclPrinter::prettyPrintAttributes 2017-10-02 11:27:19 +02:00