aboutsummaryrefslogtreecommitdiff
path: root/lib/Bitcode
AgeCommit message (Collapse)Author
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-22Fix default cases for printing instructions/constants in PNaCl wire format.Karl Schimpf
Fix printing of instructions/constants to explicitly check on cast opcodes and binary operators, so that we don't accidentally allow unknown opcodes. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3570 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/19242003
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-18Merge remote-tracking branch 'origin/master'Eli Bendersky
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-15Merge commit '7dfcb84fc16b3bf6b2379713b53090757f0a45f9'Eli Bendersky
Conflicts: docs/LangRef.rst include/llvm/CodeGen/CallingConvLower.h include/llvm/IRReader/IRReader.h include/llvm/Target/TargetMachine.h lib/CodeGen/CallingConvLower.cpp lib/IRReader/IRReader.cpp lib/IRReader/LLVMBuild.txt lib/IRReader/Makefile lib/LLVMBuild.txt lib/Makefile lib/Support/MemoryBuffer.cpp lib/Support/Unix/PathV2.inc lib/Target/ARM/ARMBaseInstrInfo.cpp lib/Target/ARM/ARMISelLowering.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMSubtarget.cpp lib/Target/ARM/ARMTargetMachine.cpp lib/Target/Mips/CMakeLists.txt lib/Target/Mips/MipsDelaySlotFiller.cpp lib/Target/Mips/MipsISelLowering.cpp lib/Target/Mips/MipsInstrInfo.td lib/Target/Mips/MipsSubtarget.cpp lib/Target/Mips/MipsSubtarget.h lib/Target/X86/X86FastISel.cpp lib/Target/X86/X86ISelDAGToDAG.cpp lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86InstrControl.td lib/Target/X86/X86InstrFormats.td lib/Transforms/IPO/ExtractGV.cpp lib/Transforms/InstCombine/InstCombineCompares.cpp lib/Transforms/Utils/SimplifyLibCalls.cpp test/CodeGen/X86/fast-isel-divrem.ll test/MC/ARM/data-in-code.ll tools/Makefile tools/llvm-extract/llvm-extract.cpp tools/llvm-link/CMakeLists.txt tools/opt/CMakeLists.txt tools/opt/LLVMBuild.txt tools/opt/Makefile tools/opt/opt.cpp
2013-07-03Don't generate Type ID's for global variable fields.Karl Schimpf
Also removed local MaxGlobalType in WriteModuleInfo because it calls VE.getTypeID(GV->getTYpe(), which is no longer defined for globals. Also noted that MaxAlignment in WriteModuleInfo was no longer used and removed it. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3541 R=mseaborn@chromium.org Review URL: https://codereview.chromium.org/18185005
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: Remove some LOCALMODs in the upstream bitcode reader/writerMark Seaborn
These were for ELF dynamic linking support, which we are removing. The same LOCALMODs were previously removed from PNaCl's fork of the reader/writer (in https://codereview.chromium.org/17761005/). BUG=https://code.google.com/p/nativeclient/issues/detail?id=3520 TEST=PNaCl toolchain trybots Review URL: https://codereview.chromium.org/17854006
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: Use FORWARDTYPEREF consistently for all forward referencesMark Seaborn
Before this change, the writer would only emit FORWARDTYPEREF for some operands, e.g. the first operand of BINOP but not the second, on the grounds that the type of the second operand can be inferred. However, that makes the format complicated. Change the writer so that it always emits FORWARDTYPEREF for a forward ref. This unifies PushValueAndType() and pushValue(). pushValue() gains a call to EmitFnForwardTypeRef() so becomes the same as PushValueAndType(). Change the reader to be stricter, so that it requires a FORWARDTYPEREF to have been emitted in most cases. This is done by ignoring the implied type argument. Tasks still remaining: * Make reader stricter so that multiple FORWARDTYPEREFs are disallowed. * Remove now-unused Type arguments in the reader. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3507 TEST=new llvm-lit test + PNaCl toolchain trybots Review URL: https://codereview.chromium.org/17806003
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-21Fix warning messages in bitcode encoding functions.Karl Schimpf
BUG=None R=jvoung@chromium.org Review URL: https://codereview.chromium.org/17519003
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-13Remove unused function from PNaCl bitcode writer.Karl Schimpf
BUG=none R=dschuff@chromium.org Review URL: https://codereview.chromium.org/16838018
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-13Fix reading of headers when using a streamable memory object.Karl Schimpf
Fixes bug where we computed the length of fields buffer on the size of a pointer, rather then the actual length of the field. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3485 R=dschuff@chromium.org Review URL: https://codereview.chromium.org/17003002
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-20Create type IDs based on reference counts.Karl Schimpf
Create type IDs based on number of references, rather than first reached. This is done so that fewer bits are used to encode types that are commonly used. Note that this cuts the size of the generate bitcode file by about 1.5%, with no effect on the reader, since it only changes the order type ID's are created. BUG= https://code.google.com/p/nativeclient/issues/detail?id=3405 R=jvoung@chromium.org Review URL: https://codereview.chromium.org/14495008
2013-05-05Add ArrayRef constructor from None, and do the cleanups that this ↵Dmitri Gribenko
constructor enables Patch by Robert Wilhelm. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@181138 91177308-0d34-0410-b5e6-96231b3b80d8
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-01This patch breaks up Wrap.h so that it does not have to include all of Filip Pizlo
the things, and renames it to CBindingWrapping.h. I also moved CBindingWrapping.h into Support/. This new file just contains the macros for defining different wrap/unwrap methods. The calls to those macros, as well as any custom wrap/unwrap definitions (like for array of Values for example), are put into corresponding C++ headers. Doing this required some #include surgery, since some .cpp files relied on the fact that including Wrap.h implicitly caused the inclusion of a bunch of other things. This also now means that the C++ headers will include their corresponding C API headers; for example Value.h must include llvm-c/Core.h. I think this is harmless, since the C API headers contain just external function declarations and some C types, so I don't believe there should be any nasty dependency issues here. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180881 91177308-0d34-0410-b5e6-96231b3b80d8
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-26Fix CMake build of NaClBitWriterDerek Schuff
TBR=kschimpf@google.com BUG=none Review URL: https://codereview.chromium.org/14520020
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-22Move C++ code out of the C headers and into either C++ headersEric Christopher
or the C++ files themselves. This enables people to use just a C compiler to interoperate with LLVM. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@180063 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-01Whitespace cleanupJoe Abbey
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@178454 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-11Merge commit '279b9184c2ff4fea93b198a3519b8cb3a1d8d195'Eli Bendersky
Conflicts: include/llvm/CodeGen/LexicalScopes.h include/llvm/MC/MCAsmInfo.h lib/Linker/LinkArchives.cpp lib/Linker/LinkItems.cpp lib/MC/MCAsmInfo.cpp lib/MC/MCDwarf.cpp lib/Target/ARM/ARMInstrInfo.td lib/Target/ARM/ARMSubtarget.cpp lib/Target/ARM/MCTargetDesc/ARMMCTargetDesc.cpp lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp lib/Target/Mips/MCTargetDesc/MipsMCTargetDesc.cpp lib/Target/Mips/MipsAsmPrinter.cpp lib/Target/Mips/MipsDelaySlotFiller.cpp lib/Target/Mips/MipsISelDAGToDAG.cpp lib/Target/Mips/MipsSubtarget.cpp lib/Target/Mips/MipsSubtarget.h lib/Target/Mips/MipsTargetObjectFile.cpp lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp lib/Target/X86/X86FastISel.cpp lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86TargetMachine.cpp lib/Transforms/CMakeLists.txt lib/Transforms/LLVMBuild.txt lib/Transforms/Makefile test/MC/ARM/arm_instructions.s test/MC/X86/AlignedBundling/pad-align-to-bundle-end.s
2013-02-19Simplify code. No functionality change.Jakub Staszak
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@175501 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-12Have the bitcode writer and reader handle the new attribute references.Bill Wendling
The bitcode writer emits a reference to the attribute group that the object at the given index refers to. The bitcode reader is modified to read this in and map it back to the attribute group. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174952 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-12Use the AttributeSet as the 'key' to the map instead of the 'raw' pointer.Bill Wendling
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174950 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-11Rename AttributeSets to AttributeGroups so that it's more meaningful.Bill Wendling
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174911 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-11Use a std::map so that we record the group ID.Bill Wendling
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174910 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-11[tsan/msan] adding thread_safety and uninitialized_checks attributesKostya Serebryany
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174864 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-11Fix unnecessary removal of const through cast machineryDavid Blaikie
I have some uncommitted changes to the cast code that catch this sort of thing at compile-time but I still need to do some other cleanup before I can enable it. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174853 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-10Add support in the bitcode reader to read the attribute groups.Bill Wendling
This reads the attribute groups. It currently doesn't do anything with them. NOTE: In the commit to the bitcode writer, the format *may* change in the near future. Which means that this code would also change. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174849 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-10Add code for emitting the attribute groups.Bill Wendling
This is some initial code for emitting the attribute groups into the bitcode. NOTE: This format *may* change! Do not rely upon the attribute groups' bitcode not changing. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174845 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-10Add support for attribute groups in the value enumerator.Bill Wendling
Attribute groups are essentially all AttributeSets which are used by the program. Enumerate them here. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174844 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-09Fix the underlying problem that was causing read(0) to be called: sometimes theChris Lattner
bitcode writer would generate abbrev records saying that the abbrev should be filled with fixed zero-bit bitfields (this happens in the .bc writer when the number of types used in a module is exactly one, since log2(1) == 0). In this case, just handle it as a literal zero. We can't "just fix" the writer without breaking compatibility with existing bc files, so have the abbrev reader do the substitution. Strengthen the assert in read to reject reads of zero bits so we catch such crimes in the future, and remove the special case designed to handle this. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174801 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-06Code Custodian (trivial whitespace cleanup)Joe Abbey
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174550 91177308-0d34-0410-b5e6-96231b3b80d8