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

Eli Friedman via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 7 14:42:31 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)) {
----------------
efriedma-quic wrote:

So instead of a GEP from the base to "array", then a GEP from the base to "count", you emit a GEP from the base to "array", then a GEP from the "array" to the "count"?  That's basically just rearranging the math; instead of "a + b", you compute "a + c + (b - c)".  Maybe it saves refactoring some code, though.

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


More information about the cfe-commits mailing list