From c1485223a688abe8a86e27529e86bd0fa885ceeb Mon Sep 17 00:00:00 2001 From: Richard Trieu Date: Sat, 21 Jun 2014 02:43:02 +0000 Subject: [PATCH] Add back functionality removed in r210497. Instead of asserting, output a message stating that a null pointer was found. llvm-svn: 211430 --- llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp | 6 ++++-- llvm/lib/Analysis/IVUsers.cpp | 6 ++++-- llvm/lib/Analysis/LoopPass.cpp | 6 ++++-- llvm/lib/Analysis/RegionPass.cpp | 6 ++++-- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp | 6 ++++-- llvm/lib/IR/Core.cpp | 14 ++++++++++---- llvm/lib/Transforms/Instrumentation/DebugIR.cpp | 6 ++++-- 7 files changed, 34 insertions(+), 16 deletions(-) diff --git a/llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp b/llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp index 0d9d0ef..730eb71 100644 --- a/llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp +++ b/llvm/lib/Analysis/IPA/CallGraphSCCPass.cpp @@ -603,8 +603,10 @@ namespace { bool runOnSCC(CallGraphSCC &SCC) override { Out << Banner; for (CallGraphSCC::iterator I = SCC.begin(), E = SCC.end(); I != E; ++I) { - assert((*I)->getFunction() && "Expecting non-null Function"); - (*I)->getFunction()->print(Out); + if ((*I)->getFunction()) + (*I)->getFunction()->print(Out); + else + Out << "Printing Function"; } return false; } diff --git a/llvm/lib/Analysis/IVUsers.cpp b/llvm/lib/Analysis/IVUsers.cpp index 0b94238..24655aa 100644 --- a/llvm/lib/Analysis/IVUsers.cpp +++ b/llvm/lib/Analysis/IVUsers.cpp @@ -287,8 +287,10 @@ void IVUsers::print(raw_ostream &OS, const Module *M) const { OS << ")"; } OS << " in "; - assert(UI->getUser() != nullptr && "Expected non-null User"); - UI->getUser()->print(OS); + if (UI->getUser()) + UI->getUser()->print(OS); + else + OS << "Printing User"; OS << '\n'; } } diff --git a/llvm/lib/Analysis/LoopPass.cpp b/llvm/lib/Analysis/LoopPass.cpp index 2c6e6e3..7bd866e 100644 --- a/llvm/lib/Analysis/LoopPass.cpp +++ b/llvm/lib/Analysis/LoopPass.cpp @@ -45,8 +45,10 @@ public: for (Loop::block_iterator b = L->block_begin(), be = L->block_end(); b != be; ++b) { - assert((*b) != nullptr && "Expecting non-null block"); - (*b)->print(Out); + if (*b) + (*b)->print(Out); + else + Out << "Printing block"; } return false; } diff --git a/llvm/lib/Analysis/RegionPass.cpp b/llvm/lib/Analysis/RegionPass.cpp index d11b332..71de144 100644 --- a/llvm/lib/Analysis/RegionPass.cpp +++ b/llvm/lib/Analysis/RegionPass.cpp @@ -196,8 +196,10 @@ public: bool runOnRegion(Region *R, RGPassManager &RGM) override { Out << Banner; for (const auto &BB : R->blocks()) { - assert(BB != nullptr && "Expecting non-null Block"); - BB->print(Out); + if (BB) + BB->print(Out); + else + Out << "Printing Block"; } return false; diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp index d30588e..799ee92 100644 --- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp @@ -1866,8 +1866,10 @@ static void emitGlobalConstantFP(const ConstantFP *CFP, AsmPrinter &AP) { SmallString<8> StrVal; CFP->getValueAPF().toString(StrVal); - assert(CFP->getType() != nullptr && "Expecting non-null Type"); - CFP->getType()->print(AP.OutStreamer.GetCommentOS()); + if (CFP->getType()) + CFP->getType()->print(AP.OutStreamer.GetCommentOS()); + else + AP.OutStreamer.GetCommentOS() << "Printing Type"; AP.OutStreamer.GetCommentOS() << ' ' << StrVal << '\n'; } diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index 68b9baa..0cb781c 100644 --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -281,8 +281,11 @@ char *LLVMPrintTypeToString(LLVMTypeRef Ty) { std::string buf; raw_string_ostream os(buf); - assert(unwrap(Ty) != nullptr && "Expecting non-null Type"); - unwrap(Ty)->print(os); + if (unwrap(Ty)) + unwrap(Ty)->print(os); + else + os << "Printing Type"; + os.flush(); return strdup(buf.c_str()); @@ -532,8 +535,11 @@ char* LLVMPrintValueToString(LLVMValueRef Val) { std::string buf; raw_string_ostream os(buf); - assert(unwrap(Val) != nullptr && "Expecting non-null Value"); - unwrap(Val)->print(os); + if (unwrap(Val)) + unwrap(Val)->print(os); + else + os << "Printing Value"; + os.flush(); return strdup(buf.c_str()); diff --git a/llvm/lib/Transforms/Instrumentation/DebugIR.cpp b/llvm/lib/Transforms/Instrumentation/DebugIR.cpp index 1bfef57..f2f1738 100644 --- a/llvm/lib/Transforms/Instrumentation/DebugIR.cpp +++ b/llvm/lib/Transforms/Instrumentation/DebugIR.cpp @@ -352,10 +352,12 @@ private: } std::string getTypeName(Type *T) { - assert(T != nullptr && "Expecting non-null Type"); std::string TypeName; raw_string_ostream TypeStream(TypeName); - T->print(TypeStream); + if (T) + T->print(TypeStream); + else + TypeStream << "Printing Type"; TypeStream.flush(); return TypeName; } -- 2.7.4