@@ -345,12 +345,13 @@ RValue CIRGenFunction::emitRotate(const CallExpr *E, bool IsRotateRight) {
345
345
return RValue::get (r);
346
346
}
347
347
348
- static bool isMemBuiltinOutOfBoundPossible (const CallExpr *expr,
349
- clang::CIRGen::CIRGenModule &cgm,
348
+ static bool isMemBuiltinOutOfBoundPossible (const clang::Expr *sizeArg,
349
+ const clang::Expr *dstSizeArg,
350
+ clang::ASTContext &astContext,
350
351
llvm::APSInt &size) {
351
352
clang::Expr::EvalResult sizeResult, dstSizeResult;
352
- if (!expr-> getArg ( 2 )-> EvaluateAsInt (sizeResult, cgm. getASTContext () ) ||
353
- !expr-> getArg ( 3 )-> EvaluateAsInt (dstSizeResult, cgm. getASTContext () ))
353
+ if (!sizeArg-> EvaluateAsInt (sizeResult, astContext ) ||
354
+ !dstSizeArg-> EvaluateAsInt (dstSizeResult, astContext ))
354
355
return true ;
355
356
size = sizeResult.Val .getInt ();
356
357
llvm::APSInt dstSize = dstSizeResult.Val .getInt ();
@@ -1501,7 +1502,8 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
1501
1502
case Builtin::BI__builtin___memcpy_chk: {
1502
1503
// fold __builtin_memcpy_chk(x, y, cst1, cst2) to memcpy iff cst1<=cst2.
1503
1504
llvm::APSInt size;
1504
- if (isMemBuiltinOutOfBoundPossible (E, CGM, size))
1505
+ if (isMemBuiltinOutOfBoundPossible (E->getArg (2 ), E->getArg (3 ),
1506
+ CGM.getASTContext (), size))
1505
1507
break ;
1506
1508
Address dest = emitPointerWithAlignment (E->getArg (0 ));
1507
1509
Address src = emitPointerWithAlignment (E->getArg (1 ));
@@ -1517,7 +1519,8 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
1517
1519
case Builtin::BI__builtin___memmove_chk: {
1518
1520
// fold __builtin_memcpy_chk(x, y, cst1, cst2) to memcpy iff cst1<=cst2.
1519
1521
llvm::APSInt size;
1520
- if (isMemBuiltinOutOfBoundPossible (E, CGM, size))
1522
+ if (isMemBuiltinOutOfBoundPossible (E->getArg (2 ), E->getArg (3 ),
1523
+ CGM.getASTContext (), size))
1521
1524
break ;
1522
1525
Address Dest = emitPointerWithAlignment (E->getArg (0 ));
1523
1526
Address Src = emitPointerWithAlignment (E->getArg (1 ));
@@ -1556,7 +1559,8 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
1556
1559
case Builtin::BI__builtin___memset_chk: {
1557
1560
// fold __builtin_memset_chk(x, y, cst1, cst2) to memset iff cst1<=cst2.
1558
1561
llvm::APSInt size;
1559
- if (isMemBuiltinOutOfBoundPossible (E, CGM, size))
1562
+ if (isMemBuiltinOutOfBoundPossible (E->getArg (2 ), E->getArg (3 ),
1563
+ CGM.getASTContext (), size))
1560
1564
break ;
1561
1565
Address dest = emitPointerWithAlignment (E->getArg (0 ));
1562
1566
mlir::Value byteVal = emitScalarExpr (E->getArg (1 ));
0 commit comments