[clang] [ClangFE] Improve handling of casting of atomic memory operations. (PR #86691)

Jonas Paulsson via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 27 04:21:10 PDT 2024


================
@@ -1399,13 +1401,22 @@ RValue AtomicInfo::convertAtomicTempToRValue(Address addr,
       LVal.getBaseInfo(), TBAAAccessInfo()));
 }
 
+static bool shouldCastToInt(llvm::Type *ValTy, bool CmpXchg) {
----------------
JonPsson1 wrote:

This is a bit messy...

- For one thing, there can't currently be an atomic CmpXchg of float type - per the spec - so that must be casted to int. That would be a later patch on its own, including as well changes in the spec document and AtomicExpand.

- An atomic struct needs to be casted to integer in EmitAtomicLoadOp().

- In ConvertToValueOrAtomic() and convertRValueToInt(), scalars are treated specially. But still FP80 and float/CmpXchg scalars currrently need casting.

- FP80 also seems like a separate patch if there's a need. I guess maybe in that case it does make sense to cast it to i128 here, as there is only one target using it, and it's a special non-power-of-2 case..?

So it still looks to me that there are these two changes that would first need handling, and then this could probably be improved further.

https://github.com/llvm/llvm-project/pull/86691


More information about the cfe-commits mailing list