[flang-commits] [clang] [clang-tools-extra] [libcxx] [flang] [compiler-rt] [libc] [llvm] [Clang] Generate the GEP instead of adding AST nodes (PR #73730)

Bill Wendling via flang-commits flang-commits at lists.llvm.org
Fri Dec 15 14:14:57 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:

It started with a couple of bugs reported by someone testing the feature on Linux. I created a fix, but it wasn't super great and relied upon some assumptions about how the FAM expressions were formatted. Plus it could reload the expressions, which isn't good, especially if they have side effects. @nickdesaulniers had the good idea to generate the GEPs in a similar way to this. (That's where this code comes from.) Then several different cases were mentioned that needed to be handled at least gracefully...and the yak kept growing hair.

I don't necessarily think that this is adding "new" features more than just taking care of case after case after case ..., which is legion in C. For instance, the code was meant to handle FAMs in substructures, but because it's potentially very messy, maybe I should remove that feature. That would hopefully simplify this patch.

I'll update this patch removing the substructure FAM support and using your "offset" idea to get the count. Thanks for your feedback!

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


More information about the flang-commits mailing list