Author: Timm Baeder Date: 2026-08-20T15:19:38+02:00 New Revision: 40b01d09d907dad32862074cc6a827c6506a30b2
URL: https://github.com/llvm/llvm-project/commit/40b01d09d907dad32862074cc6a827c6506a30b2 DIFF: https://github.com/llvm/llvm-project/commit/40b01d09d907dad32862074cc6a827c6506a30b2.diff LOG: [clang][bytecode] Remove a Pointer::toAPValue() call (#217594) We can just use `computeLayoutOffset()` instead. Added: Modified: clang/lib/AST/ByteCode/InterpBuiltin.cpp Removed: ################################################################################ diff --git a/clang/lib/AST/ByteCode/InterpBuiltin.cpp b/clang/lib/AST/ByteCode/InterpBuiltin.cpp index 17a0983059bc7..0e7278a6de2c4 100644 --- a/clang/lib/AST/ByteCode/InterpBuiltin.cpp +++ b/clang/lib/AST/ByteCode/InterpBuiltin.cpp @@ -1374,15 +1374,16 @@ static bool interp__builtin_assume_aligned(InterpState &S, CodePtr OpPC, return false; const Pointer &Ptr = S.Stk.pop<Pointer>(); + const ASTContext &ASTCtx = S.getASTContext(); CharUnits Align = CharUnits::fromQuantity(Alignment.getZExtValue()); // If there is a base object, then it must have the correct alignment. if (Ptr.isBlockPointer()) { CharUnits BaseAlignment; if (const auto *VD = Ptr.getDeclDesc()->asValueDecl()) - BaseAlignment = S.getASTContext().getDeclAlign(VD); + BaseAlignment = ASTCtx.getDeclAlign(VD); else if (const auto *E = Ptr.getRootExpr()) - BaseAlignment = GetAlignOfExpr(S.getASTContext(), E, UETT_AlignOf); + BaseAlignment = GetAlignOfExpr(ASTCtx, E, UETT_AlignOf); if (BaseAlignment < Align) { S.CCEDiag(Call->getArg(0), @@ -1392,8 +1393,11 @@ static bool interp__builtin_assume_aligned(InterpState &S, CodePtr OpPC, } } - APValue AV = Ptr.toAPValue(S.getASTContext()); - CharUnits AVOffset = AV.getLValueOffset(); + std::optional<size_t> LayoutOffset = Ptr.computeLayoutOffset(ASTCtx); + if (!LayoutOffset) + return false; + + CharUnits AVOffset = CharUnits::fromQuantity(*LayoutOffset); if (ExtraOffset) AVOffset -= CharUnits::fromQuantity(ExtraOffset->getZExtValue()); if (AVOffset.alignTo(Align) != AVOffset) { _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
