[clang] [Clang][CodeGen] Preserve alignment information for pointer arithmetics (PR #152575)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 7 13:20:32 PDT 2025
================
@@ -4184,29 +4184,14 @@ Value *ScalarExprEmitter::EmitOverflowCheckedBinOp(const BinOpInfo &Ops) {
}
/// Emit pointer + index arithmetic.
-static Value *emitPointerArithmetic(CodeGenFunction &CGF,
- const BinOpInfo &op,
- bool isSubtraction) {
- // Must have binary (not unary) expr here. Unary pointer
- // increment/decrement doesn't use this path.
- const BinaryOperator *expr = cast<BinaryOperator>(op.E);
-
- Value *pointer = op.LHS;
- Expr *pointerOperand = expr->getLHS();
- Value *index = op.RHS;
- Expr *indexOperand = expr->getRHS();
-
- // In a subtraction, the LHS is always the pointer.
- if (!isSubtraction && !pointer->getType()->isPointerTy()) {
- std::swap(pointer, index);
- std::swap(pointerOperand, indexOperand);
- }
-
+llvm::Value *CodeGenFunction::EmitPointerArithmetic(
----------------
efriedma-quic wrote:
This refactor is sort of tricky to follow; can you land it separately as an NFC patch?
https://github.com/llvm/llvm-project/pull/152575
More information about the cfe-commits
mailing list