summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenPGO.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [PGO] Avoid instrumenting constants at value sitesBetul Buyukkurt2016-03-311-0/+3
| | | | | | | | | | Value profiling should not profile constants and/or constant expressions when they appear as callees in call instructions. Constant expressions form when a direct callee has bitcasts or inttoptr(ptrtint (callee)) nests surrounding it. Value profiling should avoid instrumenting such cases. Mostly NFC. llvm-svn: 265037
* [PGO] Move the instrumentation point closer to the value site.Betul Buyukkurt2016-03-291-3/+4
| | | | | | | | | For terminator instructions, the value profiling instrumentation happens in a basic block other than where the value site resides. This CR moves the instrumentation point prior to the value site. Mostly NFC. llvm-svn: 264783
* P0184R0: Allow types of 'begin' and 'end' expressions in range-based for ↵Richard Smith2016-03-201-1/+2
| | | | | | loops to differ. llvm-svn: 263895
* [PGO] code simplification: use existing VP annotation API /NFCXinliang David Li2016-02-041-27/+3
| | | | llvm-svn: 259819
* [PGO] cc1 option name change for profile instrumentationRong Xu2016-02-041-4/+4
| | | | | | | | | | | | This patch changes cc1 option -fprofile-instr-generate to an enum option -fprofile-instrument={clang|none}. It also changes cc1 options -fprofile-instr-generate= to -fprofile-instrument-path=. The driver level option -fprofile-instr-generate and -fprofile-instr-generate= remain intact. This change will pave the way to integrate new PGO instrumentation in IR level. Review: http://reviews.llvm.org/D16730 llvm-svn: 259811
* Clang changes for value profilingBetul Buyukkurt2016-01-231-4/+81
| | | | | | Differential Revision: http://reviews.llvm.org/D8940 llvm-svn: 258650
* [PGO] Simplify coverage mapping loweringXinliang David Li2016-01-071-1/+1
| | | | | | | | | | | | | | | | Coverage mapping data may reference names of functions that are skipped by FE (e.g, unused inline functions). Since those functions are skipped, normal instr-prof function lowering pass won't put those names in the right section, so special handling is needed to walk through coverage mapping structure and recollect the references. With this patch, only names that are skipped are processed. This simplifies the lowering code and it no longer needs to make assumptions coverage mapping data layout. It should also be more efficient. llvm-svn: 257092
* Remove setting of inlinehint and cold attributes based on profile dataEaswaran Raman2016-01-041-10/+0
| | | | | | | | | | | NFC. These hints are only used for inlining and the inliner now uses the same criteria to identify hot and cold callees and set appropriate thresholds without relying on these hints. Hence this removed code is superfluous. Differential Revision: http://reviews.llvm.org/D15726 llvm-svn: 256793
* [PGO] Instrument only base constructors and destructors.Serge Pavlov2015-12-061-15/+12
| | | | | | | | | | | | | | | | Constructors and destructors may be represented by several functions in IR. Only base structors correspond to source code, others are small pieces of code and eventually call the base variant. In this case instrumentation of non-base structors has little sense, this fix remove it. Now profile data of a declaration corresponds to exactly one function in IR, it agrees with the current logic of the profile data loading. This change fixes PR24996. Differential Revision: http://reviews.llvm.org/D15158 llvm-svn: 254876
* Pass profile version info to name API (NFC)Xinliang David Li2015-12-051-1/+4
| | | | llvm-svn: 254839
* [PGO] Code cleanup [NFC]Xinliang David Li2015-11-091-43/+2
| | | | | | | Use interfaces defined in LLVM to create FuncName and FuncNameVar. llvm-svn: 252434
* CodeGen: Remove implicit ilist iterator conversions, NFCDuncan P. N. Exon Smith2015-11-061-1/+1
| | | | | | | Make ilist iterator conversions explicit in clangCodeGen. Eventually I'll remove them everywhere. llvm-svn: 252358
* Use newly introduced interfaces in LLVM (NFC)Xinliang David Li2015-10-221-1/+1
| | | | | | | Replaced references to raw strings in instrumentation and coverage code. llvm-svn: 251072
* Fix Clang-tidy modernize-use-nullptr warnings in source directories; other ↵Hans Wennborg2015-10-061-2/+2
| | | | | | | | | | minor cleanups Patch by Eugene Zelenko! Differential Revision: http://reviews.llvm.org/D13406 llvm-svn: 249484
* Switch users of the 'for (StmtRange range = stmt->children(); range; ↵Benjamin Kramer2015-07-021-4/+3
| | | | | | | | | ++range)‘ pattern to range for loops. The pattern was born out of the lack of range-based for loops in C++98 and is somewhat obscure. No functionality change intended. llvm-svn: 241300
* Revert r240270 ("Fixed/added namespace ending comments using clang-tidy").Alexander Kornienko2015-06-221-1/+1
| | | | llvm-svn: 240353
* Fixed/added namespace ending comments using clang-tidy. NFCAlexander Kornienko2015-06-221-1/+1
| | | | | | | | | | | | The patch is generated using this command: $ tools/extra/clang-tidy/tool/run-clang-tidy.py -fix \ -checks=-*,llvm-namespace-comment -header-filter='llvm/.*|clang/.*' \ work/llvm/tools/clang To reduce churn, not touching namespaces spanning less than 10 lines. llvm-svn: 240270
* Set function entry counts with -fprofile-instr-use.Diego Novillo2015-05-271-0/+2
| | | | | | This generates function entry counts from instrumentation profiles. llvm-svn: 238360
* API update for streamlining of IRBuilder::CreateCall to just use ↵David Blaikie2015-05-181-3/+3
| | | | | | ArrayRef/initializer_list+braced init llvm-svn: 237625
* InstrProf: Cede ownership of createProfileWeights to CGFJustin Bogner2015-05-021-9/+10
| | | | | | | | The fact that PGO has a say in how these branch weights are determined isn't interesting to most of CodeGen, so it makes more sense for this API to be accessible via CodeGenFunction rather than CodeGenPGO. llvm-svn: 236380
* InstrProf: Use a locally tracked current count in ComputeRegionCountsJustin Bogner2015-05-021-33/+35
| | | | | | | | No functional change. This just makes it more obvious that the logic in ComputeRegionCounts only depends on the counter map and local state. llvm-svn: 236370
* InstrProf: Replace the RegionCounter class with a simpler direct approachJustin Bogner2015-05-011-130/+111
| | | | | | | | | This removes the RegionCounter class, which is only used as a helper in teh ComputeRegionCounts stmt visitor. This class is just an extra layer of abstraction that makes the code harder to follow at this point, and removing it makes the logic quite a bit more direct. llvm-svn: 236364
* InstrProf: Fix handling of profile counters in the body of range based forJustin Bogner2015-04-301-3/+2
| | | | | | | | | We were assigning the counter for the body of the loop to the loop variable initialization for some reason here, but our tests completely lacked coverage for range-for loops. This fixes that and makes the logic generally more similar to the logic for a regular for. llvm-svn: 236277
* InstrProf: Mark code regions after throw expressions as unreachableJustin Bogner2015-04-281-0/+8
| | | | | | | We weren't setting regions as being unreachable after C++ throw expressions, leading to incorrect count propagations. llvm-svn: 235967
* InstrProf: Stop using RegionCounter outside of CodeGenPGO (NFC)Justin Bogner2015-04-231-3/+4
| | | | | | | | | The RegionCounter type does a lot of legwork, but most of it is only meaningful within the implementation of CodeGenPGO. The uses elsewhere in CodeGen generally just want to increment or read counters, so do that directly. llvm-svn: 235664
* InstrProf: Fix a shadowing error that would break length of profile namesJustin Bogner2015-04-231-2/+2
| | | | | | | | We try to use the member variable "FuncName" here, but we've also used that name as a parameter. This ends with us getting the length of the function name wrong when we generate the coverage data. llvm-svn: 235565
* InstrProf: Simplify getStmtCount by using an OptionalJustin Bogner2015-04-131-6/+4
| | | | llvm-svn: 234750
* InstrProf: Make profile variables private to reduce binary size overheadJustin Bogner2015-03-201-2/+6
| | | | | | | | | | | | When we instrument a program for profiling, we copy the linkage of an instrumented function so that our datastructures merge in the same way as the function. This avoids redundant copies for things like linkonce, but ends up emitting names we never need to reference for normal and internal symbols. Promoting internal and external linkage to private for these variables reduces the size overhead of profiling drastically. llvm-svn: 232799
* 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
OpenPOWER on IntegriCloud