[llvm] [CodeGen] Pass the atomic instruction to supportsUnalignedAtomics (PR #216621)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Aug 16 19:38:48 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-selectiondag
Author: Harrison Hao (harrisonGPU)
<details>
<summary>Changes</summary>
<sub>Stack created with <a href="https://github.com/github/gh-stack">GitHub Stacks CLI</a> • <a href="https://gh.io/stacks-feedback">Give Feedback 💬</a></sub>
---
Full diff: https://github.com/llvm/llvm-project/pull/216621.diff
2 Files Affected:
- (modified) llvm/include/llvm/CodeGen/TargetLowering.h (+3-1)
- (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (+2-2)
``````````diff
diff --git a/llvm/include/llvm/CodeGen/TargetLowering.h b/llvm/include/llvm/CodeGen/TargetLowering.h
index c8aa38afc5dd0..2eb93a440a6f3 100644
--- a/llvm/include/llvm/CodeGen/TargetLowering.h
+++ b/llvm/include/llvm/CodeGen/TargetLowering.h
@@ -2302,7 +2302,9 @@ class LLVM_ABI TargetLoweringBase {
unsigned getMinCmpXchgSizeInBits() const { return MinCmpXchgSizeInBits; }
/// Whether the target supports unaligned atomic operations.
- bool supportsUnalignedAtomics() const { return SupportsUnalignedAtomics; }
+ virtual bool supportsUnalignedAtomics(const Instruction *I) const {
+ return SupportsUnalignedAtomics;
+ }
/// Whether AtomicExpandPass should automatically insert fences and reduce
/// ordering for this atomic. This should be true for most architectures with
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index b3e22ff50d4bd..efb30eba6d82e 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -5369,7 +5369,7 @@ void SelectionDAGBuilder::visitAtomicLoad(const LoadInst &I) {
EVT VT = TLI.getValueType(DAG.getDataLayout(), I.getType());
EVT MemVT = TLI.getMemValueType(DAG.getDataLayout(), I.getType());
- if (!TLI.supportsUnalignedAtomics() &&
+ if (!TLI.supportsUnalignedAtomics(&I) &&
I.getAlign().value() < MemVT.getSizeInBits() / 8)
report_fatal_error("Cannot generate unaligned atomic load");
@@ -5406,7 +5406,7 @@ void SelectionDAGBuilder::visitAtomicStore(const StoreInst &I) {
EVT MemVT =
TLI.getMemValueType(DAG.getDataLayout(), I.getValueOperand()->getType());
- if (!TLI.supportsUnalignedAtomics() &&
+ if (!TLI.supportsUnalignedAtomics(&I) &&
I.getAlign().value() < MemVT.getSizeInBits() / 8)
report_fatal_error("Cannot generate unaligned atomic store");
``````````
</details>
https://github.com/llvm/llvm-project/pull/216621
More information about the llvm-commits
mailing list