================
@@ -1138,24 +1139,40 @@ void CodeGenFunction::EmitNewArrayInitializer(
 
     CharUnits StartAlign = CurPtr.getAlignment();
     unsigned i = 0;
+    auto AdvanceToNextElement = [&]() {
+      CurPtr = Address(Builder.CreateInBoundsGEP(CurPtr.getElementType(),
+                                                 CurPtr.emitRawPointer(*this),
+                                                 Builder.getSize(1),
+                                                 "array.exp.next"),
+                       CurPtr.getElementType(),
+                       StartAlign.alignmentAtOffset((++i) * ElementSize));
+    };
     for (const Expr *IE : InitExprs) {
       // Tell the cleanup that it needs to destroy up to this
       // element.  TODO: some of these stores can be trivially
       // observed to be unnecessary.
       if (EndOfInit.isValid()) {
         Builder.CreateStore(CurPtr.emitRawPointer(*this), EndOfInit);
       }
+      // An EmbedExpr can initialize more than one array element.
+      if (const auto *EmbedS = dyn_cast<EmbedExpr>(IE->IgnoreParenImpCasts())) 
{
+        for (const IntegerLiteral *DataElement :
+             EmbedS->underlying_data_elements()) {
+          llvm::Value *Val = EmitScalarConversion(
----------------
Fznamznon wrote:

Why doesn't that use `StoreAnyExprIntoOneUnit` like a non-embed initializer 
path?
Can we use `doForEachDataElement` instead of a loop? 

IIRC, `doForEachDataElement` or what you're doing is actually also slow because 
it creates integer literals, the fastest way to do this is accessing underlying 
string literal directly like ExprConstant does. But we can at least start with 
`doForEachDataElement` and stop crashing.

https://github.com/llvm/llvm-project/pull/218262
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to