[PATCH] D34834: [objc] Don't require null-check and don't emit memset when result is ignored for struct-returning method calls

Kuba (Brecka) Mracek via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 29 13:35:40 PDT 2017


kubamracek created this revision.
kubamracek added a project: Sanitizers.

There's currently an issue with the emission of lifetime markers for struct-returning Obj-C msgSend calls.  The following code triggers an ASan use-after-scope report:

  MyClass *myNil = nil;  // intentionally nil
  [myNil methodWhichReturnsARect];

The reason is that when the result of a struct-returning call is ignore, the temporary storage is only marked with lifetime markers in one of the two branches of the nil-receiver-check.  The check is, however, not required when the result is unused.  If we still need to emit the check (due to consumer arguments), let's not emit the memset to zero out the result if it's unused.  This fixes the use-after-scope problem.


Repository:
  rL LLVM

https://reviews.llvm.org/D34834

Files:
  projects/compiler-rt/test/asan/TestCases/Darwin/nil-return-struct.mm
  tools/clang/lib/CodeGen/CGObjCMac.cpp
  tools/clang/test/CodeGenObjC/stret-1.m

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34834.104728.patch
Type: text/x-patch
Size: 5692 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170629/fe584350/attachment.bin>


More information about the llvm-commits mailing list