aboutsummaryrefslogtreecommitdiff
path: root/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp
AgeCommit message (Collapse)Author
2013-08-28Handle pointer conversions for call instructions.Karl Schimpf
This also should complete the changes associated with removing pointer cast instructions from the PNaCl bitcode file. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3544 R=dschuff@chromium.org, jvoung@chromium.org Review URL: https://codereview.chromium.org/23482002
2013-08-26Elide pointer to int casts on phi nodes.Karl Schimpf
Handles the eliding of pointer to integer casts operands of the phi node. Also caches unelided casts generated in the reader (removing duplicates within the same block). This reduces the size of thawed pnacl-llc.pexe by about 2%. BUG= https://code.google.com/p/nativeclient/issues/detailid=3544 R=mseaborn@chromium.org Review URL: https://codereview.chromium.org/22909016
2013-08-23PNaCl bitcode: Remove support for TYPE_CODE_FUNCTION_OLDMark Seaborn
PNaCl uses TYPE_CODE_FUNCTION instead, as you'd expect. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3590 TEST=PNaCl toolchain trybots Review URL: https://codereview.chromium.org/22819015
2013-08-23PNaCl bitcode: Remove support for string constant valuesMark Seaborn
These are no longer used since we introduced the GLOBALVAR block for PNaCl, in which global variable initialisers are flattened. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3590 TEST=PNaCl toolchain trybots Review URL: https://codereview.chromium.org/22903045
2013-08-14Remove ptrtoint instructions from the PNaCl bitcode file.Karl Schimpf
Removes ptrtoint instructions when applicable (currently only in stores), and add them back just before their use. Note: This code does not handle ptrtoint casts for calls and phi nodes, binary operators, etc. because handling of casts for these instructions has not been added yet. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3544 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/22633002
2013-08-05Fix handling of the volatile bit of loads/stores in PNaCl bitcode files.Karl Schimpf
Fixes so that the volatile bit is no longer put into the bitcode file, since the volatile bit is not in the PNaCl ABI. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3610 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/21949006
2013-08-02Remove unnecessary pointer casts on store instructions.Karl Schimpf
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3544 R=mseaborn@chromium.org Review URL: https://codereview.chromium.org/21964002
2013-08-02Remove the bitcast (of global values) from load instructions.Karl Schimpf
Adds the eliding of bitcasts that are used as an argument to instructions that expect normalized pointers. Currently, the checked in code only checks normalized pointers for load instructions. Hence, the restriction to load instructions. As more instructions are modified to check for normalized pointers, this code will apply to those instructions. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3544 R=mseaborn@chromium.org Review URL: https://codereview.chromium.org/21614002
2013-08-01Remove the inttoptr dependency from load instructions.Karl Schimpf
Elides inttoptr casts used (exclusively) in load instructions when PNaClVersion=2. This is an incremental start on removing the inttoptr instruction from the PNaCl wire format (See issue 3544 for more information on the strategy of removing ptrtoint). Also modifies PNaCl bitcode reader/writer to accept PNaClVersion=1 as supported, and PNaClVersion=2 as unsupported but readable (allowing pnacl-freeze and pnacl-thaw to work on such files). Also allows command-line option --pnacl-version for setting PNaClVersion in the PNaCl bitcode writer. Also fixes some problems on PNaCl bitcode headers, using common support to determine when the read/written PNaCl bitcode file is valid. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3544 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/5812155903377408
2013-07-29Remove handling of nongenerable instructions in PNaCl reader.Karl Schimpf
The PNaCl bitcode writer doesn't generate certain forms of instructions that the PNaCl bitcode writer accepts. Since these instructions do not get generated, remove them from the bitcode reader. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3590 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/20442002
2013-07-25Remove block address constants form PNaCl bitcode.Karl Schimpf
Removes block address constants because they are not part of the PNaClABI. Suggested in CL https://codereview.chromium.org/20172002 BUG= https://code.google.com/p/nativeclient/issues/detail?id=3590 R=mseaborn@chromium.org Review URL: https://codereview.chromium.org/20402002
2013-07-25Remove dead instructions from the PNaCl bitcode reader/writer:Karl Schimpf
VAArg Invoke GetElementPtr LandingPad Resume IndirectBr ExtractElement InsertElement ShuffleVector ExtractValue InsertValue AtomicCmpXchg AtomicRMW BUG= https://code.google.com/p/nativeclient/issues/detail?id=3590 R=mseaborn@chromium.org Review URL: https://codereview.chromium.org/20124002
2013-07-25Remove constant expressions and constant inline assembly from the PNaClKarl Schimpf
reader/writer, since they can't appear in PNaCl bitcode. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3590 R=mseaborn@chromium.org Review URL: https://codereview.chromium.org/20172002
2013-07-22Enable ability to have multiple PNaCl wire format versions.Karl Schimpf
Modifies PNaCl bitcode reader/writer to accept PNaClVersion=1 as supported, and all other versions are unsupported and unreadable. The PNaCl bitcode reader/writer will generate appropriate messages (including what version is unsupported if applicable). Also allows command-line option --pnacl-version for setting the PNaClVersion in the PNaCl bitcode writer. Also fixes some problems on PNaCl bitcode headers, using common support to determine when the read/written PNaCl bitcode file is valid. BUG=None R=jvoung@chromium.org Review URL: https://codereview.chromium.org/19400002
2013-07-22Remove module info records not allowed by PNaCl from the bitcode.Karl Schimpf
Remove dead code for: (1) Top-level inline assembly. (2) Remove code for named sections. (3) Remove code for GC names. (4) Global variable aliases. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3405 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/18770005
2013-07-16Remove useless field InstructionList from NaClBitcodeReader.Karl Schimpf
BUG=None R=mseaborn@chromium.org Review URL: https://codereview.chromium.org/19284013
2013-07-02Simplify globals in PNaCl wire format based on normalized constants.Karl Schimpf
Generates simple global variable records, followed by list of records defining byte initialization and relocations. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3504 R=mseaborn@chromium.org Review URL: https://codereview.chromium.org/18111002
2013-06-26PNaCl pexe reader: Remove now-unused Type argument from getValue()/popValue()Mark Seaborn
Before this change, NaClBitcodeReader had some icky use of C++ function overloading and reference types. Whether getValue() modified its Slot argument depended on whether it was passed a Type argument, which wasn't very readable: // Modifies Slot. bool getValue(SmallVector<uint64_t, 64> &Record, unsigned &Slot, unsigned InstNum, Value *&ResVal); // Does not modify Slot. bool getValue(SmallVector<uint64_t, 64> &Record, unsigned Slot, unsigned InstNum, Type *Ty, Value *&ResVal); // Does not modify Slot. Value *getValue(SmallVector<uint64_t, 64> &Record, unsigned Slot, unsigned InstNum, Type *Ty); So, do these cleanups: * Convert non-const reference arguments to pointers. (Also add "const" to the Record argument.) * Remove the unused Type argument from getValue()/popValue(). * Remove the getValue() case that was identical to popValue(). Call popValue() instead. Now popValue() modifies *Slot and getValue() does not. * Remove an unused getValue() case. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3507 TEST=PNaCl toolchain trybots Review URL: https://codereview.chromium.org/17938002
2013-06-26PNaCl wire format: Disallow duplicate FORWARDTYPEREFs for the same value IDMark Seaborn
Change the reader to be stricter so that duplicate FORWARDTYPEREFs are rejected. Also fix typo in error message. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3507 TEST=see "Invalid FORWARDTYPEREF record" if EmitFnForwardTypeRef() is changed to produce unnecessary FORWARDTYPEREFs Review URL: https://codereview.chromium.org/17925002
2013-06-26PNaCl wire format: Remove the METADATA_BLOCK block from pexesMark Seaborn
Despite removing metadata at the IR level, the writer was still outputting a METADATA_BLOCK containing built-in strings such as "dbg", "tbaa" and "fpmath". Remove this by removing metadata support from the reader and writer. I've removed most references to "metadata" and "MD". I've also removed DEBUG_LOC handling, since that depends on MDValueList in the reader. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3518 TEST=PNaCl toolchain trybots + check hello_world.final.pexe in bcanalyzer Review URL: https://codereview.chromium.org/17761005
2013-06-26PNaCl wire format: Clean up representation of "alloca" instructionMark Seaborn
For some reason, the size operand of "alloca" was represented using an absolute value ID + type, unlike other instructions where relative value IDs are used. Change the "alloca" representation to be consistent with other instructions, so that we can use PushValueAndType() in the writer and getValue() in the reader. Also take this opportunity to remove the field for alloca's result type, since it's always i8* in PNaCl. This is part of a cleanup to make forward reference handling stricter: it removes a use of getOrCreateFnValueByID(), which isn't strict (that is, it doesn't reject duplicate FORWARDTYPEREF records). BUG=https://code.google.com/p/nativeclient/issues/detail?id=3507 TEST=PNaCl toolchain trybots Review URL: https://codereview.chromium.org/17757004
2013-06-26PNaCl wire format: Remove magic number and hash from encoding of 'switch'Mark Seaborn
The magic number is no longer needed now that the reader for the old switch representation has been removed (in https://codereview.chromium.org/17764003), so we can remove this baggage. Also add a missing record size check to the reader. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3507 TEST=hello_world.pexe includes a switch statement; also PNaCl toolchain trybots Review URL: https://codereview.chromium.org/17777005
2013-06-25PNaCl wire format: Remove code for reading old SwitchInst representationMark Seaborn
The PNaCl pexe writer never writes this old representation. This is part of a cleanup to make forward reference handling stricter: it removes a use of getOrCreateFnValueByID(), which isn't strict (that is, it doesn't reject duplicate FORWARDTYPEREF records). BUG=https://code.google.com/p/nativeclient/issues/detail?id=3507 TEST=PNaCl toolchain trybots Review URL: https://codereview.chromium.org/17764003
2013-06-25PNaCl wire format: Remove the top-level DATALAYOUT recordMark Seaborn
PNaCl only supports a fixed data layout, so treat this as implicit in the pexe file. Add the data layout field back at read time, to prevent accidentally using any architecture-specific backend data layout when translating, and to ensure that any IR passes that use the data layout work correctly. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3505 TEST=*.ll tests + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/17591014
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-23PNaCl wire format: Remove the top-level TRIPLE recordMark Seaborn
Currently, the triple that gets put into pexes is "armv7-none-linux-gnueabi". This is a wart that we don't want to keep. We can remove the triple entirely; PNaCl doesn't need it. We don't need to add a triple back at read time: (pnacl-)llc tells the backend explicitly what target to use. I'm leaving MODULE_CODE_TRIPLE defined in the enum for now because pnacl-bcanalyzer still refers to it. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3505 TEST=PNaCl toolchain trybots + GCC torture tests + Spec2k Review URL: https://codereview.chromium.org/17321009
2013-06-21PNaCl wire format: Remove function attributes from pexe reader/writerMark Seaborn
Remove support for reading and writing the PARAMATTR_BLOCK_ID and PARAMATTR_GROUP_BLOCK_ID blocks. These blocks will no longer be written into pexes. While PNaCl doesn't allow function attributes on normal functions, Function::Create() always inserts them back on intrinsics, so previously the PARAMATTR blocks were being written into pexes. Remove paramattr fields from two record types: * MODULE_CODE_FUNCTION records (function declarations). Also remove the fields that follow paramattr, which PNaCl also does not use. * FUNC_CODE_INST_CALL (function calls). BUG=https://code.google.com/p/nativeclient/issues/detail?id=3506 TEST=PNaCl toolchain trybots + GCC torture tests + Spec2k Review URL: https://codereview.chromium.org/17419013
2013-06-19Insulate calling conventions in PNaCl bitcode files.Karl Schimpf
Creates a bitcode-local enumeration for calling conventions for the PNaCl bitcode file, so that the bitcode file is better protected from (accidental) changes in LLVM code. Also removes invokes from the bitcode. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3497 R=dschuff@chromium.org, mseaborn@chromium.org Review URL: https://codereview.chromium.org/17118002
2013-06-13Insulate PNaCl bitcode from LLVM encodings of floating point optimization flags.Karl Schimpf
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3405 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/16836017
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-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-02Copy BitCodes.h to NaCl/NaClBitCodes.hKarl Schimpf
Create NaCl specific version of BitCodes.h so that we can custimize it for the PNaCl wire format. Moves enums to namespace naclbitc. Renames classes using NaCl prefix. Fixes references so that files compiles. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3405 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/14682013
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