[clang] [Clang] Remove dead code related to atomics (NFC) (PR #216614)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Aug 16 16:25:45 PDT 2026
llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-codegen
Author: AZero13 (AZero13)
<details>
<summary>Changes</summary>
This PR cleans up dead code in `CGObjC.cpp` related to unaligned atomics.
Because the synchronization strategy (native vs. objc_copyStruct) is baked into the ABI for compiled frameworks, it can essentially never be changed for existing architectures like x86 without breaking backwards compatibility.
---
Full diff: https://github.com/llvm/llvm-project/pull/216614.diff
1 Files Affected:
- (modified) clang/lib/CodeGen/CGObjC.cpp (+3-16)
``````````diff
diff --git a/clang/lib/CodeGen/CGObjC.cpp b/clang/lib/CodeGen/CGObjC.cpp
index c724a063bafe8..b9cbf593fb1c4 100644
--- a/clang/lib/CodeGen/CGObjC.cpp
+++ b/clang/lib/CodeGen/CGObjC.cpp
@@ -869,19 +869,9 @@ static void emitStructGetterCall(CodeGenFunction &CGF, ObjCIvarDecl *ivar,
callee, ReturnValueSlot(), args);
}
-/// Determine whether the given architecture supports unaligned atomic
-/// accesses. They don't have to be fast, just faster than a function
-/// call and a mutex.
-static bool hasUnalignedAtomics(llvm::Triple::ArchType arch) {
- // FIXME: Allow unaligned atomic load/store on x86. (It is not
- // currently supported by the backend.)
- return false;
-}
-
/// Return the maximum size that permits atomic accesses for the given
/// architecture.
-static CharUnits getMaxAtomicAccessSize(CodeGenModule &CGM,
- llvm::Triple::ArchType arch) {
+static CharUnits getMaxAtomicAccessSize(CodeGenModule &CGM) {
// ARM has 8-byte atomic accesses, but it's not clear whether we
// want to rely on them here.
@@ -1047,20 +1037,17 @@ PropertyImplStrategy::PropertyImplStrategy(CodeGenModule &CGM,
return;
}
- llvm::Triple::ArchType arch =
- CGM.getTarget().getTriple().getArch();
-
// Most architectures require memory to fit within a single cache
// line, so the alignment has to be at least the size of the access.
// Otherwise we have to grab a lock.
- if (IvarAlignment < IvarSize && !hasUnalignedAtomics(arch)) {
+ if (IvarAlignment < IvarSize) {
Kind = CopyStruct;
return;
}
// If the ivar's size exceeds the architecture's maximum atomic
// access size, we have to use CopyStruct.
- if (IvarSize > getMaxAtomicAccessSize(CGM, arch)) {
+ if (IvarSize > getMaxAtomicAccessSize(CGM)) {
Kind = CopyStruct;
return;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/216614
More information about the cfe-commits
mailing list