diff options
author | Matt Arsenault <Matthew.Arsenault@amd.com> | 2022-04-05 17:48:50 -0400 |
---|---|---|
committer | Matt Arsenault <Matthew.Arsenault@amd.com> | 2022-04-06 22:34:04 -0400 |
commit | c4ea925f504850e521d1e9d7c54bb00a1f1d80c3 (patch) | |
tree | 0f8af9947aa974ce4b2b862e5e2868f70d6b3bb8 /llvm/lib/CodeGen/AtomicExpandPass.cpp | |
parent | 1b547799c504fb5f6286801653a9d4d59a99ee66 (diff) | |
download | llvm-c4ea925f504850e521d1e9d7c54bb00a1f1d80c3.zip llvm-c4ea925f504850e521d1e9d7c54bb00a1f1d80c3.tar.gz llvm-c4ea925f504850e521d1e9d7c54bb00a1f1d80c3.tar.bz2 |
AtomicExpand: Change return type for shouldExpandAtomicStoreInIR
Use the same enum as the other atomic instructions for consistency, in
preparation for addition of another strategy.
Introduce a new "Expand" option, since the store expansion does not
use cmpxchg. Alternatively, the existing CmpXChg strategy could be
renamed to Expand.
Diffstat (limited to 'llvm/lib/CodeGen/AtomicExpandPass.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AtomicExpandPass.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/AtomicExpandPass.cpp b/llvm/lib/CodeGen/AtomicExpandPass.cpp index 45b41ce..05b140b 100644 --- a/llvm/lib/CodeGen/AtomicExpandPass.cpp +++ b/llvm/lib/CodeGen/AtomicExpandPass.cpp @@ -77,6 +77,7 @@ private: bool expandAtomicLoadToLL(LoadInst *LI); bool expandAtomicLoadToCmpXchg(LoadInst *LI); StoreInst *convertAtomicStoreToIntegerType(StoreInst *SI); + bool tryExpandAtomicStore(StoreInst *SI); void expandAtomicStore(StoreInst *SI); bool tryExpandAtomicRMW(AtomicRMWInst *AI); AtomicRMWInst *convertAtomicXchgToIntegerType(AtomicRMWInst *RMWI); @@ -271,10 +272,8 @@ bool AtomicExpand::runOnFunction(Function &F) { MadeChange = true; } - if (TLI->shouldExpandAtomicStoreInIR(SI)) { - expandAtomicStore(SI); + if (tryExpandAtomicStore(SI)) MadeChange = true; - } } else if (RMWI) { // There are two different ways of expanding RMW instructions: // - into a load if it is idempotent @@ -418,6 +417,18 @@ bool AtomicExpand::tryExpandAtomicLoad(LoadInst *LI) { } } +bool AtomicExpand::tryExpandAtomicStore(StoreInst *SI) { + switch (TLI->shouldExpandAtomicStoreInIR(SI)) { + case TargetLoweringBase::AtomicExpansionKind::None: + return false; + case TargetLoweringBase::AtomicExpansionKind::Expand: + expandAtomicStore(SI); + return true; + default: + llvm_unreachable("Unhandled case in tryExpandAtomicStore"); + } +} + bool AtomicExpand::expandAtomicLoadToLL(LoadInst *LI) { IRBuilder<> Builder(LI); |