Add ability to print out abbreviations in PNaCl bitcode files.

Adds ability to print out abbreviations in pnacl-bcanalyzer, so
that we can interogate abbreviations to be added by pnacl-bccompress.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3720
R=jvoung@chromium.org

Review URL: https://codereview.chromium.org/100603008

(cherry picked from commit 0c594b2351ae180ae541cbbee097292bfb96cabc)
Fix signature of Error methods in NaClBitcodeAnalyzer.cpp.

This fixes an compiler inheritance warning that these
methods are hiding the inherited virtual function.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3720
R=mseaborn@chromium.org

Review URL: https://codereview.chromium.org/121783002

(cherry picked from commit 008388a19faf4e1d545b48d1ca46b6a7f20c762b)
Add block bit tracking to NaClBitcodeParser.

Simplify NaClBitcodeParser so that tracking of bits in blocks are
stored in class NaClBitcodeRecord, and are (automatically) updated by
class NaClBitcodeParser.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3720
R=jvoung@chromium.org

Review URL: https://codereview.chromium.org/118293006

(cherry picked from commit 4fc1f6c9b55a028fe1e166019270777cc7269d80)
PNaCl: Remove references to LinkOnceODRAutoHideLinkage, removed upstream

This is in preparation for merging LLVM 3.4.  The linkage type
LinkOnceODRAutoHideLinkage was removed upstream in r193865:
http://llvm.org/viewvc/llvm-project?view=revision&revision=193865

BUG=https://code.google.com/p/nativeclient/issues/detail?id=3757
TEST=build

Review URL: https://codereview.chromium.org/123233003

(cherry picked from commit 81a4d582785d9546178cfcf83c6164d579789741)

Conflicts:
	lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp
	lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp
Remove the use of templates for bitcode record distributions.

Since templates do not represent inheritance well, remove the use of
templates to define bitcode record distributions. Rather, use LLVM's
(dynamic) casting operators to handle the casting that was formerly
handled by template arguments.

Also moves many bodies of methods in header files, to the
corresponding implementation files.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3720
R=jvoung@chromium.org

Review URL: https://codereview.chromium.org/103553005

(cherry picked from commit 0fd5436c85656fb3d2ad8e4ed47abfcdd7280c94)
PNaCl bitcode: Remove support for reading/writing case ranges in switches

