[clang] [CIR] Add support for constructors with VTT parameters (PR #156521)

Henrich Lauko via cfe-commits cfe-commits at lists.llvm.org
Wed Sep 3 03:53:59 PDT 2025


================
@@ -329,10 +330,35 @@ static Address applyNonVirtualAndVirtualOffset(
           loc, addr, baseValueTy, nonVirtualOffset.getQuantity(),
           assumeNotNull);
     }
+  } else {
+    baseOffset = virtualOffset;
+  }
+
+  // Apply the base offset.  cir.ptr_stride adjusts by a number of elements,
+  // not bytes.  So the pointer must be cast to a byte pointer and back.
+
+  mlir::Value ptr = addr.getPointer();
+  mlir::Type charPtrType = cgf.cgm.UInt8PtrTy;
+  mlir::Value charPtr =
+      cgf.getBuilder().createCast(cir::CastKind::bitcast, ptr, charPtrType);
+  mlir::Value adjusted = cir::PtrStrideOp::create(
+      cgf.getBuilder(), loc, charPtrType, charPtr, baseOffset);
+  ptr = cgf.getBuilder().createCast(cir::CastKind::bitcast, adjusted,
+                                    ptr.getType());
+
----------------
xlauko wrote:

```suggestion
  ptr = cgf.getBuilder().createBitcast(adjusted, ptr.getType());
```

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


More information about the cfe-commits mailing list