aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorEli Bendersky <eliben@chromium.org>2013-07-15 08:23:06 -0700
committerEli Bendersky <eliben@chromium.org>2013-07-15 08:23:06 -0700
commitdceeed39b14cc9fc4748e82a67caab2e1d9caafa (patch)
tree7b5813dfd03acd5018c104d1dfea067f49f89480 /tools
parent4c1316ea42eb48ec8da6753f3e0319b676e50a75 (diff)
Run the LLVM IR verifier just once in pnacl-llc.
By default, using the path inherited from llc, the verifier is run twice. We only need it to run once right after reading the bitcode in and before the ABI verifier runs. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3553 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/18920004
Diffstat (limited to 'tools')
-rw-r--r--tools/pnacl-llc/pnacl-llc.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/tools/pnacl-llc/pnacl-llc.cpp b/tools/pnacl-llc/pnacl-llc.cpp
index 6292001ab1..b085a0be57 100644
--- a/tools/pnacl-llc/pnacl-llc.cpp
+++ b/tools/pnacl-llc/pnacl-llc.cpp
@@ -13,6 +13,7 @@
#include "llvm/ADT/Triple.h"
#include "llvm/Analysis/NaCl.h"
+#include "llvm/Analysis/Verifier.h"
#include "llvm/Assembly/PrintModulePass.h"
#include "llvm/Support/DataStream.h"
#include "llvm/Bitcode/NaCl/NaClReaderWriter.h"
@@ -428,6 +429,13 @@ static int compileModule(char **argv, LLVMContext &Context) {
else
PM.reset(new PassManager());
+ // For conformance with llc, we let the user disable LLVM IR verification with
+ // -disable-verify. Unlike llc, when LLVM IR verification is enabled we only
+ // run it once, before PNaCl ABI verification.
+ if (!NoVerify) {
+ PM->add(createVerifierPass());
+ }
+
// Add the ABI verifier pass before the analysis and code emission passes.
FunctionPass *FunctionVerifyPass = NULL;
if (PNaClABIVerify) {
@@ -470,8 +478,10 @@ static int compileModule(char **argv, LLVMContext &Context) {
ROS.SetBufferSize(1 << 20);
formatted_raw_ostream FOS(ROS);
- // Ask the target to add backend passes as necessary.
- if (Target.addPassesToEmitFile(*PM, FOS, FileType, NoVerify)) {
+ // Ask the target to add backend passes as necessary. We explicitly ask it
+ // not to add the verifier pass because we added it earlier.
+ if (Target.addPassesToEmitFile(*PM, FOS, FileType,
+ /* DisableVerify */ true)) {
errs() << argv[0] << ": target does not support generation of this"
<< " file type!\n";
return 1;
@@ -520,7 +530,9 @@ static int compileModule(char **argv, LLVMContext &Context) {
}
// Ask the target to add backend passes as necessary.
- if (Target.addPassesToEmitFile(*PM, FOS, FileType, NoVerify,
+ // TODO: decrease the amount of code duplication with __native_client__
+ if (Target.addPassesToEmitFile(*PM, FOS, FileType,
+ /* DisableVerify */ true,
StartAfterID, StopAfterID)) {
errs() << argv[0] << ": target does not support generation of this"
<< " file type!\n";