aboutsummaryrefslogtreecommitdiffstats
path: root/lib/Transforms/IPO
diff options
context:
space:
mode:
authorAnders Carlsson <andersca@mac.com>2011-03-21 14:54:40 +0000
committerAnders Carlsson <andersca@mac.com>2011-03-21 14:54:40 +0000
commitb12caf31f43eefc399eb2584225924d22cfd5b28 (patch)
tree42a96834d695314668d4bbafe2219cc3edeb5bd4 /lib/Transforms/IPO
parent3ce1b7d514d2898516106c8b2b843ae9386607ce (diff)
downloadexternal_llvm-b12caf31f43eefc399eb2584225924d22cfd5b28.zip
external_llvm-b12caf31f43eefc399eb2584225924d22cfd5b28.tar.gz
external_llvm-b12caf31f43eefc399eb2584225924d22cfd5b28.tar.bz2
More cleanups to the OptimizeEmptyGlobalCXXDtors GlobalOpt function.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127997 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO')
-rw-r--r--lib/Transforms/IPO/GlobalOpt.cpp24
1 files changed, 9 insertions, 15 deletions
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp
index d8212e8..7f69aeb 100644
--- a/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/lib/Transforms/IPO/GlobalOpt.cpp
@@ -2737,18 +2737,15 @@ static bool cxxDtorIsEmpty(const Function &Fn,
for (BasicBlock::const_iterator I = EntryBlock.begin(), E = EntryBlock.end();
I != E; ++I) {
if (const CallInst *CI = dyn_cast<CallInst>(I)) {
+ // Ignore debug intrinsics.
+ if (isa<DbgInfoIntrinsic>(CI))
+ continue;
+
const Function *CalledFn = CI->getCalledFunction();
if (!CalledFn)
return false;
- if (unsigned IntrinsicID = CalledFn->getIntrinsicID()) {
- // Ignore debug intrinsics.
- if (IntrinsicID == llvm::Intrinsic::dbg_declare ||
- IntrinsicID == llvm::Intrinsic::dbg_value)
- continue;
- }
-
// Don't treat recursive functions as empty.
if (!CalledFunctions.insert(CalledFn))
return false;
@@ -2783,18 +2780,15 @@ bool GlobalOpt::OptimizeEmptyGlobalCXXDtors(Function *CXAAtExitFn) {
for (Function::use_iterator I = CXAAtExitFn->use_begin(),
E = CXAAtExitFn->use_end(); I != E;) {
- CallSite CS(*I++);
- if (!CS)
- continue;
-
// We're only interested in calls. Theoretically, we could handle invoke
// instructions as well, but neither llvm-gcc nor clang generate invokes
// to __cxa_atexit.
- if (!CS.isCall())
+ CallInst *CI = dyn_cast<CallInst>(*I++);
+ if (!CI)
continue;
Function *DtorFn =
- dyn_cast<Function>(CS.getArgument(0)->stripPointerCasts());
+ dyn_cast<Function>(CI->getArgOperand(0)->stripPointerCasts());
if (!DtorFn)
continue;
@@ -2803,8 +2797,8 @@ bool GlobalOpt::OptimizeEmptyGlobalCXXDtors(Function *CXAAtExitFn) {
continue;
// Just remove the call.
- CS->replaceAllUsesWith(Constant::getNullValue(CS.getType()));
- CS->eraseFromParent();
+ CI->replaceAllUsesWith(Constant::getNullValue(CI->getType()));
+ CI->eraseFromParent();
++NumCXXDtorsRemoved;