[llvm-commits] [llvm] r127997 - /llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
Anders Carlsson
andersca at mac.com
Mon Mar 21 07:54:40 PDT 2011
Author: andersca
Date: Mon Mar 21 09:54:40 2011
New Revision: 127997
URL: http://llvm.org/viewvc/llvm-project?rev=127997&view=rev
Log:
More cleanups to the OptimizeEmptyGlobalCXXDtors GlobalOpt function.
Modified:
llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=127997&r1=127996&r2=127997&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Mon Mar 21 09:54:40 2011
@@ -2737,18 +2737,15 @@
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 @@
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 @@
continue;
// Just remove the call.
- CS->replaceAllUsesWith(Constant::getNullValue(CS.getType()));
- CS->eraseFromParent();
+ CI->replaceAllUsesWith(Constant::getNullValue(CI->getType()));
+ CI->eraseFromParent();
++NumCXXDtorsRemoved;
More information about the llvm-commits
mailing list