Expand most atomic nodes into their respective libcalls.
Missing is the cmpxchg operation which produces ATOMIC_CMP_SWAP_WITH_SUCCESS.
A number of optimizations can still be done with these nodes.
Paths
| Differential D60033
[MSP430] Expand Atomic nodes Needs ReviewPublic Authored by INdek on Mar 30 2019, 10:41 AM.
Details
Summary Expand most atomic nodes into their respective libcalls. Missing is the cmpxchg operation which produces ATOMIC_CMP_SWAP_WITH_SUCCESS.
Diff Detail
Event TimelineComment Actions Well, what's the overall motivation of all these changes? There are no multiple threads, etc. on msp430. I believe instead of lowering to libcalls we could simply "drop" atomic. Comment Actions Well, I've been fixing crashes with the GCC torture suite, and these are some of them, so that's why i've place this change. When you say "drop", is there a way to tell isel to use the regular instructions for all of the atomics? Because, yeah, that would be better. Also, how do I do that? Comment Actions
Threads are a property of the software, not the hardware; atomic operations can still be relevant on a single-processor systems. clang has an option -mthread-model if the user explicitly doesn't want to support multi-threaded execution; I'm not sure it's a good idea to force "-mthread-model single" on all users of msp430. (Granted, maybe msp430 has too little memory for anyone to try multi-threaded programming...) Comment Actions But MSP430 has interrupts and they are similar to threads in some ways. For example if I need to increment some shared counter, I would like it to be done in a single instruction. That way if some interrupt triggers at the same time it would not corrupt the value, because a single instruction can not be split. I had to use inline assembly to make such kind of counter, because volatile doesn't optimize to a single instruction in debug builds, only in release. My point is that just forcing mthread-model single may lead to bugs in peoples code if someone would actually use atomics to implement a counter for example.
Revision Contents
Diff 192984 llvm/lib/Target/MSP430/MSP430ISelLowering.cpp
llvm/test/CodeGen/MSP430/atomics/fence.ll
llvm/test/CodeGen/MSP430/atomics/load.ll
llvm/test/CodeGen/MSP430/atomics/load_add.ll
llvm/test/CodeGen/MSP430/atomics/load_and.ll
llvm/test/CodeGen/MSP430/atomics/load_max.ll
llvm/test/CodeGen/MSP430/atomics/load_min.ll
llvm/test/CodeGen/MSP430/atomics/load_nand.ll
llvm/test/CodeGen/MSP430/atomics/load_or.ll
llvm/test/CodeGen/MSP430/atomics/load_sub.ll
llvm/test/CodeGen/MSP430/atomics/load_swap.ll
llvm/test/CodeGen/MSP430/atomics/load_umax.ll
llvm/test/CodeGen/MSP430/atomics/load_umin.ll
llvm/test/CodeGen/MSP430/atomics/load_xor.ll
llvm/test/CodeGen/MSP430/atomics/store.ll
llvm/test/CodeGen/MSP430/atomics/swap.ll
|