summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenPGO.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* InstrProf: Run clang-format to fix some strange indentation (NFC)Justin Bogner2015-02-231-424/+421
| | | | | | | | Somehow this file ended up with a strange hybrid of the old "indent inside a namespace" style and the new "don't", giving us a wonderful two-space indent starting halfway through a namespace. Fix it. llvm-svn: 230244
* InstrProf: Avoid creating profile names for symbols in system headersJustin Bogner2015-01-221-2/+1
| | | | | | | | | | We don't emit any coverage mapping for uncovered functions that come from system headers, but we were creating a GlobalVariable with each of their names. This is wasteful since the linker will need to dead strip the unused symbols, and it can lead to issues when merging coverage with others TUs that do have coverage for those functions. llvm-svn: 226764
* InstrProf: Don't emit counter increments in dead codeJustin Bogner2015-01-091-0/+2
| | | | | | | | | We were previously emitting counter increments even if we didn't have an insertion point, which would result in a CallInst with no parent. This leads to a crash, as in pr22166, if we try to do GlobalDCE. llvm-svn: 225495
* InstrProf: Use LLVM's -instrprof pass for profilingJustin Bogner2014-12-081-241/+45
| | | | | | | | The logic for lowering profiling counters has been moved to an LLVM pass. Emit the intrinsics rather than duplicating the whole pass in clang. llvm-svn: 223683
* InstrProf: Use the same names for variables as we use in the profileJustin Bogner2014-12-021-14/+11
| | | | | | | | There's no need to use different names for the local variables than we use in the profile itself, and it's a bit simpler and easier to debug if we're consistent. llvm-svn: 223173
* InstrProf: Remove some pointless indirection (NFC)Justin Bogner2014-12-021-10/+10
| | | | | | | | It doesn't make much sense to have std::unique_ptrs of std::string and std::vector. Avoid some useless indirection by using these types directly. llvm-svn: 223166
* Reapply "InstrProf: Update for the LLVM API change in r218879"Justin Bogner2014-10-021-2/+1
| | | | | | | | Reapplying now that r218887 is in. This reverts commit r218882, reapplying r218880. llvm-svn: 218888
* Revert "InstrProf: Update for the LLVM API change in r218879"Justin Bogner2014-10-021-1/+2
| | | | | | | | r218879 has been reverted for now, this needs to go to match. This reverts commit r218880. llvm-svn: 218882
* InstrProf: Update for the LLVM API change in r218879Justin Bogner2014-10-021-2/+1
| | | | llvm-svn: 218880
* Coverage Mapping: store function's hash in coverage function records.Alex Lorenz2014-08-211-2/+2
| | | | | | | | | | The profile data format was recently updated and the new indexing api requires the code coverage tool to know the function's hash as well as the function's name to get the execution counts for a function. Differential Revision: http://reviews.llvm.org/D4995 llvm-svn: 216208
* Revert r215365 - Coverage mapping: emit mapping for cxx constructors that ↵Alex Lorenz2014-08-111-6/+1
| | | | | | use microsoft's ABI llvm-svn: 215371
* Coverage mapping: emit mapping for cxx constructors that use microsoft's ABIAlex Lorenz2014-08-111-1/+6
| | | | llvm-svn: 215365
* Add a cc1 "dump-coverage-mapping" for testing coverage mapping.Alex Lorenz2014-08-081-1/+1
| | | | | | Differential Revision: http://reviews.llvm.org/D4799 llvm-svn: 215258
* Add coverage mapping generation.Alex Lorenz2014-08-041-39/+115
| | | | | | | | | | This patch adds the '-fcoverage-mapping' option which allows clang to generate the coverage mapping information that can be used to provide code coverage analysis using the execution counts obtained from the instrumentation based profiling (-fprofile-instr-generate). llvm-svn: 214752
* InstrProf: Update for LLVM API changeJustin Bogner2014-08-011-7/+9
| | | | | | | | | | | | We've added support for a multiple functions with the same name in LLVM's profile data, so the lookup returning the function hash it found doesn't make sense anymore. Update to pass in the hash we expect. This also adds a test that the version 1 format is still readable, since the new API is expected to handle that. llvm-svn: 214586
* CodeGen: Improve warnings about uninstrumented files when profilingJustin Bogner2014-06-261-5/+7
| | | | | | | | | Improve the warning when building with -fprofile-instr-use and a file appears not to have been profiled at all. This keys on whether a function is defined in the main file or not to avoid false negatives when one includes a header with functions that have been profiled. llvm-svn: 211760
* InstrProf: Set profile data to visibility hiddenDuncan P. N. Exon Smith2014-05-161-0/+9
| | | | | | | | | | | | | Shared objects are fairly broken for InstrProf right now -- a follow-up commit in compiler-rt will fix the rest of this. The main problem here is that at link time, profile data symbols in the shared object might get used instead of symbols from the main executable, creating invalid profile data sections. <rdar://problem/16918688> llvm-svn: 208939
* CodeGen: Avoid instrumenting implicit Decls more effectivelyJustin Bogner2014-04-251-2/+4
| | | | | | | | | | We don't assign counters for implicit Decls, but we were emitting code to increment the (non-existent) counters and adding empty counter lists in the output. This fixes the checks in assignRegionCounters and emitInstrumentationData to do the right thing, and adds an assert for the pathological case of emitting zero counters. llvm-svn: 207203
* CodeGen: Remove an unused includeJustin Bogner2014-04-181-1/+0
| | | | llvm-svn: 206667
* CodeGen: Use LLVM's InstrProfReader in -fprofile-instr-use=Justin Bogner2014-04-181-140/+12
| | | | | | | | | Update clang to use the InstrProfReader from LLVM to read instrumentation based profile data. This also switches us from the naive text format to the binary format, since that's what's implemented in the reader. llvm-svn: 206658
* [Cleanup] Remove a trailing whitespaceJustin Bogner2014-04-181-1/+1
| | | | llvm-svn: 206657
* InstrProf: Calculate a better function hashDuncan P. N. Exon Smith2014-04-161-7/+131
| | | | | | | | | | | | | | | | | | The function hash should change when control flow changes. This patch hashes the type of each AST node that affects counters, rather than just counting how many there are. These types are combined into a small enumerator that currently has 16 values. The new hash algorithm packs the enums for consecutively visited types into a `uint64_t`. In order to save space for new types, the types are assumed to be 6-bit values (instead of 4-bit). In order to minimize overhead for functions with little control flow, the `uint64_t` is used directly as a hash if it never fills up; if it does, it's passed through an MD5 context. <rdar://problem/16435801> llvm-svn: 206397
* CodeGen: Emit warnings for out of date profile data during PGOJustin Bogner2014-04-151-2/+8
| | | | | | | | | This adds a warning that triggers when profile data doesn't match for the source that's being compiled with -fprofile-instr-use=. This fires only once per translation unit, as warning on every mismatched function would be quite noisy. llvm-svn: 206322
* CodeGen: Remove a comment that isn't in the right placeJustin Bogner2014-04-151-4/+0
| | | | | | | This comment also appears elsewhere where it actually makes sense, and it's just confusing here. llvm-svn: 206321
* CodeGen: Handle CapturedStmt in instrumentation based profilingJustin Bogner2014-04-151-0/+14
| | | | | | | | CapturedStmt was being ignored by instrumentation based profiling, and its counters attributed to the containing function. Instead, we need to treat this as a top level entity, like we do with blocks. llvm-svn: 206231
* CodeGen: Fix handling of C++11 lambdas in profilingJustin Bogner2014-04-111-3/+9
| | | | | | | | | Until now we were generating duplicate counters for lambdas: one set in the function where the lambda was declared and another for the lambda itself. Instead, we should skip over the bodies of lambdas in their containing contexts. llvm-svn: 206081
* [PGO] Change MapRegionCounters to be a RecursiveASTVisitor.Bob Wilson2014-04-111-132/+75
| | | | | | | This avoids the overhead of specifying all the traversal code when using ConstStmtVisitor and makes it a lot easier to maintain this. llvm-svn: 206039
* CodeGen: Handle binary conditional operators in PGO instrumentationJustin Bogner2014-04-111-2/+4
| | | | | | | This treats binary conditional operators in the same way as ternary conditional operators for instrumentation based profiling. llvm-svn: 206021
* Switch from constexpr to const char *constDuncan P. N. Exon Smith2014-04-111-2/+2
| | | | | | Responding to Richard Smith's review of r205037. llvm-svn: 206008
* InstrProf: Rename Decl parameters from S to DDuncan P. N. Exon Smith2014-04-101-21/+21
| | | | | | | | No functionality change. <rdar://problem/16435801> llvm-svn: 206002
* InstrProf: Read unsigned numbers with strtoul and strtoullDuncan P. N. Exon Smith2014-04-101-6/+6
| | | | | | | | | | | | | | | | | | Fixes a bug where unsigned numbers are read using strtol and strtoll. I don't have a testcase because this bug is effectively unobservable right now. To expose the problem in the hash, we would need a function with greater than INT64_MAX counters, which we don't handle anyway. To expose the problem in the function count, we'd need a function with greater than INT32_MAX counters; this is theoretically observable, but it isn't a practical testcase to check in. An upcoming commit changes the hash to be non-trivial, so we'll get some coverage eventually. <rdar://problem/16435801> llvm-svn: 206001
* CodeGen: Move PGO initialization into Release()Justin Bogner2014-04-101-3/+2
| | | | | | | | Emitting the PGO initialization in EmitGlobalFunctionDefinition is inefficient, since this only has an effect once per module. We move this to Release() with the rest of the once-per-module logic. llvm-svn: 205977
* CodeGen: Don't create branch weight metadata from empty profilesJustin Bogner2014-04-041-2/+6
| | | | | | | | | | | If all of our weights are zero when calculating branch weights, it means we haven't profiled the code in question. Avoid creating a metadata node that says all branches are equally likely in this case. The test also checks constructs that hit the other createBranchWeights overload. These were already working. llvm-svn: 205606
* Use constexpr again, this time portablyDuncan P. N. Exon Smith2014-03-281-2/+2
| | | | | | Responding to Justin's review of r205025. llvm-svn: 205037
* InstrProf: Fix MSVC after r205023Duncan P. N. Exon Smith2014-03-281-2/+2
| | | | llvm-svn: 205025
* InstrProf: Emit runtime hook directly in IRGenDuncan P. N. Exon Smith2014-03-281-1/+32
| | | | | | | | | | | | | | | | | | -u behaviour is apparently not portable between linkers (see cfe-commits discussions for r204379 and r205012). I've moved the logic to IRGen, where it should have been in the first place. I don't have a Linux system to test this on, so it's possible this logic *still* doesn't pull in the instrumented profiling runtime on Linux. I'm in the process of getting tests going on the compiler-rt side (llvm-commits "[PATCH] InstrProf: Add initial compiler-rt test"). Once we have tests for the full flow there, the runtime logic should get a whole lot less brittle. <rdar://problem/16458307> llvm-svn: 205023
* InstrProf: Use unique_ptrDuncan P. N. Exon Smith2014-03-261-15/+10
| | | | llvm-svn: 204846
* InstrProf: Use referencesDuncan P. N. Exon Smith2014-03-261-54/+52
| | | | llvm-svn: 204845
* PGO: Don't define instrumentation data available_externallyDuncan P. N. Exon Smith2014-03-201-0/+15
| | | | | | | | | | | | | | | Variables with available_externally linkage can be dropped at will. This causes link errors, since there are still references to the instrumentation! linkonce_odr is almost equivalent, so use that instead. As a drive-by fix (I don't have an Elf system, so I'm not sure how to write a testcase), use linkonce linkage for the instrumentation of extern_weak functions. <rdar://problem/15943240> llvm-svn: 204408
* PGO: Rename FuncLinkage to VarLinkage; no functionality changeDuncan P. N. Exon Smith2014-03-201-4/+4
| | | | | | | | | The variable is used to set the linkage for variables, and will become different from function linkage in a follow-up commit. <rdar://problem/15943240> llvm-svn: 204407
* PGO: Change runtime prefix from pgo to profileDuncan P. N. Exon Smith2014-03-201-8/+8
| | | | | | | | | | | These functions are in the profile runtime. PGO comes later. Unfortunately, there's only room for 16 characters in a Darwin section, so use __llvm_prf_ instead of __llvm_profile_ for section names. <rdar://problem/15943240> llvm-svn: 204390
* PGO: Remove explicit static initializationDuncan P. N. Exon Smith2014-03-201-16/+3
| | | | | | | | | | | | | | Remove the remaining explicit static initialization from translation units, at least on Darwin. Instead, create a use of __llvm_pgo_runtime, which will pull in required code from compiler-rt. After this commit (and its pair in compiler-rt), a user can define their own __llvm_pgo_runtime to satisfy this undefined symbol and call the functions in compiler-rt directly. <rdar://problem/15943240> llvm-svn: 204379
* Use nullptr; no functionality changeDuncan P. N. Exon Smith2014-03-201-7/+7
| | | | llvm-svn: 204372
* PGO: use linker magic to find instrumentation data on DarwinDuncan P. N. Exon Smith2014-03-201-3/+8
| | | | | | <rdar://problem/15943240> llvm-svn: 204301
* PGO: Separate out common isMachO logic; no functionality changeDuncan P. N. Exon Smith2014-03-201-12/+7
| | | | | | <rdar://problem/15943240> llvm-svn: 204297
* CodeGen: Include a function hash in instrumentation based profilingJustin Bogner2014-03-181-9/+23
| | | | | | | | | The hash itself is still the number of counters, which isn't all that useful, but this separates the API changes from the actual implementation of the hash and will make it easier to transition to the ProfileData library once it's implemented. llvm-svn: 204186
* PGO: Switch to isOSBinFormatMachO()Duncan P. N. Exon Smith2014-03-181-3/+3
| | | | llvm-svn: 204098
* PGO: Statically generate data structuresDuncan P. N. Exon Smith2014-03-171-84/+148
| | | | | | | | | | | | | | | | | | | In instrumentation-based profiling, we need a set of data structures to represent the counters. Previously, these were built up during static initialization. Now, they're shoved into a specially-named section so that they show up as an array. As a consequence of the reorganizing symbols, instrumentation data structures for linkonce functions are now correctly coalesced. This is the first step in a larger project to minimize runtime overhead and dependencies in instrumentation-based profilng. The larger picture includes removing all initialization overhead and making the dependency on libc optional. <rdar://problem/15943240> llvm-svn: 204080
* Revert "CodeGen: Use a binary format for instrumentation based profiling"Justin Bogner2014-03-121-35/+149
| | | | | | | | | I've clearly done something wrong with how to get this to link correctly. Reverting for now. This reverts commit r203711. llvm-svn: 203712
* CodeGen: Use a binary format for instrumentation based profilingJustin Bogner2014-03-121-149/+35
| | | | | | | | This updates CodeGenPGO to use the ProfileDataReader introduced to llvm in r203703 and the new API for writing out the profile introduced to compiler-rt in r203710. llvm-svn: 203711
OpenPOWER on IntegriCloud