================
@@ -2520,15 +2519,47 @@ RValue CIRGenFunction::emitBuiltinExpr(const GlobalDecl 
&gd, unsigned builtinID,
     }
     return RValue::get(dest.getPointer());
   }
+  case Builtin::BI__builtin_trivially_relocate:
+  case Builtin::BImemmove:
+  case Builtin::BI__builtin_memmove: {
+    mlir::Location loc = getLoc(e->getSourceRange());
+    Address dest = emitPointerWithAlignment(e->getArg(0));
+    Address src = emitPointerWithAlignment(e->getArg(1));
+    mlir::Value sizeVal = emitScalarExpr(e->getArg(2));
+    if (builtinIDIfNoAsmLabel == Builtin::BI__builtin_trivially_relocate) {
+      QualType eltTy = e->getArg(0)->getType()->getPointeeType();
+      CharUnits eltSize = getContext().getTypeSizeInChars(eltTy);
+      mlir::Value eltSizeVal =
+          builder.getConstInt(loc, sizeVal.getType(), eltSize.getQuantity());
+      sizeVal = builder.createMul(loc, sizeVal, eltSizeVal);
+    }
+    emitNonNullArgCheck(RValue::get(dest.getPointer()), 
e->getArg(0)->getType(),
+                        e->getArg(0)->getExprLoc(), fd, 0);
+    emitNonNullArgCheck(RValue::get(src.getPointer()), e->getArg(1)->getType(),
+                        e->getArg(1)->getExprLoc(), fd, 1);
+    assert(!cir::MissingFeatures::sanitizers());
+    Address destCast = dest.withElementType(builder, cgm.voidTy);
+    Address srcCast = src.withElementType(builder, cgm.voidTy);
+    builder.createMemMove(loc, destCast, srcCast, sizeVal);
+    assert(!cir::MissingFeatures::generateDebugInfo());
+    return RValue::get(dest.getPointer());
+  }
+  case Builtin::BImemset:
+  case Builtin::BI__builtin_memset: {
+    Address dest = emitPointerWithAlignment(e->getArg(0));
+    mlir::Value byteVal = builder.createIntCast(emitScalarExpr(e->getArg(1)),
+                                                builder.getUInt8Ty());
+    mlir::Value sizeVal = emitScalarExpr(e->getArg(2));
+    emitNonNullArgCheck(RValue::get(dest.getPointer()), 
e->getArg(0)->getType(),
+                        e->getArg(0)->getExprLoc(), fd, 0);
+    builder.createMemSet(getLoc(e->getSourceRange()), dest, byteVal, sizeVal);
+    assert(!cir::MissingFeatures::generateDebugInfo());
+    return RValue::get(dest.getPointer());
+  }
   case Builtin::BI__builtin_memcpy_inline:
   case Builtin::BI__builtin___memcpy_chk:
   case Builtin::BI__builtin_objc_memmove_collectable:
   case Builtin::BI__builtin___memmove_chk:
-  case Builtin::BI__builtin_trivially_relocate:
----------------
steffenlarsen wrote:

Thanks! I was not aware of this, so I worry a few reorderings have made it in 
under my supervision. I'll try and do a sweep of these to see if we can recover 
the original ordering as an NFC.

https://github.com/llvm/llvm-project/pull/227667
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to