[compiler-rt] r254701 - [PGO] Fix mips test failure with new test case
Xinliang David Li via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 3 20:23:01 PST 2015
Author: davidxl
Date: Thu Dec 3 22:22:59 2015
New Revision: 254701
URL: http://llvm.org/viewvc/llvm-project?rev=254701&view=rev
Log:
[PGO] Fix mips test failure with new test case
cmp&swap is not well supported -- the new test
case triggers some assembler error.
This is a partial fix to the general problem (lack
of atomics operation support for certain targets).
Modified:
compiler-rt/trunk/lib/profile/InstrProfiling.c
Modified: compiler-rt/trunk/lib/profile/InstrProfiling.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/profile/InstrProfiling.c?rev=254701&r1=254700&r2=254701&view=diff
==============================================================================
--- compiler-rt/trunk/lib/profile/InstrProfiling.c (original)
+++ compiler-rt/trunk/lib/profile/InstrProfiling.c Thu Dec 3 22:22:59 2015
@@ -23,6 +23,22 @@
return 0; \
}
+#ifdef _MIPS_ARCH
+LLVM_LIBRARY_VISIBILITY
+uint32_t BoolCmpXchg(void **Ptr, void *OldV, void *NewV) {
+ void *R = *Ptr;
+ if (R == OldV) {
+ *Ptr = NewV;
+ return 1;
+ }
+ return 0;
+}
+#define BOOL_CMPXCHG(Ptr, OldV, NewV) BoolCmpXchg((void **)Ptr, OldV, NewV)
+#else
+#define BOOL_CMPXCHG(Ptr, OldV, NewV) \
+ __sync_bool_compare_and_swap(Ptr, OldV, NewV)
+#endif
+
LLVM_LIBRARY_VISIBILITY uint64_t __llvm_profile_get_magic(void) {
return sizeof(void *) == sizeof(uint64_t) ? (INSTR_PROF_RAW_MAGIC_64)
: (INSTR_PROF_RAW_MAGIC_32);
@@ -106,7 +122,7 @@ static int allocateValueProfileCounters(
(ValueProfNode **)calloc(NumVSites, sizeof(ValueProfNode *));
if (!Mem)
return 0;
- if (!__sync_bool_compare_and_swap(&Data->Values, 0, Mem)) {
+ if (!BOOL_CMPXCHG(&Data->Values, 0, Mem)) {
free(Mem);
return 0;
}
@@ -171,10 +187,9 @@ __llvm_profile_instrument_target(uint64_
uint32_t Success = 0;
if (!ValueCounters[CounterIndex])
- Success = __sync_bool_compare_and_swap(&ValueCounters[CounterIndex], 0,
- CurrentVNode);
+ Success = BOOL_CMPXCHG(&ValueCounters[CounterIndex], 0, CurrentVNode);
else if (PrevVNode && !PrevVNode->Next)
- Success = __sync_bool_compare_and_swap(&(PrevVNode->Next), 0, CurrentVNode);
+ Success = BOOL_CMPXCHG(&(PrevVNode->Next), 0, CurrentVNode);
if (!Success) {
free(CurrentVNode);
More information about the llvm-commits
mailing list