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

Side by Side Diff: tools/llc/llc.cpp

Issue 12449014: ABI verifier: Add standalone tool pnacl-abicheck (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Created 7 years, 9 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
OLDNEW
1 //===-- llc.cpp - Implement the LLVM Native Code Generator ----------------===// 1 //===-- llc.cpp - Implement the LLVM Native Code Generator ----------------===//
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 is the llc code generator driver. It provides a convenient 10 // This is the llc code generator driver. It provides a convenient
11 // command-line interface for generating native assembly-language code 11 // command-line interface for generating native assembly-language code
12 // or C code, given LLVM bitcode. 12 // or C code, given LLVM bitcode.
13 // 13 //
14 //===----------------------------------------------------------------------===// 14 //===----------------------------------------------------------------------===//
15 15
16 #include "llvm/IR/LLVMContext.h" 16 #include "llvm/IR/LLVMContext.h"
17 #include "llvm/ADT/Triple.h" 17 #include "llvm/ADT/Triple.h"
18 #include "llvm/Analysis/NaCl.h"
18 #include "llvm/Assembly/PrintModulePass.h" 19 #include "llvm/Assembly/PrintModulePass.h"
19 #include "llvm/Support/DataStream.h" // @LOCALMOD 20 #include "llvm/Support/DataStream.h" // @LOCALMOD
20 #include "llvm/CodeGen/CommandFlags.h" 21 #include "llvm/CodeGen/CommandFlags.h"
21 #include "llvm/CodeGen/IntrinsicLowering.h" // @LOCALMOD 22 #include "llvm/CodeGen/IntrinsicLowering.h" // @LOCALMOD
22 #include "llvm/CodeGen/LinkAllAsmWriterComponents.h" 23 #include "llvm/CodeGen/LinkAllAsmWriterComponents.h"
23 #include "llvm/CodeGen/LinkAllCodegenComponents.h" 24 #include "llvm/CodeGen/LinkAllCodegenComponents.h"
24 #include "llvm/IR/DataLayout.h" 25 #include "llvm/IR/DataLayout.h"
25 #include "llvm/IR/Module.h" 26 #include "llvm/IR/Module.h"
26 #include "llvm/MC/SubtargetFeature.h" 27 #include "llvm/MC/SubtargetFeature.h"
27 #include "llvm/Pass.h" 28 #include "llvm/Pass.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 101
101 // The option below overlaps very much with bitcode streaming. 102 // The option below overlaps very much with bitcode streaming.
102 // We keep it separate because it is still experimental and we want 103 // We keep it separate because it is still experimental and we want
103 // to use it without changing the outside behavior which is especially 104 // to use it without changing the outside behavior which is especially
104 // relevant for the sandboxed case. 105 // relevant for the sandboxed case.
105 static cl::opt<bool> 106 static cl::opt<bool>
106 ReduceMemoryFootprint("reduce-memory-footprint", 107 ReduceMemoryFootprint("reduce-memory-footprint",
107 cl::desc("Aggressively reduce memory used by llc"), 108 cl::desc("Aggressively reduce memory used by llc"),
108 cl::init(false)); 109 cl::init(false));
109 110
111 static cl::opt<bool>
112 ABIVerify("pnaclabi-verify",
jvoung (off chromium) 2013/03/12 22:16:21 Maybe have the PNaCl prefix in the variable name t
Derek Schuff 2013/03/13 21:51:01 Done.
113 cl::desc("Verify PNaCl bitcode ABI before translating"),
114 cl::init(false));
110 // @LOCALMOD-END 115 // @LOCALMOD-END
111 116
112 // Determine optimization level. 117 // Determine optimization level.
113 static cl::opt<char> 118 static cl::opt<char>
114 OptLevel("O", 119 OptLevel("O",
115 cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] " 120 cl::desc("Optimization level. [-O0, -O1, -O2, or -O3] "
116 "(default = '-O2')"), 121 "(default = '-O2')"),
117 cl::Prefix, 122 cl::Prefix,
118 cl::ZeroOrMore, 123 cl::ZeroOrMore,
119 cl::init(' ')); 124 cl::init(' '));
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 #endif 344 #endif
340 // @LOCALMOD-END 345 // @LOCALMOD-END
341 346
342 mod = M.get(); 347 mod = M.get();
343 if (mod == 0) { 348 if (mod == 0) {
344 Err.print(argv[0], errs()); 349 Err.print(argv[0], errs());
345 return 1; 350 return 1;
346 } 351 }
347 352
348 // @LOCALMOD-BEGIN 353 // @LOCALMOD-BEGIN
354 if (ABIVerify) {
355 // Verify the module (but not the functions yet)
356 ModulePass* VerifyPass = createPNaClABIVerifyModulePass(true);
jvoung (off chromium) 2013/03/12 22:16:21 The Function pass is only added when __native_clie
Mark Seaborn 2013/03/12 22:25:56 Spacing should be " *"
Derek Schuff 2013/03/13 21:51:01 Done.
Derek Schuff 2013/03/13 21:51:01 Done.
357 VerifyPass->runOnModule(*mod);
358 }
349 #if defined(__native_client__) && defined(NACL_SRPC) 359 #if defined(__native_client__) && defined(NACL_SRPC)
350 RecordMetadataForSrpc(*mod); 360 RecordMetadataForSrpc(*mod);
351 361
352 // To determine if we should compile PIC or not, we needed to load at 362 // To determine if we should compile PIC or not, we needed to load at
353 // least the metadata. Since we've already constructed the commandline, 363 // least the metadata. Since we've already constructed the commandline,
354 // we have to hack this in after commandline processing. 364 // we have to hack this in after commandline processing.
355 if (mod->getOutputFormat() == Module::SharedOutputFormat) { 365 if (mod->getOutputFormat() == Module::SharedOutputFormat) {
356 RelocModel = Reloc::PIC_; 366 RelocModel = Reloc::PIC_;
357 } 367 }
358 // Also set PIC_ for dynamic executables: 368 // Also set PIC_ for dynamic executables:
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 } 557 }
548 if (!StopAfter.empty()) { 558 if (!StopAfter.empty()) {
549 const PassInfo *PI = PR->getPassInfo(StopAfter); 559 const PassInfo *PI = PR->getPassInfo(StopAfter);
550 if (!PI) { 560 if (!PI) {
551 errs() << argv[0] << ": stop-after pass is not registered.\n"; 561 errs() << argv[0] << ": stop-after pass is not registered.\n";
552 return 1; 562 return 1;
553 } 563 }
554 StopAfterID = PI->getTypeInfo(); 564 StopAfterID = PI->getTypeInfo();
555 } 565 }
556 566
567 // Add the ABI verifier pass before the code emission passes.
568 if (ABIVerify)
569 PM->add(createPNaClABIVerifyFunctionsPass(true));
570
557 // Ask the target to add backend passes as necessary. 571 // Ask the target to add backend passes as necessary.
558 if (Target.addPassesToEmitFile(*PM, FOS, FileType, NoVerify, 572 if (Target.addPassesToEmitFile(*PM, FOS, FileType, NoVerify,
559 StartAfterID, StopAfterID)) { 573 StartAfterID, StopAfterID)) {
560 errs() << argv[0] << ": target does not support generation of this" 574 errs() << argv[0] << ": target does not support generation of this"
561 << " file type!\n"; 575 << " file type!\n";
562 return 1; 576 return 1;
563 } 577 }
564 578
565 // Before executing passes, print the final values of the LLVM options. 579 // Before executing passes, print the final values of the LLVM options.
566 cl::PrintOptionValues(); 580 cl::PrintOptionValues();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 } 619 }
606 620
607 #if !defined(NACL_SRPC) 621 #if !defined(NACL_SRPC)
608 int 622 int
609 main (int argc, char **argv) { 623 main (int argc, char **argv) {
610 return llc_main(argc, argv); 624 return llc_main(argc, argv);
611 } 625 }
612 #else 626 #else
613 // main() is in nacl_file.cpp. 627 // main() is in nacl_file.cpp.
614 #endif 628 #endif
OLDNEW
« lib/Analysis/NaCl/PNaClABIVerifyModule.cpp ('K') | « lib/Analysis/NaCl/PNaClABIVerifyModule.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698