[compiler-rt] r254701 - [PGO] Fix mips test failure with new test case
Xinliang David Li via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 4 20:04:30 PST 2015
This code will be gone soon. I have a pending change to do config time
check for atomic operations availability on target. Once that is in, the
ARCH specific check will be replaced with a common macro check.
David
On Fri, Dec 4, 2015 at 7:55 PM, Sean Silva <chisophugis at gmail.com> wrote:
>
>
> On Thu, Dec 3, 2015 at 8:23 PM, Xinliang David Li via llvm-commits <
> llvm-commits at lists.llvm.org> wrote:
>
>> 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).
>>
>
> Can you add a comment near the #ifdef explaining this?
>
> -- Sean Silva
>
>
>>
>>
>> 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);
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151204/108326e2/attachment.html>
More information about the llvm-commits
mailing list