llvm-project/llvm/lib/Transforms/ObjCARC
Akira Hatanaka 490397fc08 [ObjCARC] Do not sink an objc_retain past a clang.arc.use.
We need to do this to prevent a miscompile which sinks an objc_retain
past an objc_release that releases the object objc_retain retains. This
happens because the top-down and bottom-up traversals each determines
the insert point for retain or release individually without knowing
where the other instruction is moved.

For example, when the following IR is fed to the ARC optimizer, the
top-down traversal decides to insert objc_retain right before
objc_release and the bottom-up traversal decides to insert objc_release
right after clang.arc.use.

(IR before ARC optimizer)
%11 = call i8* @objc_retain(i8* %10)
call void (...) @clang.arc.use(%0* %5)
call void @llvm.dbg.value(...)
call void @objc_release(i8* %6)

This reverses the order of objc_release and objc_retain, which causes
the object to be destructed prematurely.

(IR after ARC optimizer)
call void (...) @clang.arc.use(%0* %5)
call void @objc_release(i8* %6)
call void @llvm.dbg.value(...)
%11 = call i8* @objc_retain(i8* %10)

rdar://problem/30530580

llvm-svn: 301289
2017-04-25 04:06:35 +00:00
..
ARCRuntimeEntryPoints.h Rename AttributeSet to AttributeList 2017-03-21 16:57:19 +00:00
BlotMapVector.h Unify XDEBUG and EXPENSIVE_CHECKS (into the latter), and add an option to the cmake build to enable them. 2016-04-29 15:22:48 +00:00
CMakeLists.txt [CMake] NFC. Updating CMake dependency specifications 2016-11-17 04:36:50 +00:00
DependencyAnalysis.cpp
DependencyAnalysis.h
LLVMBuild.txt
ObjCARC.cpp [NFC] Header cleanup 2016-04-18 09:17:29 +00:00
ObjCARC.h [NFC] Header cleanup 2016-04-18 09:17:29 +00:00
ObjCARCAPElim.cpp Re-commit optimization bisect support (r267022) without new pass manager support. 2016-04-22 22:06:11 +00:00
ObjCARCContract.cpp [ObjCArc] Do not dereference an invalidated iterator. 2017-04-05 03:44:09 +00:00
ObjCARCExpand.cpp [NFC] Header cleanup 2016-04-18 09:17:29 +00:00
ObjCARCOpts.cpp Remove redundant code. NFC. 2017-02-25 00:59:49 +00:00
ProvenanceAnalysis.cpp
ProvenanceAnalysis.h
ProvenanceAnalysisEvaluator.cpp
PtrState.cpp [ObjCARC] Do not sink an objc_retain past a clang.arc.use. 2017-04-25 04:06:35 +00:00
PtrState.h