[clang] [Clang] Improve generation of GEP and RecordDecl loop (PR #101434)

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 1 11:23:02 PDT 2024


================
@@ -1136,15 +1135,15 @@ llvm::Value *CodeGenFunction::EmitCountedByFieldExpr(
     return nullptr;
   }
 
-  llvm::Value *Zero = Builder.getInt32(0);
   RecIndicesTy Indices;
-
   getGEPIndicesToField(*this, RD, CountDecl, Indices);
+  if (Indices.empty())
+    return nullptr;
 
-  for (auto I = Indices.rbegin(), E = Indices.rend(); I != E; ++I)
-    Res = Builder.CreateInBoundsGEP(
-        ConvertType(QualType(I->first->getTypeForDecl(), 0)), Res,
-        {Zero, I->second}, "..counted_by.gep");
+  Indices.emplace_back(Builder.getInt32(0));
----------------
efriedma-quic wrote:

push_back

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


More information about the cfe-commits mailing list