Modify pnacl subzero to be able to read pnacl bitcode files.

BUG=None
R=jfb@chromium.org, stichnot@chromium.org

Review URL: https://codereview.chromium.org/277033003
diff --git a/llvm2iceinsts.py b/llvm2iceinsts.py
new file mode 100755
index 0000000..b04505f
--- /dev/null
+++ b/llvm2iceinsts.py
@@ -0,0 +1,68 @@
+#!/usr/bin/env python2
+
+import argparse
+import itertools
+import os
+import re
+import subprocess
+import sys
+
+for p in sys.path:
+    if p.endswith('/toolchain_build/src/pnacl-subzero'):
+        sys.path.insert(0, p + '/pydir')
+        break
+
+from utils import shellcmd
+
+if __name__ == '__main__':
+    desc = 'Run llvm2ice on llvm file to produce ICE instructions.'
+    argparser = argparse.ArgumentParser(
+        description=desc,
+        formatter_class=argparse.ArgumentDefaultsHelpFormatter,
+        epilog='''
+        Runs in two modes, depending on whether the flag '--pnacl' is specified.
+
+        If flag '--pnacl' is omitted, it runs llvm2ice to (directly) generate
+        the corresponding ICE instructions.
+
+        If flag '--pnacl' is given, it first assembles and freezes the
+        llvm source file generating the corresponding PNaCl bitcode
+        file. The PNaCl bitcode file is then piped into llvm2ice to
+        generate the corresponding ICE instructions.
+        ''')
+    argparser.add_argument(
+        '--llvm2ice', required=False, default='./llvm2ice', metavar='LLVM2ICE',
+        help='Path to llvm2ice driver program')
+    argparser.add_argument('--llvm-bin-path', required=False,
+                           default=None, metavar='LLVM_BIN_PATH',
+                           help='Path to LLVM executables ' +
+                                '(for building PNaCl files)')
+    argparser.add_argument('--pnacl', required=False,
+                           action='store_true',
+                           help='Convert llvm source to PNaCl bitcode ' +
+                                'file first')
+    argparser.add_argument('--echo-cmd', required=False,
+                           action='store_true',
+                           help='Trace command that generates ICE instructions')
+    argparser.add_argument('llfile', nargs=1,
+                           metavar='LLVM_FILE',
+                           help='Llvm source file')
+
+    args = argparser.parse_args()
+    llvm_bin_path = args.llvm_bin_path
+    llfile = args.llfile[0]
+
+    cmd = []
+    if args.pnacl:
+      cmd = [os.path.join(llvm_bin_path, 'llvm-as'), llfile, '-o', '-', '|',
+             os.path.join(llvm_bin_path, 'pnacl-freeze'),
+             '--allow-local-symbol-tables', '|']
+    cmd += [args.llvm2ice, '-verbose', 'inst', '-notranslate']
+    if args.pnacl:
+      cmd += ['--allow-local-symbol-tables', '--bitcode-format=pnacl']
+    else:
+      cmd.append(llfile)
+
+    stdout_result = shellcmd(cmd, echo=args.echo_cmd)
+    if not args.echo_cmd:
+      sys.stdout.write(stdout_result)
diff --git a/pydir/utils.py b/pydir/utils.py
new file mode 100644
index 0000000..57849a4
--- /dev/null
+++ b/pydir/utils.py
@@ -0,0 +1,12 @@
+import subprocess
+import sys
+
+def shellcmd(command, echo=True):
+    if echo: print '[cmd]', command
+
+    if not isinstance(command, str):
+        command = ' '.join(command)
+
+    stdout_result = subprocess.check_output(command, shell=True)
+    if echo: sys.stdout.write(stdout_result)
+    return stdout_result
diff --git a/src/llvm2ice.cpp b/src/llvm2ice.cpp
index df9061b..7136331 100644
--- a/src/llvm2ice.cpp
+++ b/src/llvm2ice.cpp
@@ -577,7 +577,7 @@
         clEnumValN(Ice::IceV_All, "all", "Use all verbose options"),
         clEnumValN(Ice::IceV_None, "none", "No verbosity"), clEnumValEnd));
 static cl::opt<std::string> IRFilename(cl::Positional, cl::desc("<IR file>"),
-                                       cl::Required);
+                                       cl::init("-"));
 static cl::opt<std::string> OutputFilename("o",
                                            cl::desc("Override output filename"),
                                            cl::init("-"),
@@ -594,6 +594,16 @@
 static cl::opt<bool> SubzeroTimingEnabled(
     "timing", cl::desc("Enable breakdown timing of Subzero translation"));
 
+static cl::opt<NaClFileFormat>
+InputFileFormat(
+    "bitcode-format",
+    cl::desc("Define format of input file:"),
+    cl::values(
+        clEnumValN(LLVMFormat, "llvm", "LLVM file (default)"),
+        clEnumValN(PNaClFormat, "pnacl", "PNaCl bitcode file"),
+        clEnumValEnd),
+    cl::init(LLVMFormat));
+
 int main(int argc, char **argv) {
   cl::ParseCommandLineOptions(argc, argv);
 
@@ -603,7 +613,7 @@
 
   {
     Ice::Timer T;
-    Mod = ParseIRFile(IRFilename, Err, getGlobalContext());
+    Mod = NaClParseIRFile(IRFilename, InputFileFormat, Err, getGlobalContext());
 
     if (SubzeroTimingEnabled) {
       std::cerr << "[Subzero timing] IR Parsing: " << T.getElapsedSec()
diff --git a/szdiff.py b/szdiff.py
index f2696e8..9b8d613 100755
--- a/szdiff.py
+++ b/szdiff.py
@@ -2,45 +2,40 @@
 
 import argparse
 import itertools
-import subprocess
 import re
 
 if __name__ == '__main__':
-    """Runs llvm2ice on an input .ll file, and compares the output
-    against the input.
+    """Compares a LLVM file with a subzero file for differences.
 
-    Before comparing, the input file is massaged to remove comments,
+    Before comparing, the LLVM file is massaged to remove comments,
     blank lines, global variable definitions, external function
     declarations, and possibly other patterns that llvm2ice does not
     handle.
 
-    The output file and the massaged input file are compared line by
+    The subzero file and the massaged LLVM file are compared line by
     line for differences.  However, there is a regex defined such that
-    if the regex matches a line in the input file, that line and the
-    corresponding line in the output file are ignored.  This lets us
+    if the regex matches a line in the LLVM file, that line and the
+    corresponding line in the subzero file are ignored.  This lets us
     ignore minor differences such as inttoptr and ptrtoint, and
     printing of floating-point constants.
 
     On success, no output is produced.  On failure, each mismatch is
-    printed as two lines, one starting with 'SZ' and one starting with
-    'LL'.
+    printed as two lines, one starting with 'SZ' (subzero) and one
+    starting with 'LL' (LLVM).
     """
-    desc = 'Compare llvm2ice output against bitcode input.'
+    desc = 'Compare LLVM and subzero bitcode files.'
     argparser = argparse.ArgumentParser(description=desc)
     argparser.add_argument(
-        'llfile', nargs='?', default='-',
-        type=argparse.FileType('r'), metavar='FILE',
-        help='Textual bitcode file [default stdin]')
+        'llfile', nargs=1,
+        type=argparse.FileType('r'), metavar='LLVM_FILE',
+        help='LLVM bitcode file')
     argparser.add_argument(
-        '--llvm2ice', required=False, default='./llvm2ice', metavar='LLVM2ICE',
-        help='Path to llvm2ice driver program [default ./llvm2ice]')
+        'szfile', nargs='?', default='-',
+        type=argparse.FileType('r'), metavar='SUBZERO_FILE',
+        help='Subzero bitcode file [default stdin]')
     args = argparser.parse_args()
-    bitcode = args.llfile.readlines()
-
-    # Run llvm2ice and collect its output lines into sz_out.
-    command = [args.llvm2ice, '-verbose', 'inst', '-notranslate', '-']
-    p = subprocess.Popen(command, stdin=subprocess.PIPE, stdout=subprocess.PIPE)
-    sz_out = p.communicate(input=''.join(bitcode))[0].splitlines()
+    bitcode = args.llfile[0].readlines()
+    sz_out = [ line.rstrip() for line in args.szfile.readlines()]
 
     # Filter certain lines and patterns from the input, and collect
     # the remainder into llc_out.
@@ -63,11 +58,12 @@
     lines_total = 0
     lines_diff = 0
     ignore_pattern = re.compile(
-        '|'.join([' -[0-9]',                # negative constants
-                  ' (float|double) [-0-9]', # FP constants
+        '|'.join([' -[0-9]',                 # negative constants
+                  ' (float|double) [-0-9]',  # FP constants
                   ' (float|double) %\w+, [-0-9]',
-                  ' inttoptr ',             # inttoptr pointer types
-                  ' ptrtoint '              # ptrtoint pointer types
+                  ' inttoptr ',              # inttoptr pointer types
+                  ' ptrtoint ',              # ptrtoint pointer types
+                  ' bitcast .*\* .* to .*\*' # bitcast pointer types
                   ]))
     for (sz_line, llc_line) in itertools.izip_longest(sz_out, llc_out):
         lines_total += 1
diff --git a/tests_lit/lit.cfg b/tests_lit/lit.cfg
index 171517d..d1d15bf 100644
--- a/tests_lit/lit.cfg
+++ b/tests_lit/lit.cfg
@@ -32,7 +32,13 @@
 llvmbinpath = os.path.abspath(os.environ.get('LLVM_BIN_PATH'))
 
 # Finding Subzero tools
-config.substitutions.append(('%llvm2ice', os.path.join(bin_root, 'llvm2ice')))
+llvm2icetool = os.path.join(bin_root, 'llvm2ice')
+config.substitutions.append(
+  ('%llvm2iceinsts', ' '.join([os.path.join(bin_root, 'llvm2iceinsts.py'),
+                               '--llvm2ice', llvm2icetool,
+                               '--llvm-bin-path', llvmbinpath
+                             ])))
+config.substitutions.append(('%llvm2ice', llvm2icetool))
 config.substitutions.append(('%szdiff', os.path.join(bin_root, 'szdiff.py')))
 
 llvmbintools = ['FileCheck']
diff --git a/tests_lit/llvm2ice_tests/64bit.pnacl.ll b/tests_lit/llvm2ice_tests/64bit.pnacl.ll
index 4b79fd1..761f388 100644
--- a/tests_lit/llvm2ice_tests/64bit.pnacl.ll
+++ b/tests_lit/llvm2ice_tests/64bit.pnacl.ll
@@ -1,6 +1,8 @@
 ; RUIN: %llvm2ice --verbose none %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 @__init_array_start = internal constant [0 x i8] zeroinitializer, align 4
 @__fini_array_start = internal constant [0 x i8] zeroinitializer, align 4
@@ -719,8 +721,8 @@
 
 define internal i64 @load64(i32 %a) {
 entry:
-  %a.asptr = inttoptr i32 %a to i64*
-  %v0 = load i64* %a.asptr, align 1
+  %__1 = inttoptr i32 %a to i64*
+  %v0 = load i64* %__1, align 1
   ret i64 %v0
 }
 ; CHECK: load64:
@@ -730,8 +732,8 @@
 
 define internal void @store64(i32 %a, i64 %value) {
 entry:
-  %a.asptr = inttoptr i32 %a to i64*
-  store i64 %value, i64* %a.asptr, align 1
+  %__2 = inttoptr i32 %a to i64*
+  store i64 %value, i64* %__2, align 1
   ret void
 }
 ; CHECK: store64:
diff --git a/tests_lit/llvm2ice_tests/alloc.ll b/tests_lit/llvm2ice_tests/alloc.ll
index f7a2040..b2f90e4 100644
--- a/tests_lit/llvm2ice_tests/alloc.ll
+++ b/tests_lit/llvm2ice_tests/alloc.ll
@@ -1,12 +1,14 @@
 ; RUIN: %llvm2ice --verbose none %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 define void @fixed_400(i32 %n) {
 entry:
   %array = alloca i8, i32 400, align 16
-  %array.asint = ptrtoint i8* %array to i32
-  call void @f1(i32 %array.asint)
+  %__2 = ptrtoint i8* %array to i32
+  call void @f1(i32 %__2)
   ret void
   ; CHECK:      sub     esp, 400
   ; CHECK-NEXT: mov     eax, esp
@@ -19,8 +21,8 @@
 define void @variable_n(i32 %n) {
 entry:
   %array = alloca i8, i32 %n, align 16
-  %array.asint = ptrtoint i8* %array to i32
-  call void @f2(i32 %array.asint)
+  %__2 = ptrtoint i8* %array to i32
+  call void @f2(i32 %__2)
   ret void
   ; CHECK:      mov     eax, dword ptr [ebp+8]
   ; CHECK-NEXT: sub     esp, eax
diff --git a/tests_lit/llvm2ice_tests/arith-opt.ll b/tests_lit/llvm2ice_tests/arith-opt.ll
index becbc9f..f080125 100644
--- a/tests_lit/llvm2ice_tests/arith-opt.ll
+++ b/tests_lit/llvm2ice_tests/arith-opt.ll
@@ -1,6 +1,8 @@
 ; RUIN: %llvm2ice -verbose inst %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 define i32 @Add(i32 %a, i32 %b) {
 ; CHECK: define i32 @Add
diff --git a/tests_lit/llvm2ice_tests/arithmetic-chain.ll b/tests_lit/llvm2ice_tests/arithmetic-chain.ll
index 3ca1ad0..2609ef7 100644
--- a/tests_lit/llvm2ice_tests/arithmetic-chain.ll
+++ b/tests_lit/llvm2ice_tests/arithmetic-chain.ll
@@ -1,6 +1,8 @@
 ; RUIN: %llvm2ice -verbose inst %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 define i64 @arithmetic_chain(i64 %foo, i64 %bar) {
 entry:
diff --git a/tests_lit/llvm2ice_tests/bitcast.ll b/tests_lit/llvm2ice_tests/bitcast.ll
index 1a6623f..c180c87 100644
--- a/tests_lit/llvm2ice_tests/bitcast.ll
+++ b/tests_lit/llvm2ice_tests/bitcast.ll
@@ -1,6 +1,8 @@
 ; RUIN: %llvm2ice -verbose inst %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 define internal i32 @cast_f2i(float %f) {
 entry:
diff --git a/tests_lit/llvm2ice_tests/bool-opt.ll b/tests_lit/llvm2ice_tests/bool-opt.ll
index 787228c..3078615 100644
--- a/tests_lit/llvm2ice_tests/bool-opt.ll
+++ b/tests_lit/llvm2ice_tests/bool-opt.ll
@@ -1,6 +1,8 @@
 ; RUIN: %llvm2ice -verbose inst %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 define void @testBool(i32 %a, i32 %b) {
 entry:
diff --git a/tests_lit/llvm2ice_tests/branch-simple.ll b/tests_lit/llvm2ice_tests/branch-simple.ll
index 502287a..201238e 100644
--- a/tests_lit/llvm2ice_tests/branch-simple.ll
+++ b/tests_lit/llvm2ice_tests/branch-simple.ll
@@ -1,6 +1,8 @@
 ; RUIN: %llvm2ice %s -verbose inst | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 define i32 @simple_cond_branch(i32 %foo, i32 %bar) {
 entry:
diff --git a/tests_lit/llvm2ice_tests/call.ll b/tests_lit/llvm2ice_tests/call.ll
index 6503dec..c029789 100644
--- a/tests_lit/llvm2ice_tests/call.ll
+++ b/tests_lit/llvm2ice_tests/call.ll
@@ -1,6 +1,8 @@
 ; RUIN: %llvm2ice -verbose inst %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 define i32 @fib(i32 %n) {
 ; CHECK: define i32 @fib
diff --git a/tests_lit/llvm2ice_tests/callindirect.pnacl.ll b/tests_lit/llvm2ice_tests/callindirect.pnacl.ll
index d07ad77..10b0aba 100644
--- a/tests_lit/llvm2ice_tests/callindirect.pnacl.ll
+++ b/tests_lit/llvm2ice_tests/callindirect.pnacl.ll
@@ -1,6 +1,8 @@
 ; RUIN: %llvm2ice --verbose none %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 @__init_array_start = internal constant [0 x i8] zeroinitializer, align 4
 @__fini_array_start = internal constant [0 x i8] zeroinitializer, align 4
@@ -9,12 +11,12 @@
 
 define internal void @CallIndirect(i32 %f) {
 entry:
-  %f.asptr = inttoptr i32 %f to void ()*
-  call void %f.asptr()
-  call void %f.asptr()
-  call void %f.asptr()
-  call void %f.asptr()
-  call void %f.asptr()
+  %__1 = inttoptr i32 %f to void ()*
+  call void %__1()
+  call void %__1()
+  call void %__1()
+  call void %__1()
+  call void %__1()
   ret void
 }
 ; CHECK: call [[REGISTER:[a-z]+]]
diff --git a/tests_lit/llvm2ice_tests/casts.ll b/tests_lit/llvm2ice_tests/casts.ll
index a9617ae..0849fb2 100644
--- a/tests_lit/llvm2ice_tests/casts.ll
+++ b/tests_lit/llvm2ice_tests/casts.ll
@@ -1,6 +1,8 @@
 ; RUIN: %llvm2ice -verbose inst %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 define i64 @simple_zext(i32 %arg) {
 entry:
diff --git a/tests_lit/llvm2ice_tests/cmp-opt.ll b/tests_lit/llvm2ice_tests/cmp-opt.ll
index 15aee2a..124630d 100644
--- a/tests_lit/llvm2ice_tests/cmp-opt.ll
+++ b/tests_lit/llvm2ice_tests/cmp-opt.ll
@@ -1,6 +1,8 @@
 ; RUIN: %llvm2ice %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 define void @testBool(i32 %a, i32 %b) {
 entry:
diff --git a/tests_lit/llvm2ice_tests/convert.ll b/tests_lit/llvm2ice_tests/convert.ll
index 53a1de4..b5655cc 100644
--- a/tests_lit/llvm2ice_tests/convert.ll
+++ b/tests_lit/llvm2ice_tests/convert.ll
@@ -1,29 +1,31 @@
 ; RUIN: %llvm2ice %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
-@i8v = common global i8 0, align 1
-@i16v = common global i16 0, align 2
-@i32v = common global i32 0, align 4
-@i64v = common global i64 0, align 8
-@u8v = common global i8 0, align 1
-@u16v = common global i16 0, align 2
-@u32v = common global i32 0, align 4
-@u64v = common global i64 0, align 8
-@i1 = common global i32 0, align 4
-@i2 = common global i32 0, align 4
-@u1 = common global i32 0, align 4
-@u2 = common global i32 0, align 4
+@i8v = global [1 x i8] zeroinitializer, align 1
+@i16v = global [2 x i8] zeroinitializer, align 2
+@i32v = global [4 x i8] zeroinitializer, align 4
+@i64v = global [8 x i8] zeroinitializer, align 8
+@u8v = global [1 x i8] zeroinitializer, align 1
+@u16v = global [2 x i8] zeroinitializer, align 2
+@u32v = global [4 x i8] zeroinitializer, align 4
+@u64v = global [8 x i8] zeroinitializer, align 8
 
 define void @from_int8() {
 entry:
-  %v0 = load i8* @i8v, align 1
+  %__0 = bitcast [1 x i8]* @i8v to i8*
+  %v0 = load i8* %__0, align 1
   %v1 = sext i8 %v0 to i16
-  store i16 %v1, i16* @i16v, align 1
+  %__3 = bitcast [2 x i8]* @i16v to i16*
+  store i16 %v1, i16* %__3, align 1
   %v2 = sext i8 %v0 to i32
-  store i32 %v2, i32* @i32v, align 1
+  %__5 = bitcast [4 x i8]* @i32v to i32*
+  store i32 %v2, i32* %__5, align 1
   %v3 = sext i8 %v0 to i64
-  store i64 %v3, i64* @i64v, align 1
+  %__7 = bitcast [8 x i8]* @i64v to i64*
+  store i64 %v3, i64* %__7, align 1
   ret void
   ; CHECK: mov al, byte ptr [
   ; CHECK-NEXT: movsx cx, al
@@ -38,13 +40,17 @@
 
 define void @from_int16() {
 entry:
-  %v0 = load i16* @i16v, align 1
+  %__0 = bitcast [2 x i8]* @i16v to i16*
+  %v0 = load i16* %__0, align 1
   %v1 = trunc i16 %v0 to i8
-  store i8 %v1, i8* @i8v, align 1
+  %__3 = bitcast [1 x i8]* @i8v to i8*
+  store i8 %v1, i8* %__3, align 1
   %v2 = sext i16 %v0 to i32
-  store i32 %v2, i32* @i32v, align 1
+  %__5 = bitcast [4 x i8]* @i32v to i32*
+  store i32 %v2, i32* %__5, align 1
   %v3 = sext i16 %v0 to i64
-  store i64 %v3, i64* @i64v, align 1
+  %__7 = bitcast [8 x i8]* @i64v to i64*
+  store i64 %v3, i64* %__7, align 1
   ret void
   ; CHECK: mov ax, word ptr [
   ; CHECK-NEXT: mov cx, ax
@@ -59,13 +65,17 @@
 
 define void @from_int32() {
 entry:
-  %v0 = load i32* @i32v, align 1
+  %__0 = bitcast [4 x i8]* @i32v to i32*
+  %v0 = load i32* %__0, align 1
   %v1 = trunc i32 %v0 to i8
-  store i8 %v1, i8* @i8v, align 1
+  %__3 = bitcast [1 x i8]* @i8v to i8*
+  store i8 %v1, i8* %__3, align 1
   %v2 = trunc i32 %v0 to i16
-  store i16 %v2, i16* @i16v, align 1
+  %__5 = bitcast [2 x i8]* @i16v to i16*
+  store i16 %v2, i16* %__5, align 1
   %v3 = sext i32 %v0 to i64
-  store i64 %v3, i64* @i64v, align 1
+  %__7 = bitcast [8 x i8]* @i64v to i64*
+  store i64 %v3, i64* %__7, align 1
   ret void
   ; CHECK: mov eax, dword ptr [
   ; CHECK-NEXT: mov ecx, eax
@@ -80,13 +90,17 @@
 
 define void @from_int64() {
 entry:
-  %v0 = load i64* @i64v, align 1
+  %__0 = bitcast [8 x i8]* @i64v to i64*
+  %v0 = load i64* %__0, align 1
   %v1 = trunc i64 %v0 to i8
-  store i8 %v1, i8* @i8v, align 1
+  %__3 = bitcast [1 x i8]* @i8v to i8*
+  store i8 %v1, i8* %__3, align 1
   %v2 = trunc i64 %v0 to i16
-  store i16 %v2, i16* @i16v, align 1
+  %__5 = bitcast [2 x i8]* @i16v to i16*
+  store i16 %v2, i16* %__5, align 1
   %v3 = trunc i64 %v0 to i32
-  store i32 %v3, i32* @i32v, align 1
+  %__7 = bitcast [4 x i8]* @i32v to i32*
+  store i32 %v3, i32* %__7, align 1
   ret void
   ; CHECK: mov eax, dword ptr [
   ; CHECK-NEXT: mov ecx, eax
@@ -98,13 +112,17 @@
 
 define void @from_uint8() {
 entry:
-  %v0 = load i8* @u8v, align 1
+  %__0 = bitcast [1 x i8]* @u8v to i8*
+  %v0 = load i8* %__0, align 1
   %v1 = zext i8 %v0 to i16
-  store i16 %v1, i16* @i16v, align 1
+  %__3 = bitcast [2 x i8]* @i16v to i16*
+  store i16 %v1, i16* %__3, align 1
   %v2 = zext i8 %v0 to i32
-  store i32 %v2, i32* @i32v, align 1
+  %__5 = bitcast [4 x i8]* @i32v to i32*
+  store i32 %v2, i32* %__5, align 1
   %v3 = zext i8 %v0 to i64
-  store i64 %v3, i64* @i64v, align 1
+  %__7 = bitcast [8 x i8]* @i64v to i64*
+  store i64 %v3, i64* %__7, align 1
   ret void
   ; CHECK: mov al, byte ptr [
   ; CHECK-NEXT: movzx cx, al
@@ -119,13 +137,17 @@
 
 define void @from_uint16() {
 entry:
-  %v0 = load i16* @u16v, align 1
+  %__0 = bitcast [2 x i8]* @u16v to i16*
+  %v0 = load i16* %__0, align 1
   %v1 = trunc i16 %v0 to i8
-  store i8 %v1, i8* @i8v, align 1
+  %__3 = bitcast [1 x i8]* @i8v to i8*
+  store i8 %v1, i8* %__3, align 1
   %v2 = zext i16 %v0 to i32
-  store i32 %v2, i32* @i32v, align 1
+  %__5 = bitcast [4 x i8]* @i32v to i32*
+  store i32 %v2, i32* %__5, align 1
   %v3 = zext i16 %v0 to i64
-  store i64 %v3, i64* @i64v, align 1
+  %__7 = bitcast [8 x i8]* @i64v to i64*
+  store i64 %v3, i64* %__7, align 1
   ret void
   ; CHECK: mov ax, word ptr [
   ; CHECK-NEXT: mov cx, ax
@@ -140,13 +162,17 @@
 
 define void @from_uint32() {
 entry:
-  %v0 = load i32* @u32v, align 1
+  %__0 = bitcast [4 x i8]* @u32v to i32*
+  %v0 = load i32* %__0, align 1
   %v1 = trunc i32 %v0 to i8
-  store i8 %v1, i8* @i8v, align 1
+  %__3 = bitcast [1 x i8]* @i8v to i8*
+  store i8 %v1, i8* %__3, align 1
   %v2 = trunc i32 %v0 to i16
-  store i16 %v2, i16* @i16v, align 1
+  %__5 = bitcast [2 x i8]* @i16v to i16*
+  store i16 %v2, i16* %__5, align 1
   %v3 = zext i32 %v0 to i64
-  store i64 %v3, i64* @i64v, align 1
+  %__7 = bitcast [8 x i8]* @i64v to i64*
+  store i64 %v3, i64* %__7, align 1
   ret void
   ; CHECK: mov eax, dword ptr [
   ; CHECK-NEXT: mov ecx, eax
@@ -160,13 +186,17 @@
 
 define void @from_uint64() {
 entry:
-  %v0 = load i64* @u64v, align 1
+  %__0 = bitcast [8 x i8]* @u64v to i64*
+  %v0 = load i64* %__0, align 1
   %v1 = trunc i64 %v0 to i8
-  store i8 %v1, i8* @i8v, align 1
+  %__3 = bitcast [1 x i8]* @i8v to i8*
+  store i8 %v1, i8* %__3, align 1
   %v2 = trunc i64 %v0 to i16
-  store i16 %v2, i16* @i16v, align 1
+  %__5 = bitcast [2 x i8]* @i16v to i16*
+  store i16 %v2, i16* %__5, align 1
   %v3 = trunc i64 %v0 to i32
-  store i32 %v3, i32* @i32v, align 1
+  %__7 = bitcast [4 x i8]* @i32v to i32*
+  store i32 %v3, i32* %__7, align 1
   ret void
   ; CHECK: mov eax, dword ptr [
   ; CHECK-NEXT: mov ecx, eax
diff --git a/tests_lit/llvm2ice_tests/empty-func.ll b/tests_lit/llvm2ice_tests/empty-func.ll
index a5edc02..98367bc 100644
--- a/tests_lit/llvm2ice_tests/empty-func.ll
+++ b/tests_lit/llvm2ice_tests/empty-func.ll
@@ -1,6 +1,8 @@
 ; RUIN: %llvm2ice -verbose inst %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 define void @foo() {
 ; CHECK: define void @foo()
diff --git a/tests_lit/llvm2ice_tests/fp.pnacl.ll b/tests_lit/llvm2ice_tests/fp.pnacl.ll
index 8981c9e..a9951d9 100644
--- a/tests_lit/llvm2ice_tests/fp.pnacl.ll
+++ b/tests_lit/llvm2ice_tests/fp.pnacl.ll
@@ -1,6 +1,8 @@
 ; RUIN: %llvm2ice --verbose none %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 @__init_array_start = internal constant [0 x i8] zeroinitializer, align 4
 @__fini_array_start = internal constant [0 x i8] zeroinitializer, align 4
@@ -1017,8 +1019,8 @@
 
 define internal float @loadFloat(i32 %a) {
 entry:
-  %a.asptr = inttoptr i32 %a to float*
-  %v0 = load float* %a.asptr, align 4
+  %__1 = inttoptr i32 %a to float*
+  %v0 = load float* %__1, align 4
   ret float %v0
 }
 ; CHECK: loadFloat:
@@ -1027,8 +1029,8 @@
 
 define internal double @loadDouble(i32 %a) {
 entry:
-  %a.asptr = inttoptr i32 %a to double*
-  %v0 = load double* %a.asptr, align 8
+  %__1 = inttoptr i32 %a to double*
+  %v0 = load double* %__1, align 8
   ret double %v0
 }
 ; CHECK: loadDouble:
@@ -1037,8 +1039,8 @@
 
 define internal void @storeFloat(i32 %a, float %value) {
 entry:
-  %a.asptr = inttoptr i32 %a to float*
-  store float %value, float* %a.asptr, align 4
+  %__2 = inttoptr i32 %a to float*
+  store float %value, float* %__2, align 4
   ret void
 }
 ; CHECK: storeFloat:
@@ -1046,8 +1048,8 @@
 
 define internal void @storeDouble(i32 %a, double %value) {
 entry:
-  %a.asptr = inttoptr i32 %a to double*
-  store double %value, double* %a.asptr, align 8
+  %__2 = inttoptr i32 %a to double*
+  store double %value, double* %__2, align 8
   ret void
 }
 ; CHECK: storeDouble:
diff --git a/tests_lit/llvm2ice_tests/fpconst.pnacl.ll b/tests_lit/llvm2ice_tests/fpconst.pnacl.ll
index eb43c8e..1e40f76 100644
--- a/tests_lit/llvm2ice_tests/fpconst.pnacl.ll
+++ b/tests_lit/llvm2ice_tests/fpconst.pnacl.ll
@@ -1,4 +1,6 @@
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 ; This is a smoke test for floating-point constant pooling.  It tests
 ; pooling of various float and double constants (including positive
diff --git a/tests_lit/llvm2ice_tests/global.ll b/tests_lit/llvm2ice_tests/global.ll
index 22dbad4..00ed03e 100644
--- a/tests_lit/llvm2ice_tests/global.ll
+++ b/tests_lit/llvm2ice_tests/global.ll
@@ -1,21 +1,26 @@
 ; RUIN: %llvm2ice -verbose inst %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
 
-@intern_global = global i32 12, align 4
-@extern_global = external global i32
+; Note: We don't run this test using a PNaCl bitcode file, because
+; external globals are not in the PNaCl ABI.
+
+@intern_global = global [4 x i8] [i8 0, i8 0, i8 0, i8 12], align 4
+@extern_global = external global [4 x i8]
 
 define i32 @test_intern_global() {
 ; CHECK: define i32 @test_intern_global
 entry:
-  %v0 = load i32* @intern_global, align 1
+  %__1 = bitcast [4 x i8]* @intern_global to i32*
+  %v0 = load i32* %__1, align 1
   ret i32 %v0
 }
 
 define i32 @test_extern_global() {
 ; CHECK: define i32 @test_extern_global
 entry:
-  %v0 = load i32* @extern_global, align 1
+  %__1 = bitcast [4 x i8]* @extern_global to i32*
+  %v0 = load i32* %__1, align 1
   ret i32 %v0
 }
 
diff --git a/tests_lit/llvm2ice_tests/icmp-simple.ll b/tests_lit/llvm2ice_tests/icmp-simple.ll
index 69e0adb..dc97a9b 100644
--- a/tests_lit/llvm2ice_tests/icmp-simple.ll
+++ b/tests_lit/llvm2ice_tests/icmp-simple.ll
@@ -1,6 +1,8 @@
 ; RUIN: %llvm2ice -verbose inst %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 define void @dummy_icmp(i64 %foo, i64 %bar) {
 ; CHECK: define void @dummy_icmp
diff --git a/tests_lit/llvm2ice_tests/inttoptr.ll b/tests_lit/llvm2ice_tests/inttoptr.ll
deleted file mode 100644
index 67781d7..0000000
--- a/tests_lit/llvm2ice_tests/inttoptr.ll
+++ /dev/null
@@ -1,13 +0,0 @@
-; RUIN: %llvm2ice -verbose inst %s | FileCheck %s
-; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
-
-define void @dummy_inttoptr(i32 %addr_arg) {
-entry:
-  %ptr = inttoptr i32 %addr_arg to i32*
-  ret void
-; CHECK: %ptr = i32 %addr_arg
-}
-
-; ERRORS-NOT: ICE translation error
-; DUMP-NOT: SZ
diff --git a/tests_lit/llvm2ice_tests/load.ll b/tests_lit/llvm2ice_tests/load.ll
index 31b0624..1a1d6a3 100644
--- a/tests_lit/llvm2ice_tests/load.ll
+++ b/tests_lit/llvm2ice_tests/load.ll
@@ -1,47 +1,49 @@
 ; RUIN: %llvm2ice -verbose inst %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 define void @load_i64(i32 %addr_arg) {
 entry:
-  %ptr64 = inttoptr i32 %addr_arg to i64*
-  %iv = load i64* %ptr64, align 1
+  %__1 = inttoptr i32 %addr_arg to i64*
+  %iv = load i64* %__1, align 1
   ret void
 
-; CHECK:      %ptr64 = i32 %addr_arg
+; CHECK:      %__1 = i32 %addr_arg
 ; CHECK-NEXT:  %iv = load i64* {{.*}}, align 1
 ; CHECK-NEXT:  ret void
 }
 
 define void @load_i32(i32 %addr_arg) {
 entry:
-  %ptr32 = inttoptr i32 %addr_arg to i32*
-  %iv = load i32* %ptr32, align 1
+  %__1 = inttoptr i32 %addr_arg to i32*
+  %iv = load i32* %__1, align 1
   ret void
 
-; CHECK:       %ptr32 = i32 %addr_arg
+; CHECK:       %__1 = i32 %addr_arg
 ; CHECK-NEXT:  %iv = load i32* {{.*}}, align 1
 ; CHECK-NEXT:  ret void
 }
 
 define void @load_i16(i32 %addr_arg) {
 entry:
-  %ptr16 = inttoptr i32 %addr_arg to i16*
-  %iv = load i16* %ptr16, align 1
+  %__1 = inttoptr i32 %addr_arg to i16*
+  %iv = load i16* %__1, align 1
   ret void
 
-; CHECK:       %ptr16 = i32 %addr_arg
+; CHECK:       %__1 = i32 %addr_arg
 ; CHECK-NEXT:  %iv = load i16* {{.*}}, align 1
 ; CHECK-NEXT:  ret void
 }
 
 define void @load_i8(i32 %addr_arg) {
 entry:
-  %ptr8 = inttoptr i32 %addr_arg to i8*
-  %iv = load i8* %ptr8, align 1
+  %__1 = inttoptr i32 %addr_arg to i8*
+  %iv = load i8* %__1, align 1
   ret void
 
-; CHECK:       %ptr8 = i32 %addr_arg
+; CHECK:       %__1 = i32 %addr_arg
 ; CHECK-NEXT:  %iv = load i8* {{.*}}, align 1
 ; CHECK-NEXT:  ret void
 }
diff --git a/tests_lit/llvm2ice_tests/return-int-arg.ll b/tests_lit/llvm2ice_tests/return-int-arg.ll
index 66f6a3b..1e2d8b2 100644
--- a/tests_lit/llvm2ice_tests/return-int-arg.ll
+++ b/tests_lit/llvm2ice_tests/return-int-arg.ll
@@ -1,6 +1,8 @@
 ; RUIN: %llvm2ice -verbose inst %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 define i32 @func_single_arg(i32 %a) {
 ; CHECK: define i32 @func_single_arg
diff --git a/tests_lit/llvm2ice_tests/select-opt.ll b/tests_lit/llvm2ice_tests/select-opt.ll
index e47dd3c..9bb9701 100644
--- a/tests_lit/llvm2ice_tests/select-opt.ll
+++ b/tests_lit/llvm2ice_tests/select-opt.ll
@@ -1,6 +1,8 @@
 ; RUIN: %llvm2ice %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 define void @testSelect(i32 %a, i32 %b) {
 entry:
diff --git a/tests_lit/llvm2ice_tests/shift.ll b/tests_lit/llvm2ice_tests/shift.ll
index 45d295d..674f4db 100644
--- a/tests_lit/llvm2ice_tests/shift.ll
+++ b/tests_lit/llvm2ice_tests/shift.ll
@@ -1,18 +1,21 @@
 ; RUIN: %llvm2ice -verbose inst %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
-@i1 = common global i32 0, align 4
-@i2 = common global i32 0, align 4
-@u1 = common global i32 0, align 4
-@u2 = common global i32 0, align 4
+@i1 = global [4 x i8] zeroinitializer, align 4
+@i2 = global [4 x i8] zeroinitializer, align 4
+@u1 = global [4 x i8] zeroinitializer, align 4
 
 define void @conv1() {
 entry:
-  %v0 = load i32* @u1, align 1
+  %__0 = bitcast [4 x i8]* @u1 to i32*
+  %v0 = load i32* %__0, align 1
   %sext = shl i32 %v0, 24
   %v1 = ashr i32 %sext, 24
-  store i32 %v1, i32* @i1, align 1
+  %__4 = bitcast [4 x i8]* @i1 to i32*
+  store i32 %v1, i32* %__4, align 1
   ret void
   ; CHECK: shl eax, 24
   ; CHECK-NEXT: sar eax, 24
@@ -20,10 +23,12 @@
 
 define void @conv2() {
 entry:
-  %v0 = load i32* @u1, align 1
+  %__0 = bitcast [4 x i8]* @u1 to i32*
+  %v0 = load i32* %__0, align 1
   %sext1 = shl i32 %v0, 16
   %v1 = ashr i32 %sext1, 16
-  store i32 %v1, i32* @i2, align 1
+  %__4 = bitcast [4 x i8]* @i2 to i32*
+  store i32 %v1, i32* %__4, align 1
   ret void
   ; CHECK: shl eax, 16
   ; CHECK-NEXT: sar eax, 16
diff --git a/tests_lit/llvm2ice_tests/simple-arith.ll b/tests_lit/llvm2ice_tests/simple-arith.ll
index 0b109c6..8b32a94 100644
--- a/tests_lit/llvm2ice_tests/simple-arith.ll
+++ b/tests_lit/llvm2ice_tests/simple-arith.ll
@@ -1,7 +1,8 @@
 ; RUIN: %llvm2ice -verbose inst %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
-
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 define i64 @add_args_i64(i64 %arg1, i64 %arg2) {
 entry:
diff --git a/tests_lit/llvm2ice_tests/simple-cond.ll b/tests_lit/llvm2ice_tests/simple-cond.ll
index cc1f583..2161a59 100644
--- a/tests_lit/llvm2ice_tests/simple-cond.ll
+++ b/tests_lit/llvm2ice_tests/simple-cond.ll
@@ -1,6 +1,8 @@
 ; RUIN: %llvm2ice -verbose inst %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 define internal i32 @simple_cond(i32 %a, i32 %n) {
 entry:
@@ -16,8 +18,8 @@
 if.else:
   %gep_array = mul i32 %n, 4
   %gep = add i32 %a, %gep_array
-  %gep.asptr = inttoptr i32 %gep to i32*
-  %v0 = load i32* %gep.asptr, align 1
+  %__6 = inttoptr i32 %gep to i32*
+  %v0 = load i32* %__6, align 1
   br label %if.end
 
 if.end:
diff --git a/tests_lit/llvm2ice_tests/simple-loop.ll b/tests_lit/llvm2ice_tests/simple-loop.ll
index 4460834..a35e5b3 100644
--- a/tests_lit/llvm2ice_tests/simple-loop.ll
+++ b/tests_lit/llvm2ice_tests/simple-loop.ll
@@ -1,6 +1,8 @@
 ; RUIN: %llvm2ice -verbose inst %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 define i32 @simple_loop(i32 %a, i32 %n) {
 entry:
@@ -12,8 +14,8 @@
   %sum.05 = phi i32 [ %add, %for.body ], [ 0, %entry ]
   %gep_array = mul i32 %i.06, 4
   %gep = add i32 %a, %gep_array
-  %gep.asptr = inttoptr i32 %gep to i32*
-  %v0 = load i32* %gep.asptr, align 1
+  %__9 = inttoptr i32 %gep to i32*
+  %v0 = load i32* %__9, align 1
   %add = add i32 %v0, %sum.05
   %inc = add i32 %i.06, 1
   %cmp = icmp slt i32 %inc, %n
diff --git a/tests_lit/llvm2ice_tests/store.ll b/tests_lit/llvm2ice_tests/store.ll
index edf2ff2..59e1c2b 100644
--- a/tests_lit/llvm2ice_tests/store.ll
+++ b/tests_lit/llvm2ice_tests/store.ll
@@ -1,47 +1,49 @@
 ; RUIN: %llvm2ice %s -verbose inst | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 define void @store_i64(i32 %addr_arg) {
 entry:
-  %ptr64 = inttoptr i32 %addr_arg to i64*
-  store i64 1, i64* %ptr64, align 1
+  %__1 = inttoptr i32 %addr_arg to i64*
+  store i64 1, i64* %__1, align 1
   ret void
 
-; CHECK:       %ptr64 = i32 %addr_arg
+; CHECK:       %__1 = i32 %addr_arg
 ; CHECK-NEXT:  store i64 1, {{.*}}, align 1
 ; CHECK-NEXT:  ret void
 }
 
 define void @store_i32(i32 %addr_arg) {
 entry:
-  %ptr32 = inttoptr i32 %addr_arg to i32*
-  store i32 1, i32* %ptr32, align 1
+  %__1 = inttoptr i32 %addr_arg to i32*
+  store i32 1, i32* %__1, align 1
   ret void
 
-; CHECK:       %ptr32 = i32 %addr_arg
+; CHECK:       %__1 = i32 %addr_arg
 ; CHECK-NEXT:  store i32 1, {{.*}}, align 1
 ; CHECK-NEXT:  ret void
 }
 
 define void @store_i16(i32 %addr_arg) {
 entry:
-  %ptr16 = inttoptr i32 %addr_arg to i16*
-  store i16 1, i16* %ptr16, align 1
+  %__1 = inttoptr i32 %addr_arg to i16*
+  store i16 1, i16* %__1, align 1
   ret void
 
-; CHECK:       %ptr16 = i32 %addr_arg
+; CHECK:       %__1 = i32 %addr_arg
 ; CHECK-NEXT:  store i16 1, {{.*}}, align 1
 ; CHECK-NEXT:  ret void
 }
 
 define void @store_i8(i32 %addr_arg) {
 entry:
-  %ptr8 = inttoptr i32 %addr_arg to i8*
-  store i8 1, i8* %ptr8, align 1
+  %__1 = inttoptr i32 %addr_arg to i8*
+  store i8 1, i8* %__1, align 1
   ret void
 
-; CHECK:       %ptr8 = i32 %addr_arg
+; CHECK:       %__1 = i32 %addr_arg
 ; CHECK-NEXT:  store i8 1, {{.*}}, align 1
 ; CHECK-NEXT:  ret void
 }
diff --git a/tests_lit/llvm2ice_tests/struct-arith.pnacl.ll b/tests_lit/llvm2ice_tests/struct-arith.pnacl.ll
index de68416..3e88b0f 100644
--- a/tests_lit/llvm2ice_tests/struct-arith.pnacl.ll
+++ b/tests_lit/llvm2ice_tests/struct-arith.pnacl.ll
@@ -1,6 +1,8 @@
 ; RUIN: %llvm2ice -verbose inst %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 ; This file is lowered from C code that does some simple aritmetic with
 ; struct members. It's also built with the PNaCl toolchain so this is the
@@ -9,37 +11,37 @@
 
 define internal i32 @compute_important_function(i32 %v1, i32 %v2) {
 entry:
-  %v1.asptr = inttoptr i32 %v1 to i32*
-  %_v0 = load i32* %v1.asptr, align 1
+  %__2 = inttoptr i32 %v1 to i32*
+  %_v0 = load i32* %__2, align 1
 
 ; CHECK:        entry:
-; CHECK-NEXT:       %v1.asptr = i32 %v1
+; CHECK-NEXT:       %__2 = i32 %v1
 ; CHECK-NEXT:       %_v0 = load i32* {{.*}}, align 1
 
-  %v2.asptr = inttoptr i32 %v2 to i32*
-  %_v1 = load i32* %v2.asptr, align 1
+  %__4 = inttoptr i32 %v2 to i32*
+  %_v1 = load i32* %__4, align 1
   %gep = add i32 %v2, 12
-  %gep.asptr = inttoptr i32 %gep to i32*
-  %_v2 = load i32* %gep.asptr, align 1
+  %__7 = inttoptr i32 %gep to i32*
+  %_v2 = load i32* %__7, align 1
   %mul = mul i32 %_v2, %_v1
   %gep6 = add i32 %v1, 4
-  %gep6.asptr = inttoptr i32 %gep6 to i32*
-  %_v3 = load i32* %gep6.asptr, align 1
+  %__11 = inttoptr i32 %gep6 to i32*
+  %_v3 = load i32* %__11, align 1
   %gep8 = add i32 %v2, 8
-  %gep8.asptr = inttoptr i32 %gep8 to i32*
-  %_v4 = load i32* %gep8.asptr, align 1
+  %__14 = inttoptr i32 %gep8 to i32*
+  %_v4 = load i32* %__14, align 1
   %gep10 = add i32 %v2, 4
-  %gep10.asptr = inttoptr i32 %gep10 to i32*
-  %_v5 = load i32* %gep10.asptr, align 1
+  %__17 = inttoptr i32 %gep10 to i32*
+  %_v5 = load i32* %__17, align 1
   %mul3 = mul i32 %_v5, %_v4
   %gep12 = add i32 %v1, 8
-  %gep12.asptr = inttoptr i32 %gep12 to i32*
-  %_v6 = load i32* %gep12.asptr, align 1
+  %__21 = inttoptr i32 %gep12 to i32*
+  %_v6 = load i32* %__21, align 1
   %mul7 = mul i32 %_v6, %_v3
   %mul9 = mul i32 %mul7, %_v6
   %gep14 = add i32 %v1, 12
-  %gep14.asptr = inttoptr i32 %gep14 to i32*
-  %_v7 = load i32* %gep14.asptr, align 1
+  %__26 = inttoptr i32 %gep14 to i32*
+  %_v7 = load i32* %__26, align 1
   %mul11 = mul i32 %mul9, %_v7
   %add4.neg = add i32 %mul, %_v0
   %add = sub i32 %add4.neg, %_v3
diff --git a/tests_lit/llvm2ice_tests/switch-opt.ll b/tests_lit/llvm2ice_tests/switch-opt.ll
index 3d008d1..827dae7 100644
--- a/tests_lit/llvm2ice_tests/switch-opt.ll
+++ b/tests_lit/llvm2ice_tests/switch-opt.ll
@@ -1,6 +1,8 @@
 ; RUIN: %llvm2ice %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 define i32 @testSwitch(i32 %a) {
 entry:
diff --git a/tests_lit/llvm2ice_tests/unreachable.ll b/tests_lit/llvm2ice_tests/unreachable.ll
index 9d49008..25a3dd6 100644
--- a/tests_lit/llvm2ice_tests/unreachable.ll
+++ b/tests_lit/llvm2ice_tests/unreachable.ll
@@ -1,6 +1,8 @@
 ; RUIN: %llvm2ice -verbose inst %s | FileCheck %s
 ; RUIN: %llvm2ice --verbose none %s | FileCheck --check-prefix=ERRORS %s
-; RUN: %szdiff --llvm2ice=%llvm2ice %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts %s | %szdiff %s | FileCheck --check-prefix=DUMP %s
+; RUN: %llvm2iceinsts --pnacl %s | %szdiff %s \
+; RUN:                           | FileCheck --check-prefix=DUMP %s
 
 define internal i32 @divide(i32 %num, i32 %den) {
 entry: