llvm/lib/Transforms
Michael Gottesman 0556900b26 [objc-arc] Do not mismatch up retains inside a for loop with releases outside said for loop in the presense of differing provenance caused by escaping blocks.
This occurs due to an alloca representing a separate ownership from the
original pointer. Thus consider the following pseudo-IR:

  objc_retain(%a)
  for (...) {
    objc_retain(%a)
    %block <- %a
    F(%block)
    objc_release(%block)
  }
  objc_release(%a)

From the perspective of the optimizer, the %block is a separate
provenance from the original %a. Thus the optimizer pairs up the inner
retain for %a and the outer release from %a, resulting in segfaults.

This is fixed by noting that the signature of a mismatch of
retain/releases inside the for loop is a Use/CanRelease top down with an
None bottom up (since bottom up the Retain-CanRelease-Use-Release
sequence is completed by the inner objc_retain, but top down due to the
differing provenance from the objc_release said sequence is not
completed). In said case in CheckForCFGHazards, we now clear the state
of %a implying that no pairing will occur.

Additionally a test case is included.

rdar://12969722

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179747 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-18 05:39:45 +00:00
..
Hello Move all of the header files which are involved in modelling the LLVM IR 2013-01-02 11:36:10 +00:00
InstCombine Reorders two transforms that collide with each other 2013-04-14 21:15:43 +00:00
Instrumentation [ASan] Allow disabling init-order checks for globals by source file name. 2013-04-11 13:20:00 +00:00
IPO We are not able to bitcast a pointer to an integral value. 2013-04-15 22:33:50 +00:00
ObjCARC [objc-arc] Do not mismatch up retains inside a for loop with releases outside said for loop in the presense of differing provenance caused by escaping blocks. 2013-04-18 05:39:45 +00:00
Scalar Fix a typo in comment. 2013-04-15 17:40:48 +00:00
Utils Do not optimise fprintf() calls if its return value is used. 2013-04-17 02:01:10 +00:00
Vectorize SLPVectorizer: Make it a function pass and add code for hoisting the vector-gather sequence out of loops. 2013-04-15 22:00:26 +00:00
CMakeLists.txt Extracted ObjCARC.cpp into its own library libLLVMObjCARCOpts in preparation for refactoring the ARC Optimizer. 2013-01-28 01:35:51 +00:00
LLVMBuild.txt Extracted ObjCARC.cpp into its own library libLLVMObjCARCOpts in preparation for refactoring the ARC Optimizer. 2013-01-28 01:35:51 +00:00
Makefile Extracted ObjCARC.cpp into its own library libLLVMObjCARCOpts in preparation for refactoring the ARC Optimizer. 2013-01-28 01:35:51 +00:00