[PATCH] D55349: Convert some ObjC alloc msgSends to runtime calls

John McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 7 13:34:56 PST 2018


rjmccall added inline comments.


================
Comment at: lib/CodeGen/CGObjC.cpp:385
+        // prefix are identified as OMF_alloc but we only want to call the
+        // runtime for this version.
+        if (Sel.isUnarySelector() && Sel.getNameForSlot(0) == "alloc")
----------------
Actually, I'd suggest just rewriting this comment to look like the next one, it conveys the same idea but much more succinctly.


================
Comment at: lib/CodeGen/CGObjC.cpp:390
+        if (Sel.isKeywordSelector() && Sel.getNumArgs() == 1 &&
+            Args.size() == 1 && Args.front().getKnownRValue().isScalar() &&
+            Sel.getNameForSlot(0) == "allocWithZone") {
----------------
You should check `!Args.front().hasLValue()` here before calling `getKnownRValue()`.  The test case would be some silly example where `-allocWithZone:` is declared with a parameter that's some big `struct` and the argument expression just loads it immediately from an l-value.  Or you could just check that the parameter type is a pointer type.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55349/new/

https://reviews.llvm.org/D55349





More information about the cfe-commits mailing list