Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(304)

Side by Side Diff: tools/pnacl-abicheck/pnacl-abicheck.cpp

Issue 14329025: Check for metadata in PNaCl ABI checker. (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« tools/opt/opt.cpp ('K') | « tools/opt/opt.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===-- pnacl-abicheck.cpp - Check PNaCl bitcode ABI ----------------===// 1 //===-- pnacl-abicheck.cpp - Check PNaCl bitcode ABI ----------------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This tool checks files for compliance with the PNaCl bitcode ABI 10 // This tool checks files for compliance with the PNaCl bitcode ABI
11 // 11 //
12 //===----------------------------------------------------------------------===// 12 //===----------------------------------------------------------------------===//
13 13
14 #include "llvm/ADT/OwningPtr.h" 14 #include "llvm/ADT/OwningPtr.h"
15 #include "llvm/Analysis/NaCl.h" 15 #include "llvm/Analysis/NaCl.h"
16 #include "llvm/IR/LLVMContext.h" 16 #include "llvm/IR/LLVMContext.h"
17 #include "llvm/IR/Module.h" 17 #include "llvm/IR/Module.h"
18 #include "llvm/Pass.h" 18 #include "llvm/Pass.h"
19 #include "llvm/Support/CommandLine.h" 19 #include "llvm/Support/CommandLine.h"
20 #include "llvm/Support/FormattedStream.h" 20 #include "llvm/Support/FormattedStream.h"
21 #include "llvm/Support/IRReader.h" 21 #include "llvm/Support/IRReader.h"
22 #include <string> 22 #include <string>
23 23
24 using namespace llvm; 24 using namespace llvm;
25 25
26 static cl::opt<std::string> 26 static cl::opt<std::string>
27 InputFilename(cl::Positional, cl::desc("<input bitcode>"), cl::init("-")); 27 InputFilename(cl::Positional, cl::desc("<input bitcode>"), cl::init("-"));
28 28
29 static cl::opt<bool, false> 29 static cl::opt<bool>
30 Quiet("q", cl::desc("Do not print error messages")); 30 Quiet("q", cl::desc("Do not print error messages"));
31 31
32 static cl::opt<bool>
33 AllowDebugMetadata("allow-debug-metadata",
34 cl::desc("Allow debug metadata."));
35
36
32 // Print any errors collected by the error reporter. Return true if 37 // Print any errors collected by the error reporter. Return true if
33 // there were any. 38 // there were any.
34 static bool CheckABIVerifyErrors(PNaClABIErrorReporter &Reporter, 39 static bool CheckABIVerifyErrors(PNaClABIErrorReporter &Reporter,
35 const Twine &Name) { 40 const Twine &Name) {
36 bool HasErrors = Reporter.getErrorCount() > 0; 41 bool HasErrors = Reporter.getErrorCount() > 0;
37 if (HasErrors) { 42 if (HasErrors) {
38 if (!Quiet) { 43 if (!Quiet) {
39 outs() << "ERROR: " << Name << " is not valid PNaCl bitcode:\n"; 44 outs() << "ERROR: " << Name << " is not valid PNaCl bitcode:\n";
40 Reporter.printErrors(outs()); 45 Reporter.printErrors(outs());
41 } 46 }
(...skipping 10 matching lines...) Expand all
52 OwningPtr<Module> Mod(ParseIRFile(InputFilename, Err, Context)); 57 OwningPtr<Module> Mod(ParseIRFile(InputFilename, Err, Context));
53 if (Mod.get() == 0) { 58 if (Mod.get() == 0) {
54 Err.print(argv[0], errs()); 59 Err.print(argv[0], errs());
55 return 1; 60 return 1;
56 } 61 }
57 PNaClABIErrorReporter ABIErrorReporter; 62 PNaClABIErrorReporter ABIErrorReporter;
58 ABIErrorReporter.setNonFatal(); 63 ABIErrorReporter.setNonFatal();
59 bool ErrorsFound = false; 64 bool ErrorsFound = false;
60 // Manually run the passes so we can tell the user which function had the 65 // Manually run the passes so we can tell the user which function had the
61 // error. No need for a pass manager since it's just one pass. 66 // error. No need for a pass manager since it's just one pass.
62 OwningPtr<ModulePass> ModuleChecker(createPNaClABIVerifyModulePass(&ABIErrorRe porter)); 67 OwningPtr<ModulePass> ModuleChecker(
68 createPNaClABIVerifyModulePass(&ABIErrorReporter, AllowDebugMetadata));
63 ModuleChecker->runOnModule(*Mod); 69 ModuleChecker->runOnModule(*Mod);
64 ErrorsFound |= CheckABIVerifyErrors(ABIErrorReporter, "Module"); 70 ErrorsFound |= CheckABIVerifyErrors(ABIErrorReporter, "Module");
65 OwningPtr<FunctionPass> FunctionChecker( 71 OwningPtr<FunctionPass> FunctionChecker(
66 createPNaClABIVerifyFunctionsPass(&ABIErrorReporter)); 72 createPNaClABIVerifyFunctionsPass(&ABIErrorReporter,
73 AllowDebugMetadata));
67 for (Module::iterator MI = Mod->begin(), ME = Mod->end(); MI != ME; ++MI) { 74 for (Module::iterator MI = Mod->begin(), ME = Mod->end(); MI != ME; ++MI) {
68 FunctionChecker->runOnFunction(*MI); 75 FunctionChecker->runOnFunction(*MI);
69 ErrorsFound |= CheckABIVerifyErrors(ABIErrorReporter, 76 ErrorsFound |= CheckABIVerifyErrors(ABIErrorReporter,
70 "Function " + MI->getName()); 77 "Function " + MI->getName());
71 } 78 }
72 79
73 return ErrorsFound ? 1 : 0; 80 return ErrorsFound ? 1 : 0;
74 } 81 }
OLDNEW
« tools/opt/opt.cpp ('K') | « tools/opt/opt.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698