aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/NaCl/PNaClLLC/lit.local.cfg1
-rw-r--r--test/NaCl/PNaClLLC/test-runs-verify.ll13
-rw-r--r--tools/pnacl-llc/pnacl-llc.cpp18
3 files changed, 29 insertions, 3 deletions
diff --git a/test/NaCl/PNaClLLC/lit.local.cfg b/test/NaCl/PNaClLLC/lit.local.cfg
new file mode 100644
index 0000000000..c6106e4746
--- /dev/null
+++ b/test/NaCl/PNaClLLC/lit.local.cfg
@@ -0,0 +1 @@
+config.suffixes = ['.ll']
diff --git a/test/NaCl/PNaClLLC/test-runs-verify.ll b/test/NaCl/PNaClLLC/test-runs-verify.ll
new file mode 100644
index 0000000000..9e7c9d32a5
--- /dev/null
+++ b/test/NaCl/PNaClLLC/test-runs-verify.ll
@@ -0,0 +1,13 @@
+; RUN: not pnacl-llc -mtriple=i386-unknown-nacl -filetype=asm %s -o - 2>&1 | FileCheck %s
+
+; Test that the Verifier pass is running in pnacl-llc.
+
+define i32 @f1(i32 %x) {
+ %y = add i32 %z, 1
+ %z = add i32 %x, 1
+ ret i32 %y
+; CHECK: Instruction does not dominate all uses!
+; CHECK-NEXT: %z = add i32 %x, 1
+; CHECK-NEXT: %y = add i32 %z, 1
+}
+
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";