diff options
author | Roman Divacky <rdivacky@FreeBSD.org> | 2009-10-14 17:57:32 +0000 |
---|---|---|
committer | Roman Divacky <rdivacky@FreeBSD.org> | 2009-10-14 17:57:32 +0000 |
commit | 59850d0874429601812bc13408cb1f776649027c (patch) | |
tree | b21f6de4e08b89bb7931806bab798fc2a5e3a686 /tools/opt/AnalysisWrappers.cpp | |
parent | 18f153bdb9db52e7089a2d5293b96c45a3124a26 (diff) |
Diffstat (limited to 'tools/opt/AnalysisWrappers.cpp')
-rw-r--r-- | tools/opt/AnalysisWrappers.cpp | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/tools/opt/AnalysisWrappers.cpp b/tools/opt/AnalysisWrappers.cpp index 631a0ddbfb194..18360f837e93a 100644 --- a/tools/opt/AnalysisWrappers.cpp +++ b/tools/opt/AnalysisWrappers.cpp @@ -21,6 +21,7 @@ #include "llvm/Pass.h" #include "llvm/Support/CallSite.h" #include "llvm/Analysis/CallGraph.h" +#include "llvm/Support/raw_ostream.h" #include <iostream> using namespace llvm; @@ -33,27 +34,31 @@ namespace { static char ID; // Pass ID, replacement for typeid ExternalFunctionsPassedConstants() : ModulePass(&ID) {} virtual bool runOnModule(Module &M) { - for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) - if (I->isDeclaration()) { - bool PrintedFn = false; - for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); - UI != E; ++UI) - if (Instruction *User = dyn_cast<Instruction>(*UI)) { - CallSite CS = CallSite::get(User); - if (CS.getInstruction()) { - for (CallSite::arg_iterator AI = CS.arg_begin(), - E = CS.arg_end(); AI != E; ++AI) - if (isa<Constant>(*AI)) { - if (!PrintedFn) { - std::cerr << "Function '" << I->getName() << "':\n"; - PrintedFn = true; - } - std::cerr << *User; - break; - } - } + for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) { + if (!I->isDeclaration()) continue; + + bool PrintedFn = false; + for (Value::use_iterator UI = I->use_begin(), E = I->use_end(); + UI != E; ++UI) { + Instruction *User = dyn_cast<Instruction>(*UI); + if (!User) continue; + + CallSite CS = CallSite::get(User); + if (!CS.getInstruction()) continue; + + for (CallSite::arg_iterator AI = CS.arg_begin(), + E = CS.arg_end(); AI != E; ++AI) { + if (!isa<Constant>(*AI)) continue; + + if (!PrintedFn) { + errs() << "Function '" << I->getName() << "':\n"; + PrintedFn = true; } + errs() << *User; + break; + } } + } return false; } @@ -77,7 +82,7 @@ namespace { AU.addRequiredTransitive<CallGraph>(); } virtual bool runOnModule(Module &M) { - getAnalysis<CallGraph>().print(std::cerr, &M); + getAnalysis<CallGraph>().print(errs(), &M); return false; } }; |