diff --git a/src/bin/jbc2mpl b/src/bin/jbc2mpl index f90bee432eb5403cfa699018ac060b63ca18c677..745812e6c888ca39ac100e8c22bacd394ce67803 100755 Binary files a/src/bin/jbc2mpl and b/src/bin/jbc2mpl differ diff --git a/src/bin/maple b/src/bin/maple index 2048892b27c40933dc00dae2d23e60ce6fe3e121..5a8f245b538c63a13b2d8719b4a97853b6bf9c75 100755 Binary files a/src/bin/maple and b/src/bin/maple differ diff --git a/src/deplibs/libmplutil.a b/src/deplibs/libmplutil.a index f36e3829ab84c2e3c849fef9a2ac5e41633f2e64..616bd74788991ca6745a376b51ddd5676bee9818 100644 Binary files a/src/deplibs/libmplutil.a and b/src/deplibs/libmplutil.a differ diff --git a/src/maple_ipa/include/callgraph.h b/src/maple_ipa/include/callgraph.h index 2824957c0b383297d8558d431b6c8da4a24e3316..c963a836fd5decb074968756eb42eb2e74b9666d 100644 --- a/src/maple_ipa/include/callgraph.h +++ b/src/maple_ipa/include/callgraph.h @@ -170,7 +170,7 @@ class CGNode { return vcallCands; } - /* add caller to CGNode */ + // add caller to CGNode void AddCaller(CGNode *caller) { callerSet.insert(caller); } @@ -408,7 +408,7 @@ class CallGraph : public AnalysisResult { return mirModule->IsInIPA(); } - /* iterator */ + // iterator using iterator = MapleMap::iterator; iterator Begin() { return nodesMap.begin(); @@ -446,11 +446,11 @@ class CallGraph : public AnalysisResult { MIRBuilder *mirBuilder; CGNode *entryNode; // For main function, nullptr if there is multiple entries MapleVector rootNodes; - std::string fileName; /* used for output dot file */ + std::string fileName; // used for output dot file KlassHierarchy *klassh; MapleMap nodesMap; MapleVector sccTopologicalVec; - CGNode *callExternal = nullptr; /* Auxiliary node used in icall/intrinsic call */ + CGNode *callExternal = nullptr; // Auxiliary node used in icall/intrinsic call uint32 numOfNodes; uint32 numOfSccs; std::unordered_set callsiteHash; diff --git a/src/maple_ipa/src/callgraph.cpp b/src/maple_ipa/src/callgraph.cpp index 752e33a5697bff3c8e48f071999e860c2769b9b6..0ed22ff54fc6ac680cb33594e96a6591203ac117 100644 --- a/src/maple_ipa/src/callgraph.cpp +++ b/src/maple_ipa/src/callgraph.cpp @@ -582,7 +582,7 @@ void CallGraph::AddCallGraphNode(MIRFunction &func) { CHECK_FATAL(node != nullptr, "node is null in CallGraph::GenCallGraph"); BlockNode *body = func.GetBody(); HandleBody(func, *body, *node, 0); - /* set root if current function is static main */ + // set root if current function is static main if (func.GetName() == mirModule->GetEntryFuncName()) { mirModule->SetEntryFunction(&func); entryNode = node; @@ -1428,13 +1428,14 @@ bool SCCNode::HasSelfRecursion() const { } void SCCNode::Dump() const { - printf("SCC %d contains\n", id); + LogInfo::MapleLogger() << "SCC " << id << " contains\n"; for (auto const kIt : cgNodes) { CGNode *node = kIt; if (node->GetMIRFunction()) { - printf(" function(%d): %s\n", node->GetMIRFunction()->GetPuidx(), node->GetMIRFunction()->GetName().c_str()); + LogInfo::MapleLogger() << " function(" << node->GetMIRFunction()->GetPuidx() << "): " << + node->GetMIRFunction()->GetName() << "\n"; } else { - printf(" function: external\n"); + LogInfo::MapleLogger() << " function: external\n"; } } } @@ -1641,7 +1642,7 @@ void CallGraph::SCCTopologicalSort(const std::vector &sccNodes) { } void CGNode::AddCandsForCallNode(const KlassHierarchy &kh) { - /* already set vcall candidates information */ + // already set vcall candidates information if (HasSetVCallCandidates()) { return; } @@ -1662,7 +1663,7 @@ MIRFunction *CGNode::HasOneCandidate() const { ++count; cand = mirFunc; } - /* scan candidates */ + // scan candidates for (uint32 i = 0; i < vcallCands.size(); ++i) { if (vcallCands[i] == nullptr) { CHECK_FATAL(false, "must not be nullptr"); diff --git a/src/maple_ir/src/lexer.cpp b/src/maple_ir/src/lexer.cpp index cce8291a3f76d9e8e39c087934c2f7583fe12f48..d8bd9d0dee089100249406b154f53299f1e37ee1 100644 --- a/src/maple_ir/src/lexer.cpp +++ b/src/maple_ir/src/lexer.cpp @@ -219,6 +219,11 @@ TokenKind MIRLexer::GetIntConst(uint32 valStart, bool negative) { val = -val; } theIntVal = (theIntVal * hexValue) + val; + if (val < 0) { + ASSERT(theIntVal < 0, "int value overflow"); + } else if (val > 0) { + ASSERT(theIntVal > 0, "int value overflow"); + } c = GetNextCurrentCharWithUpperCheck(); } if (c == 'u' || c == 'U') { // skip 'u' or 'U' @@ -330,6 +335,7 @@ TokenKind MIRLexer::GetTokenWithPrefixPercent() { c = GetNextCurrentCharWithUpperCheck(); while (isdigit(c)) { theIntVal = (theIntVal * 10) + HexCharToDigit(c); + ASSERT(theIntVal >= 0, "int value overflow"); c = GetNextCurrentCharWithUpperCheck(); } name = line.substr(valStart, curIdx - valStart); diff --git a/src/maple_util/src/profile.cpp b/src/maple_util/src/profile.cpp index 94c86b029bfe70e68437bcf09c45195393d24f38..a46e751eaf8551beb1f2e955477f56f8cdaa8f64 100644 --- a/src/maple_util/src/profile.cpp +++ b/src/maple_util/src/profile.cpp @@ -500,6 +500,7 @@ void Profile::DumpFuncIRProfUseInfo() const { void Profile::Dump() const { std::ofstream outFile; outFile.open("prof.dump"); + CHECK_FATAL(!outFile.is_open(), "open file failed"); outFile << "classMeta profile start " <<'\n'; for (const auto &item : classMeta) { outFile << item << '\n';