[clang] [CIR] Upstream pointer subtraction handling (PR #163306)
Andy Kaylor via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 14 15:34:21 PDT 2025
================
@@ -1734,9 +1734,9 @@ mlir::Value ScalarExprEmitter::emitSub(const BinOpInfo &ops) {
// LLVM we shall take VLA's, division by element size, etc.
//
// See more in `EmitSub` in CGExprScalar.cpp.
- assert(!cir::MissingFeatures::ptrDiffOp());
- cgf.cgm.errorNYI("ptrdiff");
- return {};
+ assert(!cir::MissingFeatures::llvmLoweringPtrDiffConsidersPointee());
+ return builder.create<cir::PtrDiffOp>(cgf.getLoc(ops.loc), cgf.PtrDiffTy,
+ ops.lhs, ops.rhs);
----------------
andykaylor wrote:
```suggestion
return cir::PtrDiffOp::create(builder, cgf.getLoc(ops.loc), cgf.PtrDiffTy,
ops.lhs, ops.rhs);
```
This is a change to the preferred operation creation idiom that hasn't yet been implemented in all the incubator code.
https://github.com/llvm/llvm-project/pull/163306
More information about the cfe-commits
mailing list