1349cc55cSDimitry Andric //===-- llvm-tli-checker.cpp - Compare TargetLibraryInfo to SDK libraries -===//
2349cc55cSDimitry Andric //
3349cc55cSDimitry Andric // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4349cc55cSDimitry Andric // See https://llvm.org/LICENSE.txt for license information.
5349cc55cSDimitry Andric // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6349cc55cSDimitry Andric //
7349cc55cSDimitry Andric //===----------------------------------------------------------------------===//
8349cc55cSDimitry Andric
9349cc55cSDimitry Andric #include "llvm/ADT/SmallString.h"
10349cc55cSDimitry Andric #include "llvm/ADT/StringMap.h"
11349cc55cSDimitry Andric #include "llvm/Analysis/TargetLibraryInfo.h"
12349cc55cSDimitry Andric #include "llvm/Config/llvm-config.h"
13349cc55cSDimitry Andric #include "llvm/Demangle/Demangle.h"
14349cc55cSDimitry Andric #include "llvm/Object/Archive.h"
15349cc55cSDimitry Andric #include "llvm/Object/ELFObjectFile.h"
16349cc55cSDimitry Andric #include "llvm/Option/ArgList.h"
17349cc55cSDimitry Andric #include "llvm/Option/Option.h"
18349cc55cSDimitry Andric #include "llvm/Support/FileSystem.h"
19349cc55cSDimitry Andric #include "llvm/Support/InitLLVM.h"
20349cc55cSDimitry Andric #include "llvm/Support/Path.h"
21349cc55cSDimitry Andric #include "llvm/Support/WithColor.h"
2206c3fb27SDimitry Andric #include "llvm/TargetParser/Triple.h"
23349cc55cSDimitry Andric
24349cc55cSDimitry Andric using namespace llvm;
25349cc55cSDimitry Andric using namespace llvm::object;
26349cc55cSDimitry Andric
27349cc55cSDimitry Andric // Command-line option boilerplate.
28349cc55cSDimitry Andric namespace {
29349cc55cSDimitry Andric enum ID {
30349cc55cSDimitry Andric OPT_INVALID = 0, // This is not an option ID.
31*5f757f3fSDimitry Andric #define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__),
32349cc55cSDimitry Andric #include "Opts.inc"
33349cc55cSDimitry Andric #undef OPTION
34349cc55cSDimitry Andric };
35349cc55cSDimitry Andric
36bdd1243dSDimitry Andric #define PREFIX(NAME, VALUE) \
37bdd1243dSDimitry Andric static constexpr StringLiteral NAME##_init[] = VALUE; \
38bdd1243dSDimitry Andric static constexpr ArrayRef<StringLiteral> NAME(NAME##_init, \
39bdd1243dSDimitry Andric std::size(NAME##_init) - 1);
40349cc55cSDimitry Andric #include "Opts.inc"
41349cc55cSDimitry Andric #undef PREFIX
42349cc55cSDimitry Andric
43*5f757f3fSDimitry Andric using namespace llvm::opt;
44bdd1243dSDimitry Andric static constexpr opt::OptTable::Info InfoTable[] = {
45*5f757f3fSDimitry Andric #define OPTION(...) LLVM_CONSTRUCT_OPT_INFO(__VA_ARGS__),
46349cc55cSDimitry Andric #include "Opts.inc"
47349cc55cSDimitry Andric #undef OPTION
48349cc55cSDimitry Andric };
49349cc55cSDimitry Andric
50bdd1243dSDimitry Andric class TLICheckerOptTable : public opt::GenericOptTable {
51349cc55cSDimitry Andric public:
TLICheckerOptTable()52bdd1243dSDimitry Andric TLICheckerOptTable() : GenericOptTable(InfoTable) {}
53349cc55cSDimitry Andric };
544824e7fdSDimitry Andric } // end anonymous namespace
55349cc55cSDimitry Andric
56349cc55cSDimitry Andric // We have three levels of reporting.
57349cc55cSDimitry Andric enum class ReportKind {
58349cc55cSDimitry Andric Error, // For argument parsing errors.
59349cc55cSDimitry Andric Summary, // Report counts but not details.
60349cc55cSDimitry Andric Discrepancy, // Report where TLI and the library differ.
61349cc55cSDimitry Andric Full // Report for every known-to-TLI function.
62349cc55cSDimitry Andric };
63349cc55cSDimitry Andric
64349cc55cSDimitry Andric // Most of the ObjectFile interfaces return an Expected<T>, so make it easy
654824e7fdSDimitry Andric // to ignore errors.
664824e7fdSDimitry Andric template <typename T>
unwrapIgnoreError(Expected<T> E,T Default=T ())674824e7fdSDimitry Andric static T unwrapIgnoreError(Expected<T> E, T Default = T()) {
68349cc55cSDimitry Andric if (E)
69349cc55cSDimitry Andric return std::move(*E);
70349cc55cSDimitry Andric // Sink the error and return a nothing value.
71349cc55cSDimitry Andric consumeError(E.takeError());
724824e7fdSDimitry Andric return Default;
73349cc55cSDimitry Andric }
74349cc55cSDimitry Andric
fail(const Twine & Message)75349cc55cSDimitry Andric static void fail(const Twine &Message) {
76349cc55cSDimitry Andric WithColor::error() << Message << '\n';
77349cc55cSDimitry Andric exit(EXIT_FAILURE);
78349cc55cSDimitry Andric }
79349cc55cSDimitry Andric
80349cc55cSDimitry Andric // Some problem occurred with an archive member; complain and continue.
reportArchiveChildIssue(const object::Archive::Child & C,int Index,StringRef ArchiveFilename)81349cc55cSDimitry Andric static void reportArchiveChildIssue(const object::Archive::Child &C, int Index,
82349cc55cSDimitry Andric StringRef ArchiveFilename) {
83349cc55cSDimitry Andric // First get the member name.
84349cc55cSDimitry Andric std::string ChildName;
85349cc55cSDimitry Andric Expected<StringRef> NameOrErr = C.getName();
86349cc55cSDimitry Andric if (NameOrErr)
87349cc55cSDimitry Andric ChildName = std::string(NameOrErr.get());
88349cc55cSDimitry Andric else {
89349cc55cSDimitry Andric // Ignore the name-fetch error, just report the index.
90349cc55cSDimitry Andric consumeError(NameOrErr.takeError());
91349cc55cSDimitry Andric ChildName = "<file index: " + std::to_string(Index) + ">";
92349cc55cSDimitry Andric }
93349cc55cSDimitry Andric
94349cc55cSDimitry Andric WithColor::warning() << ArchiveFilename << "(" << ChildName
95349cc55cSDimitry Andric << "): member is not usable\n";
96349cc55cSDimitry Andric }
97349cc55cSDimitry Andric
98349cc55cSDimitry Andric // Return Name, and if Name is mangled, append "aka" and the demangled name.
getPrintableName(StringRef Name)994824e7fdSDimitry Andric static std::string getPrintableName(StringRef Name) {
100349cc55cSDimitry Andric std::string OutputName = "'";
101349cc55cSDimitry Andric OutputName += Name;
102349cc55cSDimitry Andric OutputName += "'";
10306c3fb27SDimitry Andric std::string DemangledName(demangle(Name));
1044824e7fdSDimitry Andric if (Name != DemangledName) {
105349cc55cSDimitry Andric OutputName += " aka ";
1064824e7fdSDimitry Andric OutputName += DemangledName;
107349cc55cSDimitry Andric }
108349cc55cSDimitry Andric return OutputName;
109349cc55cSDimitry Andric }
110349cc55cSDimitry Andric
111349cc55cSDimitry Andric // Store all the names that TargetLibraryInfo knows about; the bool indicates
112349cc55cSDimitry Andric // whether TLI has it marked as "available" for the target of interest.
113349cc55cSDimitry Andric // This is a vector to preserve the sorted order for better reporting.
114349cc55cSDimitry Andric struct TLINameList : std::vector<std::pair<StringRef, bool>> {
115349cc55cSDimitry Andric // Record all the TLI info in the vector.
116349cc55cSDimitry Andric void initialize(StringRef TargetTriple);
117349cc55cSDimitry Andric // Print out what we found.
118349cc55cSDimitry Andric void dump();
119349cc55cSDimitry Andric };
1204824e7fdSDimitry Andric static TLINameList TLINames;
121349cc55cSDimitry Andric
initialize(StringRef TargetTriple)122349cc55cSDimitry Andric void TLINameList::initialize(StringRef TargetTriple) {
123349cc55cSDimitry Andric Triple T(TargetTriple);
124349cc55cSDimitry Andric TargetLibraryInfoImpl TLII(T);
125349cc55cSDimitry Andric TargetLibraryInfo TLI(TLII);
126349cc55cSDimitry Andric
127349cc55cSDimitry Andric reserve(LibFunc::NumLibFuncs);
128349cc55cSDimitry Andric size_t NumAvailable = 0;
129349cc55cSDimitry Andric for (unsigned FI = 0; FI != LibFunc::NumLibFuncs; ++FI) {
130349cc55cSDimitry Andric LibFunc LF = (LibFunc)FI;
131349cc55cSDimitry Andric bool Available = TLI.has(LF);
132349cc55cSDimitry Andric // getName returns names only for available funcs.
133349cc55cSDimitry Andric TLII.setAvailable(LF);
134349cc55cSDimitry Andric emplace_back(TLI.getName(LF), Available);
135349cc55cSDimitry Andric if (Available)
136349cc55cSDimitry Andric ++NumAvailable;
137349cc55cSDimitry Andric }
138349cc55cSDimitry Andric outs() << "TLI knows " << LibFunc::NumLibFuncs << " symbols, " << NumAvailable
139349cc55cSDimitry Andric << " available for '" << TargetTriple << "'\n";
140349cc55cSDimitry Andric }
141349cc55cSDimitry Andric
dump()142349cc55cSDimitry Andric void TLINameList::dump() {
143349cc55cSDimitry Andric // Assume this gets called after initialize(), so we have the above line of
144349cc55cSDimitry Andric // output as a header. So, for example, no need to repeat the triple.
145349cc55cSDimitry Andric for (auto &TLIName : TLINames) {
146349cc55cSDimitry Andric outs() << (TLIName.second ? " " : "not ")
1474824e7fdSDimitry Andric << "available: " << getPrintableName(TLIName.first) << '\n';
148349cc55cSDimitry Andric }
149349cc55cSDimitry Andric }
150349cc55cSDimitry Andric
151349cc55cSDimitry Andric // Store all the exported symbol names we found in the input libraries.
152349cc55cSDimitry Andric // We use a map to get hashed lookup speed; the bool is meaningless.
153349cc55cSDimitry Andric class SDKNameMap : public StringMap<bool> {
154bdd1243dSDimitry Andric void maybeInsertSymbol(const SymbolRef &S, const ObjectFile &O);
155349cc55cSDimitry Andric void populateFromObject(ObjectFile *O);
156349cc55cSDimitry Andric void populateFromArchive(Archive *A);
157349cc55cSDimitry Andric
158349cc55cSDimitry Andric public:
159349cc55cSDimitry Andric void populateFromFile(StringRef LibDir, StringRef LibName);
160349cc55cSDimitry Andric };
1614824e7fdSDimitry Andric static SDKNameMap SDKNames;
162349cc55cSDimitry Andric
163bdd1243dSDimitry Andric // Insert defined global function symbols into the map if valid.
maybeInsertSymbol(const SymbolRef & S,const ObjectFile & O)164bdd1243dSDimitry Andric void SDKNameMap::maybeInsertSymbol(const SymbolRef &S, const ObjectFile &O) {
165bdd1243dSDimitry Andric SymbolRef::Type Type = unwrapIgnoreError(S.getType());
166bdd1243dSDimitry Andric uint32_t Flags = unwrapIgnoreError(S.getFlags());
167bdd1243dSDimitry Andric section_iterator Section = unwrapIgnoreError(S.getSection(),
168bdd1243dSDimitry Andric /*Default=*/O.section_end());
169bdd1243dSDimitry Andric if (Type == SymbolRef::ST_Function && (Flags & SymbolRef::SF_Global) &&
170bdd1243dSDimitry Andric Section != O.section_end()) {
171bdd1243dSDimitry Andric StringRef Name = unwrapIgnoreError(S.getName());
172bdd1243dSDimitry Andric insert({ Name, true });
173bdd1243dSDimitry Andric }
174bdd1243dSDimitry Andric }
175bdd1243dSDimitry Andric
176349cc55cSDimitry Andric // Given an ObjectFile, extract the global function symbols.
populateFromObject(ObjectFile * O)177349cc55cSDimitry Andric void SDKNameMap::populateFromObject(ObjectFile *O) {
1784824e7fdSDimitry Andric // FIXME: Support other formats.
179349cc55cSDimitry Andric if (!O->isELF()) {
1804824e7fdSDimitry Andric WithColor::warning() << O->getFileName()
1814824e7fdSDimitry Andric << ": only ELF-format files are supported\n";
182349cc55cSDimitry Andric return;
183349cc55cSDimitry Andric }
1844824e7fdSDimitry Andric const auto *ELF = cast<ELFObjectFileBase>(O);
185349cc55cSDimitry Andric
186bdd1243dSDimitry Andric if (ELF->getEType() == ELF::ET_REL) {
187bdd1243dSDimitry Andric for (const auto &S : ELF->symbols())
188bdd1243dSDimitry Andric maybeInsertSymbol(S, *O);
189bdd1243dSDimitry Andric } else {
190bdd1243dSDimitry Andric for (const auto &S : ELF->getDynamicSymbolIterators())
191bdd1243dSDimitry Andric maybeInsertSymbol(S, *O);
192349cc55cSDimitry Andric }
193349cc55cSDimitry Andric }
194349cc55cSDimitry Andric
195349cc55cSDimitry Andric // Unpack an archive and populate from the component object files.
196349cc55cSDimitry Andric // This roughly imitates dumpArchive() from llvm-objdump.cpp.
populateFromArchive(Archive * A)197349cc55cSDimitry Andric void SDKNameMap::populateFromArchive(Archive *A) {
198349cc55cSDimitry Andric Error Err = Error::success();
199349cc55cSDimitry Andric int Index = -1;
200bdd1243dSDimitry Andric for (const auto &C : A->children(Err)) {
201349cc55cSDimitry Andric ++Index;
202349cc55cSDimitry Andric Expected<std::unique_ptr<object::Binary>> ChildOrErr = C.getAsBinary();
203349cc55cSDimitry Andric if (!ChildOrErr) {
204349cc55cSDimitry Andric if (auto E = isNotObjectErrorInvalidFileType(ChildOrErr.takeError())) {
205349cc55cSDimitry Andric // Issue a generic warning.
206349cc55cSDimitry Andric consumeError(std::move(E));
207349cc55cSDimitry Andric reportArchiveChildIssue(C, Index, A->getFileName());
208349cc55cSDimitry Andric }
209349cc55cSDimitry Andric continue;
210349cc55cSDimitry Andric }
211349cc55cSDimitry Andric if (ObjectFile *O = dyn_cast<ObjectFile>(&*ChildOrErr.get()))
212349cc55cSDimitry Andric populateFromObject(O);
213349cc55cSDimitry Andric // Ignore non-object archive members.
214349cc55cSDimitry Andric }
215349cc55cSDimitry Andric if (Err)
216349cc55cSDimitry Andric WithColor::defaultErrorHandler(std::move(Err));
217349cc55cSDimitry Andric }
218349cc55cSDimitry Andric
219349cc55cSDimitry Andric // Unpack a library file and extract the global function names.
populateFromFile(StringRef LibDir,StringRef LibName)220349cc55cSDimitry Andric void SDKNameMap::populateFromFile(StringRef LibDir, StringRef LibName) {
221349cc55cSDimitry Andric // Pick an arbitrary but reasonable default size.
222349cc55cSDimitry Andric SmallString<255> Filepath(LibDir);
223349cc55cSDimitry Andric sys::path::append(Filepath, LibName);
224349cc55cSDimitry Andric if (!sys::fs::exists(Filepath)) {
2254824e7fdSDimitry Andric WithColor::warning() << StringRef(Filepath) << ": not found\n";
226349cc55cSDimitry Andric return;
227349cc55cSDimitry Andric }
228349cc55cSDimitry Andric outs() << "\nLooking for symbols in '" << StringRef(Filepath) << "'\n";
229349cc55cSDimitry Andric auto ExpectedBinary = createBinary(Filepath);
230349cc55cSDimitry Andric if (!ExpectedBinary) {
231349cc55cSDimitry Andric // FIXME: Report this better.
232349cc55cSDimitry Andric WithColor::defaultWarningHandler(ExpectedBinary.takeError());
233349cc55cSDimitry Andric return;
234349cc55cSDimitry Andric }
235349cc55cSDimitry Andric OwningBinary<Binary> OBinary = std::move(*ExpectedBinary);
236349cc55cSDimitry Andric Binary &Binary = *OBinary.getBinary();
237349cc55cSDimitry Andric size_t Precount = size();
238349cc55cSDimitry Andric if (Archive *A = dyn_cast<Archive>(&Binary))
239349cc55cSDimitry Andric populateFromArchive(A);
240349cc55cSDimitry Andric else if (ObjectFile *O = dyn_cast<ObjectFile>(&Binary))
241349cc55cSDimitry Andric populateFromObject(O);
242349cc55cSDimitry Andric else {
2434824e7fdSDimitry Andric WithColor::warning() << StringRef(Filepath)
2444824e7fdSDimitry Andric << ": not an archive or object file\n";
245349cc55cSDimitry Andric return;
246349cc55cSDimitry Andric }
247349cc55cSDimitry Andric if (Precount == size())
2484824e7fdSDimitry Andric WithColor::warning() << StringRef(Filepath) << ": no symbols found\n";
249349cc55cSDimitry Andric else
250349cc55cSDimitry Andric outs() << "Found " << size() - Precount << " global function symbols in '"
251349cc55cSDimitry Andric << StringRef(Filepath) << "'\n";
252349cc55cSDimitry Andric }
253349cc55cSDimitry Andric
main(int argc,char * argv[])254349cc55cSDimitry Andric int main(int argc, char *argv[]) {
255349cc55cSDimitry Andric InitLLVM X(argc, argv);
256349cc55cSDimitry Andric BumpPtrAllocator A;
257349cc55cSDimitry Andric StringSaver Saver(A);
258349cc55cSDimitry Andric TLICheckerOptTable Tbl;
259349cc55cSDimitry Andric opt::InputArgList Args = Tbl.parseArgs(argc, argv, OPT_UNKNOWN, Saver,
260349cc55cSDimitry Andric [&](StringRef Msg) { fail(Msg); });
261349cc55cSDimitry Andric
262349cc55cSDimitry Andric if (Args.hasArg(OPT_help)) {
263349cc55cSDimitry Andric std::string Usage(argv[0]);
264349cc55cSDimitry Andric Usage += " [options] library-file [library-file...]";
265349cc55cSDimitry Andric Tbl.printHelp(outs(), Usage.c_str(),
266349cc55cSDimitry Andric "LLVM TargetLibraryInfo versus SDK checker");
267349cc55cSDimitry Andric outs() << "\nPass @FILE as argument to read options or library names from "
268349cc55cSDimitry Andric "FILE.\n";
269349cc55cSDimitry Andric return 0;
270349cc55cSDimitry Andric }
271349cc55cSDimitry Andric
272349cc55cSDimitry Andric TLINames.initialize(Args.getLastArgValue(OPT_triple_EQ));
273349cc55cSDimitry Andric
274349cc55cSDimitry Andric // --dump-tli doesn't require any input files.
275349cc55cSDimitry Andric if (Args.hasArg(OPT_dump_tli)) {
276349cc55cSDimitry Andric TLINames.dump();
277349cc55cSDimitry Andric return 0;
278349cc55cSDimitry Andric }
279349cc55cSDimitry Andric
280349cc55cSDimitry Andric std::vector<std::string> LibList = Args.getAllArgValues(OPT_INPUT);
2814824e7fdSDimitry Andric if (LibList.empty())
2824824e7fdSDimitry Andric fail("no input files\n");
283349cc55cSDimitry Andric StringRef LibDir = Args.getLastArgValue(OPT_libdir_EQ);
284349cc55cSDimitry Andric bool SeparateMode = Args.hasArg(OPT_separate);
285349cc55cSDimitry Andric
286349cc55cSDimitry Andric ReportKind ReportLevel =
287349cc55cSDimitry Andric SeparateMode ? ReportKind::Summary : ReportKind::Discrepancy;
288349cc55cSDimitry Andric if (const opt::Arg *A = Args.getLastArg(OPT_report_EQ)) {
289349cc55cSDimitry Andric ReportLevel = StringSwitch<ReportKind>(A->getValue())
290349cc55cSDimitry Andric .Case("summary", ReportKind::Summary)
291349cc55cSDimitry Andric .Case("discrepancy", ReportKind::Discrepancy)
292349cc55cSDimitry Andric .Case("full", ReportKind::Full)
293349cc55cSDimitry Andric .Default(ReportKind::Error);
2944824e7fdSDimitry Andric if (ReportLevel == ReportKind::Error)
2954824e7fdSDimitry Andric fail(Twine("invalid option for --report: ", StringRef(A->getValue())));
296349cc55cSDimitry Andric }
297349cc55cSDimitry Andric
298349cc55cSDimitry Andric for (size_t I = 0; I < LibList.size(); ++I) {
299349cc55cSDimitry Andric // In SeparateMode we report on input libraries individually; otherwise
300349cc55cSDimitry Andric // we do one big combined search. Reading to the end of LibList here
301349cc55cSDimitry Andric // will cause the outer while loop to terminate cleanly.
302349cc55cSDimitry Andric if (SeparateMode) {
303349cc55cSDimitry Andric SDKNames.clear();
304349cc55cSDimitry Andric SDKNames.populateFromFile(LibDir, LibList[I]);
305349cc55cSDimitry Andric if (SDKNames.empty())
306349cc55cSDimitry Andric continue;
307349cc55cSDimitry Andric } else {
308349cc55cSDimitry Andric do
309349cc55cSDimitry Andric SDKNames.populateFromFile(LibDir, LibList[I]);
310349cc55cSDimitry Andric while (++I < LibList.size());
311349cc55cSDimitry Andric if (SDKNames.empty()) {
312349cc55cSDimitry Andric WithColor::error() << "NO symbols found!\n";
313349cc55cSDimitry Andric break;
314349cc55cSDimitry Andric }
315349cc55cSDimitry Andric outs() << "Found a grand total of " << SDKNames.size()
316349cc55cSDimitry Andric << " library symbols\n";
317349cc55cSDimitry Andric }
318349cc55cSDimitry Andric unsigned TLIdoesSDKdoesnt = 0;
319349cc55cSDimitry Andric unsigned TLIdoesntSDKdoes = 0;
320349cc55cSDimitry Andric unsigned TLIandSDKboth = 0;
321349cc55cSDimitry Andric unsigned TLIandSDKneither = 0;
322349cc55cSDimitry Andric for (auto &TLIName : TLINames) {
323349cc55cSDimitry Andric bool TLIHas = TLIName.second;
324349cc55cSDimitry Andric bool SDKHas = SDKNames.count(TLIName.first) == 1;
325349cc55cSDimitry Andric int Which = int(TLIHas) * 2 + int(SDKHas);
326349cc55cSDimitry Andric switch (Which) {
327349cc55cSDimitry Andric case 0: ++TLIandSDKneither; break;
328349cc55cSDimitry Andric case 1: ++TLIdoesntSDKdoes; break;
329349cc55cSDimitry Andric case 2: ++TLIdoesSDKdoesnt; break;
330349cc55cSDimitry Andric case 3: ++TLIandSDKboth; break;
331349cc55cSDimitry Andric }
332349cc55cSDimitry Andric // If the results match, report only if user requested a full report.
333349cc55cSDimitry Andric ReportKind Threshold =
334349cc55cSDimitry Andric TLIHas == SDKHas ? ReportKind::Full : ReportKind::Discrepancy;
335349cc55cSDimitry Andric if (Threshold <= ReportLevel) {
336349cc55cSDimitry Andric constexpr char YesNo[2][4] = {"no ", "yes"};
337349cc55cSDimitry Andric constexpr char Indicator[4][3] = {"!!", ">>", "<<", "=="};
338349cc55cSDimitry Andric outs() << Indicator[Which] << " TLI " << YesNo[TLIHas] << " SDK "
3394824e7fdSDimitry Andric << YesNo[SDKHas] << ": " << getPrintableName(TLIName.first)
3404824e7fdSDimitry Andric << '\n';
341349cc55cSDimitry Andric }
342349cc55cSDimitry Andric }
343349cc55cSDimitry Andric
344349cc55cSDimitry Andric assert(TLIandSDKboth + TLIandSDKneither + TLIdoesSDKdoesnt +
345349cc55cSDimitry Andric TLIdoesntSDKdoes ==
346349cc55cSDimitry Andric LibFunc::NumLibFuncs);
34781ad6265SDimitry Andric (void) TLIandSDKneither;
348349cc55cSDimitry Andric outs() << "<< Total TLI yes SDK no: " << TLIdoesSDKdoesnt
349349cc55cSDimitry Andric << "\n>> Total TLI no SDK yes: " << TLIdoesntSDKdoes
350349cc55cSDimitry Andric << "\n== Total TLI yes SDK yes: " << TLIandSDKboth;
351349cc55cSDimitry Andric if (TLIandSDKboth == 0) {
352349cc55cSDimitry Andric outs() << " *** NO TLI SYMBOLS FOUND";
353349cc55cSDimitry Andric if (SeparateMode)
354349cc55cSDimitry Andric outs() << " in '" << LibList[I] << "'";
355349cc55cSDimitry Andric }
356349cc55cSDimitry Andric outs() << '\n';
357349cc55cSDimitry Andric
358349cc55cSDimitry Andric if (!SeparateMode) {
359349cc55cSDimitry Andric if (TLIdoesSDKdoesnt == 0 && TLIdoesntSDKdoes == 0)
360349cc55cSDimitry Andric outs() << "PASS: LLVM TLI matched SDK libraries successfully.\n";
361349cc55cSDimitry Andric else
362349cc55cSDimitry Andric outs() << "FAIL: LLVM TLI doesn't match SDK libraries.\n";
363349cc55cSDimitry Andric }
364349cc55cSDimitry Andric }
365349cc55cSDimitry Andric }
366