Duncan P. N. Exon Smith | 775c178a | 2014-03-20 19:23:53 +0000 | [diff] [blame] | 1 | //===- InstrProfilingRuntime.cpp - PGO runtime initialization -------------===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
Duncan P. N. Exon Smith | 775c178a | 2014-03-20 19:23:53 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | extern "C" { |
| 10 | |
Duncan P. N. Exon Smith | be0a5e1 | 2014-03-21 18:29:15 +0000 | [diff] [blame] | 11 | #include "InstrProfiling.h" |
Duncan P. N. Exon Smith | 775c178a | 2014-03-20 19:23:53 +0000 | [diff] [blame] | 12 | |
Xinliang David Li | f0e0a74 | 2016-07-22 04:08:16 +0000 | [diff] [blame] | 13 | /* int __llvm_profile_runtime */ |
| 14 | COMPILER_RT_VISIBILITY int INSTR_PROF_PROFILE_RUNTIME_VAR; |
Duncan P. N. Exon Smith | 775c178a | 2014-03-20 19:23:53 +0000 | [diff] [blame] | 15 | } |
| 16 | |
| 17 | namespace { |
| 18 | |
Duncan P. N. Exon Smith | 0843988 | 2014-05-16 01:30:24 +0000 | [diff] [blame] | 19 | class RegisterRuntime { |
Duncan P. N. Exon Smith | 775c178a | 2014-03-20 19:23:53 +0000 | [diff] [blame] | 20 | public: |
Duncan P. N. Exon Smith | 0843988 | 2014-05-16 01:30:24 +0000 | [diff] [blame] | 21 | RegisterRuntime() { |
Duncan P. N. Exon Smith | 55e4d66 | 2014-05-17 01:27:30 +0000 | [diff] [blame] | 22 | __llvm_profile_initialize_file(); |
Vedant Kumar | d889d1e | 2019-09-19 11:56:43 -0700 | [diff] [blame^] | 23 | if (!__llvm_profile_is_continuous_mode_enabled()) |
| 24 | __llvm_profile_register_write_file_atexit(); |
Duncan P. N. Exon Smith | 0843988 | 2014-05-16 01:30:24 +0000 | [diff] [blame] | 25 | } |
Duncan P. N. Exon Smith | 775c178a | 2014-03-20 19:23:53 +0000 | [diff] [blame] | 26 | }; |
| 27 | |
Duncan P. N. Exon Smith | 0843988 | 2014-05-16 01:30:24 +0000 | [diff] [blame] | 28 | RegisterRuntime Registration; |
Duncan P. N. Exon Smith | 775c178a | 2014-03-20 19:23:53 +0000 | [diff] [blame] | 29 | |
| 30 | } |