Skip to content

Commit c8eb932

Browse files
author
Wael Yehia
committed
[PGO] Simplify InstrProfilingRuntime.cpp
Differential Revision: https://reviews.llvm.org/D136192
1 parent d81725d commit c8eb932

File tree

1 file changed

+5
-13
lines changed

1 file changed

+5
-13
lines changed

compiler-rt/lib/profile/InstrProfilingRuntime.cpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,13 @@ extern "C" {
1212

1313
static int RegisterRuntime() {
1414
__llvm_profile_initialize();
15+
#ifdef _AIX
16+
extern COMPILER_RT_VISIBILITY void *__llvm_profile_keep[];
17+
(void)*(void *volatile *)__llvm_profile_keep;
18+
#endif
1519
return 0;
1620
}
1721

18-
#ifndef _AIX
1922
/* int __llvm_profile_runtime */
20-
COMPILER_RT_VISIBILITY int INSTR_PROF_PROFILE_RUNTIME_VAR;
21-
22-
static int Registration = RegisterRuntime();
23-
#else
24-
extern COMPILER_RT_VISIBILITY void *__llvm_profile_keep[];
25-
/* On AIX, when linking with -bcdtors:csect, the variable whose constructor does
26-
* the registration needs to be explicitly kept, hence we reuse the runtime hook
27-
* variable to do the registration since it'll be kept via the -u linker flag.
28-
* Create a volatile reference to __llvm_profile_keep to keep the array alive.*/
29-
COMPILER_RT_VISIBILITY int INSTR_PROF_PROFILE_RUNTIME_VAR =
30-
((void)*(void *volatile *)__llvm_profile_keep, RegisterRuntime());
31-
#endif
23+
COMPILER_RT_VISIBILITY int INSTR_PROF_PROFILE_RUNTIME_VAR = RegisterRuntime();
3224
}

0 commit comments

Comments
 (0)