[libcxx-commits] [clang] [libcxxabi] [clang] respect Ty addrspace when making an alloca (PR #181390)
Jameson Nash via libcxx-commits
libcxx-commits at lists.llvm.org
Wed Feb 18 07:13:11 PST 2026
================
@@ -298,11 +298,15 @@ namespace {
}
Address AtomicInfo::CreateTempAlloca() const {
- Address TempAlloca = CGF.CreateMemTemp(
- (LVal.isBitField() && ValueSizeInBits > AtomicSizeInBits) ? ValueTy
- : AtomicTy,
- getAtomicAlignment(),
- "atomic-temp");
+ QualType TmpTy;
+ // Remove addrspace info from the atomic pointer element when making the
+ // alloca pointer element.
+ if (LVal.isBitField() && ValueSizeInBits > AtomicSizeInBits)
+ TmpTy = ValueTy;
+ else
+ TmpTy = AtomicTy.getUnqualifiedType();
----------------
vtjnash wrote:
So the complication here is that we're getting an atomic operation like `T _Atomic volatile addrspace(1)*` for some `T` which isn't an integer for some memory that probably isn't the stack, so now that atomic load needs to be bitcast into the actual `T`. But the C spec doesn't quite provide accurate enough information on whether it is acceptable to store `T` to the stack with all of those qualifiers. Prior to this PR, the qualifiers of T would be implicitly ignored when making the pointer and load/store for the on-stack bitcast here. But after this PR, getting the unqualified type for this purpose needs to be done explicitly instead.
https://github.com/llvm/llvm-project/pull/181390
More information about the libcxx-commits
mailing list