summaryrefslogtreecommitdiffstats
path: root/clang/lib/Serialization
Commit message (Collapse)AuthorAgeFilesLines
...
* [OPENMP] Fixed support for 'schedule' clause with non-constant chunk size.Alexey Bataev2015-05-122-0/+2
| | | | | | 'schedule' clause for combined directives requires additional processing. Special helper variable is generated, that is captured in the outlined parallel region for 'parallel for' region. This captured variable is used to store chunk expression from the 'schedule' clause in this 'parallel for' region. llvm-svn: 237100
* [modules] Don't bother registering loaded macros if there are none.Richard Smith2015-05-041-1/+2
| | | | | | We don't yet have a reduced testcase for this. llvm-svn: 236454
* Rename MacroDefinition -> MacroDefinitionRecord, ↵Richard Smith2015-05-042-15/+15
| | | | | | | | | | Preprocessor::MacroDefinition -> MacroDefinition. clang::MacroDefinition now models the currently-defined value of a macro. The previous MacroDefinition type, which represented a record of a macro definition directive for a detailed preprocessing record, is now called MacroDefinitionRecord. llvm-svn: 236400
* [modules] Remove dead code from Module for tracking macro import locations.Richard Smith2015-05-022-8/+2
| | | | llvm-svn: 236376
* [modules] If a module #includes a modular header that #undef's its macro, itRichard Smith2015-05-021-1/+1
| | | | | | | | should not export the macro. ... at least, not unless we have local submodule visibility enabled. llvm-svn: 236369
* [modules] Add -fmodules-local-submodule-visibility flag.Richard Smith2015-05-011-28/+17
| | | | | | | | | | | | | | | This flag specifies that the normal visibility rules should be used even for local submodules (submodules of the currently-being-built module). Thus names will only be visible if a header / module that declares them has actually been included / imported, and not merely because a submodule that happened to be built earlier declared those names. This also removes the need to modularize bottom-up: textually-included headers will be included into every submodule that includes them, since their include guards will not leak between modules. So far, this only governs visibility of macros, not of declarations, so is not ready for real use yet. llvm-svn: 236350
* Fix a few line endings. NFC.Yunzhong Gao2015-05-012-19/+19
| | | | llvm-svn: 236301
* [modules] Start moving the module visibility information off the Module itself.Richard Smith2015-05-012-35/+7
| | | | | | | It has no place there; it's not a property of the Module, and it makes restoring the visibility set when we leave a submodule more difficult. llvm-svn: 236300
* Remove dead code: a MacroDirective can't be imported or ambiguous any more.Richard Smith2015-04-302-26/+3
| | | | llvm-svn: 236197
* [modules] Stop trying to fake up a linear MacroDirective history.Richard Smith2015-04-293-196/+7
| | | | | | | | | | | | | | Modules builds fundamentally have a non-linear macro history. In the interest of better source fidelity, represent the macro definition information faithfully: we have a linear macro directive history within each module, and at any point we have a unique "latest" local macro directive and a collection of visible imported directives. This also removes the attendent complexity of attempting to create a correct MacroDirective history (which we got wrong in the general case). No functionality change intended. llvm-svn: 236176
* [modules] Refactor creation of ModuleMacros and create them when importing ↵Richard Smith2015-04-231-7/+6
| | | | | | from local submodules. llvm-svn: 235669
* [modules] Remove the now-redundant import of all pending macros at the end ↵Richard Smith2015-04-231-27/+8
| | | | | | | | | of building a module. Since we now track module macros separately from their visibility state, this is no longer necessary. llvm-svn: 235648
* [modules] Store a ModuleMacro* on an imported macro directive rather than ↵Richard Smith2015-04-232-71/+46
| | | | | | duplicating the info within it. llvm-svn: 235644
* [modules] Determine the set of macros exported by a submodule at the end of ↵Richard Smith2015-04-232-111/+28
| | | | | | | | | | | that submodule. Previously we'd defer this determination until writing the AST, which doesn't allow us to use this information when building other submodules of the same module. This change also allows us to use a uniform mechanism for writing module macro records, independent of whether they are local or imported. llvm-svn: 235614
* Silencing a -Wunused-variable warning; NFC.Aaron Ballman2015-04-221-2/+1
| | | | llvm-svn: 235512
* [modules] Cope with partial module macro information, fix memory leak found ↵Richard Smith2015-04-221-6/+4
| | | | | | by buildbot. llvm-svn: 235464
* [modules] Build a DAG of module macros for each identifier.Richard Smith2015-04-221-28/+36
| | | | | | | | This graph will be used to determine the current set of active macros. This is foundation work for getting macro visibility correct across submodules of the current module. No functionality change for now. llvm-svn: 235461
* [modules] Move list of exported module macros from IdentifierInfo lookup ↵Richard Smith2015-04-212-398/+216
| | | | | | | | | table to separate storage, adjacent to the macro directive history. This is substantially simpler, provides better space usage accounting in bcanalyzer, and gives a more compact representation. No functionality change intended. llvm-svn: 235420
* Try to work around failure to convert this lambda to a function pointer in ↵Richard Smith2015-04-191-4/+5
| | | | | | some versions of GCC. llvm-svn: 235264
* [modules] Refactor macro emission. No functionality change.Richard Smith2015-04-191-76/+73
| | | | llvm-svn: 235263
* Revert file unintentionally changed in r235162.Daniel Jasper2015-04-171-1/+1
| | | | llvm-svn: 235163
* clang-format: Add default fallback style.Daniel Jasper2015-04-171-1/+1
| | | | | | Thanks to Michael Schlottke. llvm-svn: 235162
* [OPENMP] Codegen for 'copyin' clause in 'parallel' directive.Alexey Bataev2015-04-162-4/+22
| | | | | | | | | | | | | | | Emits the following code for the clause at the beginning of the outlined function for implicit threads: if (<not a master thread>) { ... <thread local copy of var> = <master thread local copy of var>; ... } <sync point>; Checking for a non-master thread is performed by comparing of the address of the thread local variable with the address of the master's variable. Master thread always uses original variables, so you always know the address of the variable in the master thread. Differential Revision: http://reviews.llvm.org/D9026 llvm-svn: 235075
* [OPENMP] Codegen for 'lastprivate' clause in 'for' directive.Alexey Bataev2015-04-162-0/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | #pragma omp for lastprivate(<var>) for (i = a; i < b; ++b) <BODY>; This construct is translated into something like: <last_iter> = alloca i32 <lastprivate_var> = alloca <type> <last_iter> = 0 ; No initializer for simple variables or a default constructor is called for objects. ; For arrays perform element by element initialization by the call of the default constructor. ... OMP_FOR_START(...,<last_iter>, ..); sets <last_iter> to 1 if this is the last iteration. <BODY> ... OMP_FOR_END if (<last_iter> != 0) { <var> = <lastprivate_var> ; Update original variable with the lastprivate value. } call __kmpc_cancel_barrier() ; an implicit barrier to avoid possible data race. Differential Revision: http://reviews.llvm.org/D8658 llvm-svn: 235074
* Workaround a performance issue with modules + PCHBen Langmuir2015-04-101-1/+4
| | | | | | | | | | | | More fallout from r228234; when looking up an identifier in a PCH that imports the Cocoa module on Darwin, it was taking 2 to 5 seconds because we were hammering the MapVector::erase() function, which is O(n). For now, just clear() the contained SmallVector to get back to 0.25 - 0.5 seconds. This is probably not the long-term fix, because without modules or without PCH the performance is more like 0.02 seconds. llvm-svn: 234655
* [OPENMP] Codegen for 'reduction' clause in 'parallel' directive.Alexey Bataev2015-04-102-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Emit a code for reduction clause. Next code should be emitted for reductions: static kmp_critical_name lock = { 0 }; void reduce_func(void *lhs[<n>], void *rhs[<n>]) { ... *(Type<i> *)lhs[i] = RedOp<i>(*(Type<i> *)lhs[i], *(Type<i> *)rhs[i]); ... } ... void *RedList[<n>] = {&<RHSExprs>[0], ..., &<RHSExprs>[<n> - 1]}; switch (__kmpc_reduce{_nowait}(<loc>, <gtid>, <n>, sizeof(RedList), RedList, reduce_func, &<lock>)) { case 1: ... <LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i]); ... __kmpc_end_reduce{_nowait}(<loc>, <gtid>, &<lock>); break; case 2: ... Atomic(<LHSExprs>[i] = RedOp<i>(*<LHSExprs>[i], *<RHSExprs>[i])); ... break; default: ; } Reduction variables are a kind of a private variables, they have private copies, but initial values are chosen in accordance with the reduction operation. Differential Revision: http://reviews.llvm.org/D8915 llvm-svn: 234583
* [modules] Remove unused MACRO_TABLE record.Richard Smith2015-04-102-41/+2
| | | | llvm-svn: 234555
* [OPENMP] Sema analysis for 'atomic capture' construct.Alexey Bataev2015-04-012-0/+2
| | | | | | Added sema checks for forms of expressions/statements allowed under control of 'atomic capture' directive + generation of helper objects for future codegen. llvm-svn: 233785
* [OPENMP] Codegen for 'atomic update' construct.Alexey Bataev2015-03-302-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds atomic update codegen for the following forms of expressions: x binop= expr; x++; ++x; x--; --x; x = x binop expr; x = expr binop x; If x and expr are integer and binop is associative or x is a LHS in a RHS of the assignment expression, and atomics are allowed for type of x on the target platform atomicrmw instruction is emitted. Otherwise compare-and-swap sequence is emitted: bb: ... atomic load <x> cont: <expected> = phi [ <x>, label %bb ], [ <new_failed>, %cont ] <desired> = <expected> binop <expr> <res> = cmpxchg atomic &<x>, desired, expected <new_failed> = <res>.field1; br <res>field2, label %exit, label %cont exit: ... Differential Revision: http://reviews.llvm.org/D8536 llvm-svn: 233513
* [Modules] Work around PR23030 again, in a different code path, whereChandler Carruth2015-03-271-6/+9
| | | | | | | | | | I again added the "reasonable" assertions and they again fired during a modules self-host. This hopefully will un-break the self-host build bot. No test case handy and adding one seems to have little or no value really. llvm-svn: 233426
* [modules] When merging class definitions, make the retained definition visibleRichard Smith2015-03-272-25/+31
| | | | | | | | if the merged definition is visible, and perform lookups into all merged copies of the definition (not just for special members) so that we can complete the redecl chains for members of the class. llvm-svn: 233420
* [Modules] When walking the lookup results in a namespace, sort them byChandler Carruth2015-03-271-9/+23
| | | | | | | | | | | | declaration name so that we mark declarations for emission in a deterministic order (and in turn give them deterministic IDs). This is the last for loop or data structure I can find by inspection of the AST writer which doesn't use a deterministic order. Found by inspection, no test case. llvm-svn: 233348
* [modules] Handle defining a tag with a typedef name for linkage purposes on ↵Richard Smith2015-03-271-6/+5
| | | | | | top of an existing imported-but-not-visible definition. llvm-svn: 233345
* [Modules] Make Sema's map of referenced selectors have a deterministicChandler Carruth2015-03-271-5/+3
| | | | | | | | | | | order based on order of insertion. This should cause both our warnings about these and the modules serialization to be deterministic as a consequence. Found by inspection. llvm-svn: 233343
* [Modules] Make our on-disk hash table of selector IDs be built inChandler Carruth2015-03-271-6/+5
| | | | | | | | | | a deterministic order. This uses a MapVector to track the insertion order of selectors. Found by inspection. llvm-svn: 233342
* [Modules] Sort the file IDs prior to building the flattened array ofChandler Carruth2015-03-271-10/+13
| | | | | | | | | | | DeclIDs so that in addition to be grouped by file, the order of these groups is stable. Found by inspection, no test case. Not sure this can be observed without a randomized seed for the hash table, but we shouldn't be relying on the hash table layout under any circumstances. llvm-svn: 233339
* [Modules] Make the AST serialization always use lexicographic order whenChandler Carruth2015-03-261-4/+12
| | | | | | | | | | | | | | | | traversing the identifier table. No easy test case as this table is somewhere between hard and impossible to observe as non-deterministically ordered. The table is a hash table but we hash the string contents and never remove entries from the table so the growth pattern, etc, is all completely fixed. However, relying on the hash function being deterministic is specifically against the long-term direction of LLVM's hashing datastructures, which are intended to provide *no* ordering guarantees. As such, this defends against these things by sorting the identifiers. Sorting identifiers right before we emit them to a serialized form seems a low cost for predictability here. llvm-svn: 233332
* [Modules] Delete stale, pointless code. All tests still pass with thisChandler Carruth2015-03-261-15/+0
| | | | | | | | | | | logic removed. This logic was both inserting all builtins into the identifier table and ensuring they would get serialized. The first happens unconditionally now, and we always write out the entire identifier table. This code can simply go away. llvm-svn: 233331
* [Modules] Fix a sneaky bug in r233249 where we would look for implicitChandler Carruth2015-03-261-25/+39
| | | | | | | | | | | | | | | | | constructors in the current lexical context even though name lookup found them via some other context merged into the redecl chain. This can only happen for implicit constructors which can only have the name of the type of the current context, so we can fix this by simply *always* merging those names first. This also has the advantage of removing the walk of the current lexical context from the common case when this is the only constructor name we need to deal with (implicit or otherwise). I've enhanced the tests to cover this case (and uncovered an unrelated bug which I fixed in r233325). llvm-svn: 233327
* [Modules] Fix tiny bug where we failed to get the canonical decl whenChandler Carruth2015-03-261-1/+1
| | | | | | | | | | | | | | | deserializing an inherited constructor. This is the exact same logic we use when deserializing method overrides for the same reason: the canonical decl may end up pinned to a different decl when we are improting modules, we need to re-pin to the canonical one during reading. My test case for this will come in a subsequent commit. I was trying to test a more tricky bug fix and the test case happened to tickle this bug as well. llvm-svn: 233325
* [Modules] Preserve source order for the map of late parsed templates.Chandler Carruth2015-03-262-7/+6
| | | | | | | | | | | | | | | | | | | | Clang was inserting these into a dense map. While it never iterated the dense map during normal compilation, it did when emitting a module. Fix this by using a standard MapVector to preserve the order in which we encounter the late parsed templates. I suspect this still isn't ideal, as we don't seem to remove things from this map even when we mark the templates as no longer late parsed. But I don't know enough about this particular extension to craft a nice, subtle test case covering this. I've managed to get the stress test to at least do some late parsing and demonstrate the core problem here. This patch fixes the test and provides deterministic behavior which is a strict improvement over the prior state. I've cleaned up some of the code here as well to be explicit about inserting when that is what is actually going on. llvm-svn: 233264
* [Modules] Make "#pragma weak" undeclared identifiers be trackedChandler Carruth2015-03-261-9/+7
| | | | | | | | | | | | | | | | deterministically. This fixes a latent issue where even Clang's Sema (and diagnostics) were non-deterministic in the face of this pragma. The fix is super simple -- just use a MapVector so we track the order in which these are parsed (or imported). Especially considering how rare they are, this seems like the perfect tradeoff. I've also simplified the client code with judicious use of auto and range based for loops. I've added some pretty hilarious code to my stress test which now survives the binary diff without issue. llvm-svn: 233261
* [Modules] Delete a bunch of complex code for ensuring visible decls inChandler Carruth2015-03-262-64/+4
| | | | | | | | | | | | | | updated decl contexts get emitted. Since this code was added, we have newer vastly simpler code for handling this. The code I'm removing was very expensive and also generated unstable order of declarations which made module outputs non-deterministic. All of the tests continue to pass for me and I'm able to check the difference between the .pcm files after merging modules together. llvm-svn: 233251
* [modules] If we reach a definition of a class for which we already have aRichard Smith2015-03-263-1/+29
| | | | | | | | non-visible definition, skip the new definition and make the old one visible instead of trying to parse it again and failing horribly. C++'s ODR allows us to assume that the two definitions are identical. llvm-svn: 233250
* [Modules] A second attempt at writing out on-disk hash tables for theChandler Carruth2015-03-261-56/+157
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | decl context lookup tables. The first attepmt at this caused problems. We had significantly more sources of non-determinism that I realized at first, and my change essentially turned them from non-deterministic output into use-after-free. Except that they weren't necessarily caught by tools because the data wasn't really freed. The new approach is much simpler. The first big simplification is to inline the "visit" code and handle this directly. That works much better, and I'll try to go and clean up the other caller of the visit logic similarly. The second key to the entire approach is that we need to *only* collect names into a stable order at first. We then need to issue all of the actual 'lookup()' calls in the stable order of the names so that we load external results in a stable order. Once we have loaded all the results, the table of results will stop being invalidated and we can walk all of the names again and use the cheap 'noload_lookup()' method to quickly get the results and serialize them. To handle constructors and conversion functions (whose names can't be stably ordered) in this approach, what we do is record only the visible constructor and conversion function names at first. Then, if we have any, we walk the decls of the class and add those names in the order they occur in the AST. The rest falls out naturally. This actually ends up simpler than the previous approach and seems much more robust. It uncovered a latent issue where we were building on-disk hash tables for lookup results when the context was a linkage spec! This happened to dodge all of the assert by some miracle. Instead, add a proper predicate to the DeclContext class and use that which tests both for function contexts and linkage specs. It also uncovered PR23030 where we are forming somewhat bizarre negative lookup results. I've just worked around this with a FIXME in place because fixing this particular Clang bug seems quite hard. I've flipped the first part of the test case I added for stability back on in this commit. I'm taking it gradually to try and make sure the build bots are happy this time. llvm-svn: 233249
* Keep track of canonical decls in Redeclarable.Manuel Klimek2015-03-251-0/+4
| | | | | | | | More than 2x speedup on modules builds with large redecl chains. Roughly 15-20% speedup on non-modules builds for very large TUs. Between 2-3% cost in memory on large TUs. llvm-svn: 233228
* Revert "[Modules] When writing out the on-disk hash table for the decl ↵Rafael Espindola2015-03-251-90/+15
| | | | | | | | context lookup tables, we need to establish a stable ordering for constructing the hash table. This is trickier than it might seem." This reverts commit r233156. It broke the bots. llvm-svn: 233172
* [Modules] When writing out the on-disk hash table for the decl contextChandler Carruth2015-03-251-15/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | lookup tables, we need to establish a stable ordering for constructing the hash table. This is trickier than it might seem. Most of these cases are easily handled by sorting the lookup results associated with a specific name that has an identifier. However for constructors and conversion functions, the story is more complicated. Here we need to merge all of the constructors or conversion functions together and this merge needs to be stable. We don't have any stable ordering for either constructors or conversion functions as both would require a stable ordering across types. Instead, when we have constructors or conversion functions in the results, we reconstruct a stable order by walking the decl context in lexical order and merging them in the order their particular declaration names are encountered. This doesn't generalize as there might be found declaration names which don't actually occur within the lexical context, but for constructors and conversion functions it is safe. It does require loading the entire decl context if necessary to establish the ordering but there doesn't seem to be a meaningful way around that. Many thanks to Richard for talking through all of the design choices here. While I wrote the code, he guided all the actual decisions about how to establish the order of things. No test case yet because the test case I have doesn't pass yet -- there are still more sources of non-determinism. However, this is complex enough that I wanted it to go into its own commit in case it causes some unforseen issue or needs to be reverted. llvm-svn: 233156
* [Modules] Start making explicit modules produce deterministic output.Chandler Carruth2015-03-241-13/+16
| | | | | | | | | | | | | | | | | | | | | There are two aspects of non-determinism fixed here, which was the minimum required to cause at least an empty module to be deterministic. First, the random number signature is only inserted into the module when we are building modules implicitly. The use case for these random signatures is to work around the very fact that modules are not deterministic in their output when working with the implicitly built and populated module cache. Eventually this should go away entirely when we're confident that Clang is producing deterministic output. Second, the on-disk hash table is populated based on the order of iteration over a DenseMap. Instead, use a MapVector so that we can walk it in insertion order. I've added a test that an empty module, when built twice, produces the same binary PCM file. llvm-svn: 233115
* Track the source location of the dot or arrow operator in a MemberExpr.Aaron Ballman2015-03-242-17/+19
| | | | | | Patch by Joe Ranieri! llvm-svn: 233085
OpenPOWER on IntegriCloud