vtjnash wrote:
Ah, good catch, I missed that store. It could be adjusted in that vicinity,
though I don't think this necessarily is the right way to handle it:
```diff
diff --git a/clang/lib/CodeGen/CGExprAgg.cpp b/clang/lib/CodeGen/CGExprAgg.cpp
index a49b1c8cf3b7..95ce1df6e967 100644
--- a/clang/lib/CodeGen/CGExprAgg.cpp
+++ b/clang/lib/CodeGen/CGExprAgg.cpp
@@ -487,6 +487,7 @@ void AggExprEmitter::VisitCXXStdInitializerListExpr(
Ctx.hasSameType(Field->getType()->getPointeeType(),
ArrayType->getElementType()) &&
"Expected std::initializer_list first field to be const E *");
+ ArrayPtr =
ArrayPtr.withPointer(CGF.performAddrSpaceCast(ArrayPtr.emitRawPointer(CGF),
CGF.ConvertType(Field->getType())));
// Start pointer.
AggValueSlot Dest = EnsureSlot(E->getType());
```
I instead kept a few more addrspace cast which seem unnecessary, but might get
observed (e.g. by the store in VisitCXXStdInitializerListExpr):
https://github.com/llvm/llvm-project/pull/200427. Those might have to be
addressed individually, when encountered in Sema, instead of the attempted
broad patch of all CreateAggTemp calls.
In general here, the difficulty is teaching Sema to always be careful about
calling `getNonLValueExprType` (which is simply `getUnqualifiedType()`) when
making expression types which might need to make a temporary. For example, the
result of `*(volatile __global int)p` is `int` but has a `decltype()` of
`volatile __global int` (and thus `decltype(*p) x = p` might be illegal on some
targets when `auto x = *p` would be fine).
https://github.com/llvm/llvm-project/pull/197745
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits