[PATCH] D25334: Implement __stosb intrinsic as a volatile memset

David Majnemer via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 10 12:27:31 PDT 2016


majnemer added inline comments.


================
Comment at: lib/CodeGen/CGBuiltin.cpp:7610
+    Value *SizeVal = EmitScalarExpr(E->getArg(2));
+    EmitNonNullArgCheck(RValue::get(Dest.getPointer()), E->getArg(0)->getType(),
+                        E->getArg(0)->getExprLoc(), FD, 0);
----------------
agutowski wrote:
> hans wrote:
> > Hmm, does the __stosb intrinsic require Dest to be non-null (e.g. would Dest=NULL, Count=0 be OK?) I'm not even sure what llvm's memset requires actually.
> I can't find any guarantee that memset accepts Dest=NULL and Count=0. So I guess we can either add a branch here, checking if the pointer is NULL (and that Count=0?) or assume that memset won't do anything strange. I vote for the latter (the current code does it).
I think the approach you've taken here is fine, we shouldn't need a branch.


https://reviews.llvm.org/D25334





More information about the cfe-commits mailing list