[clang] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

Bill Wendling via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 7 13:29:54 PST 2023


================
@@ -4022,8 +4169,36 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
       ArrayLV = EmitArraySubscriptExpr(ASE, /*Accessed*/ true);
     else
       ArrayLV = EmitLValue(Array);
+
     auto *Idx = EmitIdxAfterBase(/*Promote*/true);
 
+    if (SanOpts.has(SanitizerKind::ArrayBounds)) {
----------------
bwendling wrote:

I'm honestly not sure how to do that. I may have missed a method, but if you have the base pointer how do you use that to compute the rest of the expression? For instance, if `p->p->p` is the base, how do I use that to emit the full expression `p->p->p->a.b.c.d.e[index]`?

I can skip the extra load here by using the pointer from the `ArrayLV` GEP.

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


More information about the cfe-commits mailing list