This is in preparation for merging LLVM 3.4, because support for case
ranges was removed upstream in r190328
(http://llvm.org/viewvc/llvm-project?view=revision&revision=190328).

Nothing ever generated case ranges, so removing support won't break
anything.  This change restricts the bitcode format so that the
NumItems and IsSingleNumber fields are both always 1.

BUG=https://code.google.com/p/nativeclient/issues/detail?id=3758
TEST=trybots

Review URL: https://codereview.chromium.org/123233004

(cherry picked from commit 17fd5772e99828d6426ce1b402e2f66b0dbf1134)

Conflicts:
	lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp
	lib/Bitcode/NaCl/Writer/NaClBitcodeWriter.cpp
PNaCl bitcode: Remove unused code for reading wide integers in switch cases

BUG=https://code.google.com/p/nativeclient/issues/detail?id=3758
TEST=trybots

Review URL: https://codereview.chromium.org/103513003

(cherry picked from commit 3513571bb561cdcf315ec5c7dee3bfb9dce13a29)

Conflicts:
	lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp
Clean up hanlding of nested bitcode record distributions.

Also cleans up printing of distributions, and separates out adding
blocks and records to a distribution map.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3720
R=jvoung@chromium.org

Review URL: https://codereview.chromium.org/123983002

(cherry picked from commit 24e19597b6d84b8ba165740e2c9a89ff3eaa5df5)

Conflicts:
	test/NaCl/Bitcode/bcdist.ll
PNaCl: Implement computed gotos (indirectbr) by expanding out to switches

Add the ExpandIndirectBr pass for expanding out indirectbr and
blockaddress into switch instructions, so that programs using computed
gotos can work with PNaCl's stable ABI.

BUG=https://code.google.com/p/nativeclient/issues/detail?id=3695
TEST=*.ll tests + GCC torture tests

Review URL: https://codereview.chromium.org/120773002

(cherry picked from commit a55919fb536ad1b01752ae0bc7fbf04461f410e7)
Fix compiler warning about non-virtual destructor.

CL 123983002 was checked in with the compiler warning that
class NaClBitcodeDist has virtual fucntions and accessible
non-virtual destructor. This CL fixes that issue.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3720
R=jvoung@chromium.org

Review URL: https://codereview.chromium.org/126483002

(cherry picked from commit d7a651b1f33db9038a5a611b7bd52f24bd3cdb84)
Trace abbreviations use to compressed file in pnacl-bccompress.

Adds commmand-line flag to trace abbreviations used in generated
compressed file when running pnacl-bccompress. Fixes warning about
unused PrintAbbrev() function.

BUG=None
TEST=compile
R=jvoung@chromium.org

Review URL: https://codereview.chromium.org/125203002

(cherry picked from commit 2d3e6fefaacb624562e964b268521680a707a0a1)
Rename files containing PNaCl bitcode distribution maps.

Class names in various PNaCl bitcode distribution maps got renamed
in previous CL's. Fix the filenames to better reflect the distribution
maps they define.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3720
R=jvoung@chromium.org

Review URL: https://codereview.chromium.org/126543003

(cherry picked from commit abfef0eec03cdc01f09b2739f83fa02dfe4242ca)
Separate out bits distribution maps from bits and abbreviations.

Separate out bits distribution maps from bits and abbreviations
distribution maps, so that we can use the bits distribution map
to model blocks (which do not have a notion of abbreviations).

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3720
R=jvoung@chromium.org

Review URL: https://codereview.chromium.org/132343003

(cherry picked from commit ef0f702275b1c1df0a41764125cfad8a4d1e162d)
Refactor pnacl bitcode analysis to update distribution map.

Modify the bitcode analyzer to update a passed distribution map,
allowing the caller to define the map and how it is updated.

Also modifies pnacl-bcanalyzer to define it distribution map
as a map of bitcode blocks, with nested subblock and record
code distributions.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3720
R=jvoung@chromium.org

Review URL: https://codereview.chromium.org/134983002

(cherry picked from commit 49ecfbed0beeee9180b8075c3f8b186ddb36e5c4)
Refactor pnacl-bcanalyzer and pnacl-benchmark to use same distribution.

The previous CL removed building block/record distributions from
NaClBitcodeAnalyzer.cpp. This accidentally removed building block
and record distributions from pnacl-benchmark. This refactors the
code to put the distributions back into pnacl-benchmark.

It also removes record dumping from pnacl-benchmark, since the
dumping code does not reflect parse time.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3720
R=jvoung@chromium.org

Review URL: https://codereview.chromium.org/135273003

(cherry picked from commit 45dcfc69544019893a4c7c01da98e8ab515b99b2)
Add (nested) distribution maps to pnacl-bccompress.

Adds distribution maps to pnacl-bccompress that will be used to find
abbreviation refinements of the current set of abbreviations.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3720
R=jvoung@chromium.org

Review URL: https://codereview.chromium.org/139543004

(cherry picked from commit ecaa2b459dd21b870e303ceb8dfde0af6746509d)
PNaCl: Fix ambiguity in reference to PassManager

In LLVM 3.4, PassManager is defined by "using legacy::PassManager", so
forward-declaring it no longer works.  When compiling with Clang 3.4
(for the sandboxed translator), it gave this error:

include/llvm/Transforms/NaCl.h:54:38: error: reference to 'PassManager' is ambiguous
void PNaClABISimplifyAddPreOptPasses(PassManager &PM);
include/llvm/Transforms/NaCl.h:21:7: note: candidate found by name lookup is 'llvm::PassManager'
class PassManager;
include/llvm/PassManager.h:34:15: note: candidate found by name lookup is 'llvm::PassManager'
using legacy::PassManager;

(However, gcc 4.6.3 didn't complain.)

Fix this by using PassManagerBase in the same way that addPass() in
opt.cpp does.

BUG=https://code.google.com/p/nativeclient/issues/detail?id=3757
TEST=tested with LLVM 3.4 merged
R=jvoung@chromium.org

Review URL: https://codereview.chromium.org/143853002

(cherry picked from commit 6a38d188d29270fc40fa6af6c6c7d36ba4a34637)

Conflicts:
	include/llvm/Transforms/NaCl.h
	lib/Transforms/NaCl/PNaClABISimplify.cpp
Reduce the search space for finding abbreviations in pnacl-bccompress.

Reduces the search space by:

(1) Limit size and value index distributions, based on predefined
constant.

(2) Track bitcode record values using ranges, rather than individual
values.

BUG=https://code.google.com/p/nativeclient/issues/detail?id=3720
R=jvoung@chromium.org

Review URL: https://codereview.chromium.org/145273002

(cherry picked from commit c8aa6390baab96d78afa388299c6f0486f6317c9)
Make local symbol tables only allowed using command-line arguments.

Adds command-line argument to allow local (function) value symbol
tables. Fixes writing of value symbol tables to PNaCl bitcode to
remove symbols with elided code. Fixes tests to use local value
symbol tables when needed to make the assembly easier to maintain.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3774
R=jvoung@chromium.org

Review URL: https://codereview.chromium.org/148283010

(cherry picked from commit c1a842e15f0ac391704ce9d1b26a084e2ce8a58d)
Normalize abbreviation ids in pnacl-bccompress.

Pnacl-bccompress reads a pnacl bitcode file and builds distribution
maps from the records in the file. This includes mapping abbreviations
indices in the records. However, this tool converts all abbreviations
to global, including local abbreviations, which are not unique. This
code fixes the distribution maps so they all refer to the (new)
globalized abbreviations.

BUG= https://code.google.com/p/nativeclient/issues/detail?id=3720
R=jvoung@chromium.org

Review URL: https://codereview.chromium.org/130913012

(cherry picked from commit 8b0b4226d87df029265b80e1e25b2a0fbcd7f542)

Conflicts:
	tools/pnacl-bccompress/pnacl-bccompress.cpp