[llvm-branch-commits] CodeGen: Fix implementation of __builtin_trivially_relocate. (PR #140312)

Peter Collingbourne via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Fri May 16 18:15:14 PDT 2025


================
@@ -4425,6 +4425,14 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
     Address Dest = EmitPointerWithAlignment(E->getArg(0));
     Address Src = EmitPointerWithAlignment(E->getArg(1));
     Value *SizeVal = EmitScalarExpr(E->getArg(2));
+    if (BuiltinIDIfNoAsmLabel == Builtin::BI__builtin_trivially_relocate)
+      SizeVal = Builder.CreateMul(
----------------
pcc wrote:

I think an overflow here can only result from a call to `std::trivially_relocate(first, last, result)` with `first > last`. I feel like it would probably be better to report the error at the caller so that we can provide a better error message.

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


More information about the llvm-branch-commits mailing list