[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 14:15:28 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:

Okay, but that seems incredibly fragile. It'll be bypassing the code in `EmitLValue`. Wouldn't it be better to do it in the opposite way? Allow `EmitLValue` to do its thing. It'll return a GEP. I can then use `ArrayLV.getAddress(*this)` to build a GEP to `count` without re-loading the base pointer?

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


More information about the cfe-commits mailing list