[clang] [Matrix] Preserve signedness when extending matrix index expression. (PR #103044)
Florian Hahn via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 16 02:07:11 PDT 2024
================
@@ -4348,8 +4348,18 @@ LValue CodeGenFunction::EmitMatrixSubscriptExpr(const MatrixSubscriptExpr *E) {
!E->isIncomplete() &&
"incomplete matrix subscript expressions should be rejected during Sema");
LValue Base = EmitLValue(E->getBase());
- llvm::Value *RowIdx = EmitScalarExpr(E->getRowIdx());
- llvm::Value *ColIdx = EmitScalarExpr(E->getColumnIdx());
+
+ // Extend or truncate the index type to 32 or 64-bits.
+ auto EmitIndex = [this](const Expr *E) {
----------------
fhahn wrote:
> Can you just pull this out as a helper function on CGF and then call it in both places?
Done, thanks
> It looks like EmitArraySubscriptExpr does something similar, but it wouldn't be easy to share the logic because it also potentially emits a sanitizer check. On the other hand, is that something we should also be doing here? I assume this is UB if it's out-of-bounds. We always have static bounds on matrix types, right?
yes we have static bounds, so it would probably make sense to extend to logic to also support sanitizer checks for matrix subscript expressions. But probably better done separately?
https://github.com/llvm/llvm-project/pull/103044
More information about the cfe-commits
mailing list