aboutsummaryrefslogtreecommitdiff
path: root/tools
AgeCommit message (Collapse)Author
2013-06-28Teach llvm-nm to read PNaCl bitcode.Eli Bendersky
BUG=None R=jvoung@chromium.org Review URL: https://codereview.chromium.org/18153009
2013-06-28Change header include for llvm.nacl.target.arch in pnacl-llc.Jan Voung
Have nacl-file include "pnacl.h" from the nacl repo, instead of from the toolchain's standard include locations, so that it can be moved out of the toolchain tarball and not advertise it to normal developers. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3525 R=mseaborn@chromium.org Review URL: https://codereview.chromium.org/18178007
2013-06-25PNaCl ABI: Disallow various operations on the i1 typeMark Seaborn
Disallow i1 on loads/stores and require the conversions to i8 to be explicit. Add a pass, PromoteI1Ops, that adds the conversions. (Load/store on i1 occur in practice in small_tests for some boolean globals.) Disallow i1 for most arithmetic/comparison operations since these aren't very useful and it's a nuisance for a code generator to have to support these. I haven't seen these occur in practice, but PromoteI1Ops nevertheless expands them. We still allow and/or/xor on i1 because these do occur in practice, and they're less of a nuisance to handle because they never overflow: no truncation to 1 bit is required, unlike with adds. Restrict the type of alloca's argument. Clang always uses i32 here. Disallow i1 in switch instructions. Clang doesn't generate i1 switches for booleans. Move CopyLoadOrStoreAttrs() helper into a header to reuse. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3490 TEST=PNaCl toolchain trybots + GCC torture tests + Spec2k Review URL: https://codereview.chromium.org/17356011
2013-06-24Force user to provide -mptriple to pnacl-llc.Eli Bendersky
We already always provide -mptriple to pnacl-llc, and it's nonsensical to run it without it because pexe don't contain a triple. BUG=None R=dschuff@chromium.org Review URL: https://codereview.chromium.org/17617002
2013-06-24Simplify representation of forward value references in bitcode.Karl Schimpf
Simplify instruction records by adding concept of a forward type reference map that maps ValueID's to types. Used to generate forward reference types for instruction arguments that need a type because the forward reference has not yet been generated. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3507 R=jvoung@chromium.org, mseaborn@chromium.org Review URL: https://codereview.chromium.org/16963004
2013-06-20Clean-up pnacl-llc a bit, now that it's truly PNaCl-only.Eli Bendersky
No changes in functionality. Specific cleanups: * Use OwningPtr instead of bare pointer for FDOut * Command-line help should say pnacl-llc instead of a generic llvm message * Remove support for "skip module" feature * Remove some LOCALMOD comments * Add link to issue for TODO about timing IR parsing BUG=None R=jvoung@chromium.org, kschimpf@google.com Review URL: https://codereview.chromium.org/17101032
2013-06-19Rewrite llvm.flt.rounds to "1" for now, and disallow llvm.flt.rounds.Jan Voung
Until there is an intrinsic to *set* the rounding mode, this intrinsic to *get* the rounding mode isn't so useful. Separately we will add a test that for each platform, the initial rounding mode is "1" (round to nearest). That is the case right now for x86, ARM, and MIPS. (see https://codereview.chromium.org/16785003/) BUG=https://code.google.com/p/nativeclient/issues/detail?id=3491 R=mseaborn@chromium.org Review URL: https://codereview.chromium.org/17229007
2013-06-17PNaCl: Turn on ABI verifier by default in sandboxed translatorMark Seaborn
Change pnacl-llc.cpp to enable the verifier. This causes two problems which we fix: * The ABI check for declared-but-not-defined functions fails in streaming mode. Fixing this would involve changing the bitcode reader. For now, disable this check when in streaming mode. Add a flag to PNaClABIVerifyModule. * ARM's GlobalMerge pass modifies functions' global variable references to use ConstantExprs that the ABI checker rejects. Address this by disabling GlobalMerge for now. GlobalMerge does not provide much benefit at the moment anyway, because, with the FlattenGlobals pass applied, GlobalMerge doesn't merge variables with alignment >1. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3465 TEST=PNaCl toolchain trybots Review URL: https://codereview.chromium.org/17190002
2013-06-17When running pnacl-llc sandboxed, force input to always be PNaCl bitcode.Karl Schimpf
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3469 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/17295004
2013-06-12Revert llc to upstreamEli Bendersky
tools/llc is reset to revision 279b9184c2ff4fea93b198a3519b8cb3a1d8d195 from which the last LLVM merge was made. NaCl-specific files are removed. BUG=None R=jvoung@chromium.org Review URL: https://codereview.chromium.org/16510008
2013-06-12Remove a stray usage of NACL_SRPCEli Bendersky
BUG=None R=dschuff@chromium.org Review URL: https://codereview.chromium.org/16663008
2013-06-11Clean-up shared-library related code from pnacl-llc.Eli Bendersky
BUG=None R=dschuff@chromium.org Review URL: https://codereview.chromium.org/16123031
2013-06-10Fix the ninja build by adding naclbitreader to dependencies.Jim Stichnoth
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3485 R=kschimpf@google.com Review URL: https://codereview.chromium.org/16146012
2013-06-10Merge the NACL_SRPC preprocessor flag into __native_client__Eli Bendersky
We always build the sandboxed translator with NACL_SRPC. BUG=None R=jvoung@chromium.org Review URL: https://codereview.chromium.org/16667016
2013-06-07Fix Mispelled local variable in llc.Karl Schimpf
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3479 R=dschuff@chromium.org Review URL: https://codereview.chromium.org/16440008
2013-06-07Add CL argument -bitcode-format to llvm-dis, llc, and pnacl-llc.Karl Schimpf
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3469 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/16385002
2013-06-06Make PNaCl bitcode files have a different format from LLVM bitcode files.Karl Schimpf
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3405 R=dschuff@chromium.org Review URL: https://codereview.chromium.org/15907008
2013-06-05PNaCl ABI: Strip out attributes on functions and function callsMark Seaborn
Add a pass, StripAttributes, for doing this, and enable it. Add an ABI check to reject these attributes. BUG=https://code.google.com/p/nativeclient/issues/detail?id=2346 BUG=https://code.google.com/p/nativeclient/issues/detail?id=3415 TEST=*.ll tests + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/16325025
2013-06-05Change CL flag -pnacl-freeze to -bitcode-format={llvm,pnacl}.Karl Schimpf
Also removes flag from llvm-as.cpp and LTOCodeGenerator.cpp since one should call pnacl-finalize to transform pexe's to PNaCl bitcode form. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3469 R=dschuff@chromium.org, jvoung@chromium.org Review URL: https://codereview.chromium.org/16295014
2013-05-30PNaCl: Add a pass to expand out Clang's use of registers of struct typeMark Seaborn
Clang's implementation of C++ method pointers generates IR that uses LLVM registers with struct type -- specifically, loads and stores of struct values, and extractvalue instructions. See lib/CodeGen/ItaniumCXXABI.cpp in Clang. Add a pass, ExpandStructRegs, which expands out those uses. Factor out a function from ExpandArithWithOverflow so that the two passes can share some code. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3343 TEST=*.ll tests + trybots + GCC torture tests Review URL: https://codereview.chromium.org/15692014
2013-05-29PNaCl: Add ExpandSmallArguments pass to widen parameters to 32 bitsMark Seaborn
This widens i1, i8 and i16 function arguments and return types. Factor out RecreateFunction() helper function from existing PNaCl passes since this is a reoccurring code fragment. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3342 TEST=*.ll tests + PNaCl toolchain trybots + GCC torture tests + LLVM test suite Review URL: https://codereview.chromium.org/15971007
2013-05-28Update llc/pnacl-llc makefiles to link nacltransforms.Eli Bendersky
i686 translator build fails otherwise, not finding the symbols for passes invoked by llc. This breakage was introduced by commit ffc13bcb40d4257202295fc0ffe25b38bdf64263 BUG=https://code.google.com/p/nativeclient/issues/detail?id=3429 R=mseaborn@chromium.org Review URL: https://codereview.chromium.org/15786007
2013-05-28PNaCl: Extend ExpandMulWithOverflow pass to handle uadd.with.overflow tooMark Seaborn
It turned out that umul.with.overflow wasn't the only *.with.overflow intrinsic usage introduced by Clang. I knew that Clang's CGExprCXX.cpp generates umul.with.overflow for an overflow check for C++'s "new Foo[]". The same code for handling "new Foo[]" also generates uadd.with.overflow in some cases. This happens if class Foo has a destructor or a delete[] operator that takes a size argument. In those cases, the C++ ABI adds a "cookie" to the allocation which contains the array's size. Rename the pass to "ExpandArithWithOverflow" and rename files accordingly. Also enable the pass. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3434 TEST=*.ll tests + trybots + GCC torture tests Review URL: https://codereview.chromium.org/15688011
2013-05-28Add two passes that implement conversions from PNaCl's specific intrinsicsEli Bendersky
to external function calls during the translation stage (llc). One of the passes is a ModulePass that adds the appropriate function declarations to the module. The other is a FunctionPass that performs the actual call replacement. This split exists because of bitcode streaming. Initially the passes handle the llvm.nacl.{set|long}jmp intrinsics. In the future they may handle additional intrinsics that are part of the PNaCl stable bitcode ABI. This CL also removes the previous approach to handling this conversion (in SelectionDAGBuilder.cpp). That ended up not working - more details in issue 3429. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3429 R=mseaborn@chromium.org Review URL: https://codereview.chromium.org/16047002
2013-05-24PNaCl: Add "-pnacl-abi-simplify-{pre,post}opt" meta-passes to "opt"Mark Seaborn
These meta-passes will be used to replace the pass lists that are currently in the pnacl-ld.py driver script in the NaCl repo. I've moved the comments across from pnacl-ld.py and added a couple more comments for ExpandByVal and StripMetadata. Fix the declaration of createResolveAliasesPass(). BUG=https://code.google.com/p/nativeclient/issues/detail?id=3435 TEST=new *.ll tests + tested with change to pnacl-ld.py Review URL: https://codereview.chromium.org/15669002
2013-05-24PNaCl: Add pass to expand out Clang-generated umul.with.overflow callsMark Seaborn
This adds a pass, ExpandMulWithOverflow, to expand out the llvm.umul.with.overflow calls that Clang generates to implement an overflow check for C++'s new[] operator. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3434 TEST=expand-mul-with-overflow.ll Review URL: https://codereview.chromium.org/14649027
2013-05-24Allow generation of pnacl bitcode files in several llvm commnads.Karl Schimpf
Adds command line option '-pnacl-freeze' to generate a pnacl bit code file instead of an llvm bitcode file. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3405 R=dschuff@chromium.org Review URL: https://codereview.chromium.org/15178005
2013-05-24Make abbreviations explicit in pnacl-freeze/thaw.Karl Schimpf
[1] Explicitly enumerate all abbreviation values, including the maximum abbreviation for each type of block. [2] Make "enter subblock" calculate number of bits needed by passing in maximum abbreviation (associated with block) rather than requiring the developer to compute this value every time a subblock is entered. *NOTE* This code changes encoding sizes to be based on the maximum allowed value, rather than requiring the developer to calculate out the number of bits needed. This change doesn't make the PNaCL bitcode files incompatable with LLVM bitcode files, since it does not effect the bitcode reader. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3405 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/14813032
2013-05-22PNaCl: Add ReplacePtrsWithInts pass for stripping out pointer typesMark Seaborn
ReplacePtrsWithInts converts IR to a normal form in which functions don't reference any aggregate pointer types and pointer types only appear inside a few instructions. Change BlockAddress::replaceUsesOfWithOnConstant() to handle changing a function's type by replacing a function with a bitcast ConstantExpr of a new function. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3343 TEST=replace-ptrs-with-ints.ll + PNaCl toolchain trybots, torture tests, etc. Review URL: https://codereview.chromium.org/14262011
2013-05-21The RecordMetadataForSrpc function that was removed initialized ↵Eli Bendersky
NaClRecordObjectInformation, and this initialization has to be reinstated. BUG=None R=dschuff@chromium.org Review URL: https://codereview.chromium.org/15451003
2013-05-15Separate the PNaCl llc into a tool named pnacl-llc (how original!)Eli Bendersky
BUG=None R=jvoung@chromium.org Review URL: https://codereview.chromium.org/14604011
2013-05-14Adding a pass - RewritePNaClLibraryCalls, that replaces known library calls ↵Eli Bendersky
with stable bitcode intrinsics. Starting with setjmp and longjmp. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3429 R=jvoung@chromium.org, mseaborn@chromium.org Review URL: https://codereview.chromium.org/14617017
2013-05-10PNaCl ABI: Promote illegal integer typesDerek Schuff
This pass (mostly) legalizes integer types by promoting them. It has some limitations (e.g. it can't change function types) but it is more than sufficient for what clang and SROA generate. A more significant limitation of promotion is that packed bitfields of size > 64 bits are still not handled. There are none in our tests (other than callingconv_case_by_case which doesn't require a stable pexe) but we will want to either handle them by correctly expanding them, or find a better way to error out. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3360 R=eliben@chromium.org, jvoung@chromium.org Review URL: https://codereview.chromium.org/14569012
2013-05-10LLVM: Add ELF Note section to NaCl object files identifying them as such to goldDerek Schuff
This is needed to switch the native linker to one based on upstream binutils 2.23 R=mseaborn@chromium.org BUG= https://code.google.com/p/nativeclient/issues/detail?id=2971 also related to bug https://code.google.com/p/nativeclient/issues/detail?id=3424 Review URL: https://codereview.chromium.org/15067009
2013-05-08Insert denominator zero checks for NaClDavid Sehr
This IR pass for ARM inserts a comparison and a branch to trap if the denominator of a DIV or REM instruction is zero. This makes ARM fault identically to x86 in this case. BUG= https://code.google.com/p/nativeclient/issues/detail?id=2833 R=eliben@chromium.org Review URL: https://codereview.chromium.org/14607004
2013-05-06Copy llvm-bcanalyzer to build pnacl-bcanalyzer.Karl Schimpf
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3405 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/15013003
2013-05-06Allow pnacl-freeze/thaw to redirect to stdin/stdout.Karl Schimpf
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3405 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/14642019
2013-05-06Fix build warnings/UB in LTOCodeGenerator.cppDerek Schuff
Change the gatherModuleForLinking interface to return void, and add a default case in setMergedModuleOutputFormat to silence gcc warning. BUG=cleanup R=jvoung@chromium.org, mseaborn@chromium.org Review URL: https://codereview.chromium.org/14582019
2013-05-01Copy LLVM bitcode reader to generate a PNaCl wire format reader.Karl Schimpf
Copy classes for LLVM BitcodeReader into a NaCl subdirectory, to create a wire format version. Renames classes/functions to include NaCl prefix, so that they don't conflict with the LLVM Bitcode reader. Also implements pnacl-thaw, showing that we can read the PNaCl wire format files. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3405 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/14314016
2013-04-30Remove unnecessary includes from pnacl-freeze.Karl Schimpf
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3405 Review URL: https://codereview.chromium.org/14322020
2013-04-29Fix CMake build of bitcode wrapper header utility.Derek Schuff
It wasn't even attempting to build before. R=jvoung@chromium.org BUG=cmake/ninja build Review URL: https://codereview.chromium.org/13844019
2013-04-26Check for metadata in PNaCl ABI checker.Jan Voung
Disallow all metadata by default. There is a flag "-allow-debug-metadata", which will be used in pnacl-ld driver, to not change the debugging workflow. That flag will not be present in the pnacl-abicheck driver though. We'll also run -strip-metadata within pnacl-ld, after optimizations are run, so that at least that part is checked inside pnacl-ld. CL for driver changes: https://codereview.chromium.org/14358048/ BUG= http://code.google.com/p/nativeclient/issues/detail?id=3348 R=dschuff@chromium.org Review URL: https://codereview.chromium.org/14329025
2013-04-26Copy Bitwriter to generate PNaClBitwriter.Karl Schimpf
Copy classes for LLVM BitcodeWriter into a PNaCL subdirectory, to create a PNaCL version. Renames classes/methods to include PNaCl prefix so that they don't conflict with the LLVM BitcodeWriter. Also removed experimental support for use-list order preservation. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3405 Review URL: https://codereview.chromium.org/14126011
2013-04-23PNaCl: Add ExpandByVal pass for expanding out by-value struct args and resultsMark Seaborn
This pass expands out the "byval" and "sret" argument attributes. This will affect the calling conventions for PPAPI under PNaCl (for passing PP_Var etc. by value), so the PNaCl PPAPI shims will need to be updated in order to enable this pass by default. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3400 TEST=PNaCl toolchain trybots + GCC torture tests + LLVM test suite + Spec2k Review URL: https://codereview.chromium.org/13973018
2013-04-23PNaCl: Add FlattenGlobals pass for simplifying global variable initializersMark Seaborn
This pass converts initializers for global variables into a flattened normal form which removes nested struct types and simplifies ConstantExprs. In the future, we might change the bitcode format to use the flattened bytes+relocs representation for global initializers. In that case, we will be able to reuse the FlattenedConstant class in the bitcode reader/writer for converting to and from this form. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3113 TEST=test/Transforms/NaCl/flatten-globals.ll Review URL: https://codereview.chromium.org/14017011
2013-04-22Fix bot build of translator, renormalize CMakeLists/LLVMBuild.txt/MakefileDerek Schuff
naming to better match upstream R=jvoung@chromium.org BUG=bot LLVM roll Review URL: https://codereview.chromium.org/14315012
2013-04-18Fix CMake buildDerek Schuff
Clean up the LLVMBuild and CMakeLists.txt files BUG=none TEST=none Review URL: https://codereview.chromium.org/14328017
2013-04-01pnacl-abicheck: Fix exit status so that 256 errors aren't reported as successMark Seaborn
Avoid truncation problems. On Unix, exit(256) is equivalent to exit(0). BUG=https://code.google.com/p/nativeclient/issues/detail?id=2309 TEST=none Review URL: https://codereview.chromium.org/13375007
2013-04-01PNaCl: Allow the ABI checker to be used from "opt"Mark Seaborn
This allows the ABI checker passes to be used in the same way as LLVM's "-verify" pass. It allows the checker to be run between other passes, and without launching pnacl-abicheck as a separate process (so without the overhead of reading bitcode into memory again). Make the ABI checker passes produce fatal errors by default, to match "-verify". This is overridden for pnacl-abicheck's use. BUG=https://code.google.com/p/nativeclient/issues/detail?id=2309 TEST=tested with pnacl-ld.py changes to use the ABI checker passes Review URL: https://codereview.chromium.org/13323006
2013-03-28Add a pass to strip bitcode metadata.Jan Voung
This only works on instruction attachments for now. Since it is a ModulePass we can add something to strip NamedMetadata based on a whitelist, if we want to retain some of that. It does not touch debug metadata, and leaves -strip-debug to handle that. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3348 Review URL: https://codereview.chromium.org/12844027