Teach GlobalDCE how to remove empty global_ctor entries.
authorNico Weber <nicolasweber@gmx.de>
Fri, 2 May 2014 18:35:25 +0000 (18:35 +0000)
committerNico Weber <nicolasweber@gmx.de>
Fri, 2 May 2014 18:35:25 +0000 (18:35 +0000)
commit3a5b1043d0f672703381a0c5136c49486a619f91
tree6844d802ed30f03c5c0d93ebb99713a844a479db
parentd753e830cda1b1604a6527f81f76709039999fc4
Teach GlobalDCE how to remove empty global_ctor entries.

This moves most of GlobalOpt's constructor optimization
code out of GlobalOpt into Transforms/Utils/CDtorUtils.{h,cpp}. The
public interface is a single function OptimizeGlobalCtorsList() that
takes a predicate returning which constructors to remove.

GlobalOpt calls this with a function that statically evaluates all
constructors, just like it did before. This part of the change is
behavior-preserving.

Also add a call to this from GlobalDCE with a filter that removes global
constructors that contain a "ret" instruction and nothing else – this
fixes PR19590.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@207856 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Transforms/Utils/CtorUtils.h [new file with mode: 0644]
lib/Transforms/IPO/GlobalDCE.cpp
lib/Transforms/IPO/GlobalOpt.cpp
lib/Transforms/Utils/CMakeLists.txt
lib/Transforms/Utils/CtorUtils.cpp [new file with mode: 0644]
test/Transforms/GlobalDCE/global_ctors.ll [new file with mode: 0644]
test/Transforms/GlobalDCE/global_ctors_integration.ll [new file with mode: 0644]