From llvm at cs.uiuc.edu Mon Jul 5 03:19:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Mon Jul 5 03:19:01 2004 Subject: [llvm-commits] CVS: llvm/docs/BytecodeFormat.html Message-ID: <200407050818.DAA25906@zion.cs.uiuc.edu> Changes in directory llvm/docs: BytecodeFormat.html updated: 1.11 -> 1.12 --- Log message: - Reorganized the document contents - Provided a "General Layout" section that currently covers just the block structure of the bytecode file. - Wrote the section on the Global Type Pool - Wrote the section on differences between LLVM file format versions. Only five sections left to write! --- Diffs of the changes: (+469 -208) Index: llvm/docs/BytecodeFormat.html diff -u llvm/docs/BytecodeFormat.html:1.11 llvm/docs/BytecodeFormat.html:1.12 --- llvm/docs/BytecodeFormat.html:1.11 Mon Jun 21 18:29:40 2004 +++ llvm/docs/BytecodeFormat.html Mon Jul 5 03:18:07 2004 @@ -4,24 +4,31 @@ LLVM Bytecode File Format -
LLVM Bytecode File Format
  1. Abstract
  2. -
  3. General Concepts +
  4. Concepts
    1. Blocks
    2. Lists
    3. Fields
    4. -
    5. Slots
    6. -
    7. Encoding Rules
    8. Alignment
    9. +
    10. Encoding Primitives
    11. +
    12. Slots
    13. +
    +
  5. +
  6. General Layout +
      +
    1. Structure
  7. Detailed Layout @@ -30,11 +37,13 @@
  8. Blocks Types
  9. Signature Block
  10. Module Block
  11. -
  12. Global Type Pool
  13. -
  14. Module Info Block
  15. -
  16. Global Constant Pool
  17. -
  18. Function Blocks
  19. -
  20. Module Symbol Table
  21. +
  22. Global Type Pool
  23. +
  24. Module Info Block
  25. +
  26. Global Constant Pool
  27. +
  28. Function Definition
  29. +
  30. Compaction Table
  31. +
  32. Instruction List
  33. +
  34. Symbol Table
  • Version Differences @@ -52,19 +61,21 @@

    Warning: This is a work in progress.

    +
    Abstract
    -

    This document describes the LLVM bytecode -file format. It specifies the binary encoding rules of the bytecode file format +

    This document describes the LLVM bytecode file format as of version 1.3. +It specifies the binary encoding rules of the bytecode file format so that equivalent systems can encode bytecode files correctly. The LLVM bytecode representation is used to store the intermediate representation on disk in compacted form.

    + -
    General Concepts
    +
    Concepts

    This section describes the general concepts of the bytecode file format @@ -73,48 +84,42 @@ older formats. This document only describes the most current version of the bytecode format.

    +
    Blocks

    LLVM bytecode files consist simply of a sequence of blocks of bytes. -Each block begins with an identification value that determines the type of -the next block. The possible types of blocks are described below in the section -Block Types. The block identifier is used because -it is possible for entire blocks to be omitted from the file if they are -empty. The block identifier helps the reader determine which kind of block is -next in the file.

    -

    The following block identifiers are currently in use -(from llvm/Bytecode/Format.h):

    -
      -
    1. Module (0x01).
    2. -
    3. Function (0x11).
    4. -
    5. ConstantPool (0x12).
    6. -
    7. SymbolTable (0x13).
    8. -
    9. ModuleGlobalInfo (0x14).
    10. -
    11. GlobalTypePlane (0x15).
    12. -
    13. BasicBlock (0x31).
    14. -
    15. InstructionList (0x32).
    16. -
    17. CompactionTable (0x33).
    18. -
    +Each block begins with an header of two unsigned integers. The first value +identifies the type of block and the second value provides the size of the +block in bytes. The block identifier is used because it is possible for entire +blocks to be omitted from the file if they are empty. The block identifier helps +the reader determine which kind of block is next in the file. Note that blocks +can be nested within other blocks.

    All blocks are variable length, and the block header specifies the size of -the block. All blocks are rounded aligned to even 32-bit boundaries, so they -always start and end of this boundary. Each block begins with an integer -identifier and the length of the block, which does not include the padding -bytes needed for alignment.

    +the block. All blocks begin on a byte index that is aligned to an even 32-bit +boundary. That is, the first block is 32-bit aligned because it starts at offset +0. Each block is padded with zero fill bytes to ensure that the next block also +starts on a 32-bit boundary.

    +
    Lists
    -

    Most blocks are constructed of lists of information. Lists can be constructed -of other lists, etc. This decomposition of information follows the containment -hierarchy of the LLVM Intermediate Representation. For example, a function -contains a list of instructions (the terminator instructions implicitly define -the end of the basic blocks).

    -

    A list is encoded into the file simply by encoding the number of entries as -an integer followed by each of the entries. The reader knows when the list is -done because it will have filled the list with the required numbe of entries. -

    +

    LLVM Bytecode blocks often contain lists of things of a similar type. For + example, a function contains a list of instructions and a function type + contains a list of argument types. There are two basic types of lists: + length lists, and null terminated lists, as described here:

    +
    +
    Fields
    @@ -129,46 +134,16 @@ sections that follow will provide the details on how these fields are written and how the bits are to be interpreted.

    + -
    Slots
    +
    Alignment
    -

    The bytecode format uses the notion of a "slot" to reference Types and -Values. Since the bytecode file is a direct representation of LLVM's -intermediate representation, there is a need to represent pointers in the file. -Slots are used for this purpose. For example, if one has the following assembly: -

    - -
    - %MyType = type { int, sbyte }
    - %MyVar = external global %MyType +

    To support cross-platform differences, the bytecode file is aligned on + certain boundaries. This means that a small amount of padding (at most 3 + bytes) will be added to ensure that the next entry is aligned to a 32-bit + boundary.

    -

    there are two definitions. The definition of %MyVar uses -%MyType. In the C++ IR this linkage between %MyVar and -%MyType is -explicit through the use of C++ pointers. In bytecode, however, there's no -ability to store memory addresses. Instead, we compute and write out slot -numbers for every type and Value written to the file.

    -

    A slot number is simply an unsigned 32-bit integer encoded in the variable -bit rate scheme (see encoding below). This ensures that -low slot numbers are encoded in one byte. Through various bits of magic LLVM -attempts to always keep the slot numbers low. The first attempt is to associate -slot numbers with their "type plane". That is, Values of the same type are -written to the bytecode file in a list (sequentially). Their order in that list -determines their slot number. This means that slot #1 doesn't mean anything -unless you also specify for which type you want slot #1. Types are handled -specially and are always written to the file first (in the Global Type Pool) and -in such a way that both forward and backward references of the types can often be -resolved with a single pass through the type pool.

    -

    Slot numbers are also kept small by rearranging their order. Because of the -structure of LLVM, certain values are much more likely to be used frequently -in the body of a function. For this reason, a compaction table is provided in -the body of a function if its use would make the function body smaller. -Suppose you have a function body that uses just the types "int*" and "{double}" -but uses them thousands of time. Its worthwhile to ensure that the slot number -for these types are low so they can be encoded in a single byte (via vbr). -This is exactly what the compaction table does.

    -
    Encoding Primitives
    @@ -219,80 +194,196 @@ - + - - + - - + - - + - - + - - + + - - + + - - + - - + + + +
    TypeRuleRule
    unsignedA 32-bit unsigned integer that always occupies four + unsignedA 32-bit unsigned integer that always occupies four consecutive bytes. The unsigned integer is encoded using LSB first ordering. That is bits 20 through 27 are in the byte with the lowest file offset (little endian).
    uint_vbrA 32-bit unsigned integer that occupies from one to five + uint_vbrA 32-bit unsigned integer that occupies from one to five bytes using variable bit rate encoding.
    uint64_vbrA 64-bit unsigned integer that occupies from one to ten + uint64_vbrA 64-bit unsigned integer that occupies from one to ten bytes using variable bit rate encoding.
    int64_vbrA 64-bit signed integer that occupies from one to ten + int64_vbrA 64-bit signed integer that occupies from one to ten bytes using the signed variable bit rate encoding.
    charA single unsigned character encoded into one bytecharA single unsigned character encoded into one byte
    bitA single bit within a byte.bitA single bit within some larger integer field.
    stringA uint_vbr indicating the length of the character string + stringA uint_vbr indicating the length of the character string immediately followed by the characters of the string. There is no terminating null byte in the string.
    dataAn arbitrarily long segment of data to which no + dataAn arbitrarily long segment of data to which no interpretation is implied. This is used for float, double, and constant initializers.
    blockA block of data that is logically related. A block + begins with an unsigned that provides the block + identifier (constant value) and an unsigned that + provides the length of the block. Blocks may compose other blocks. +
    + -
    Alignment
    +
    Slots
    -

    To support cross-platform differences, the bytecode file is aligned on -certain boundaries. This means that a small amount of padding (at most 3 bytes) -will be added to ensure that the next entry is aligned to a 32-bit boundary. +

    The bytecode format uses the notion of a "slot" to reference Types and +Values. Since the bytecode file is a direct representation of LLVM's +intermediate representation, there is a need to represent pointers in the file. +Slots are used for this purpose. For example, if one has the following assembly:

    +
    + %MyType = type { int, sbyte }
    + %MyVar = external global %MyType +
    +

    there are two definitions. The definition of %MyVar uses +%MyType. In the C++ IR this linkage between %MyVar and +%MyType is +explicit through the use of C++ pointers. In bytecode, however, there's no +ability to store memory addresses. Instead, we compute and write out slot +numbers for every Type and Value written to the file.

    +

    A slot number is simply an unsigned 32-bit integer encoded in the variable +bit rate scheme (see encoding). This ensures that +low slot numbers are encoded in one byte. Through various bits of magic LLVM +attempts to always keep the slot numbers low. The first attempt is to associate +slot numbers with their "type plane". That is, Values of the same type are +written to the bytecode file in a list (sequentially). Their order in that list +determines their slot number. This means that slot #1 doesn't mean anything +unless you also specify for which type you want slot #1. Types are handled +specially and are always written to the file first (in the +Global Type Pool) and +in such a way that both forward and backward references of the types can often be +resolved with a single pass through the type pool.

    +

    Slot numbers are also kept small by rearranging their order. Because of the +structure of LLVM, certain values are much more likely to be used frequently +in the body of a function. For this reason, a compaction table is provided in +the body of a function if its use would make the function body smaller. +Suppose you have a function body that uses just the types "int*" and "{double}" +but uses them thousands of time. Its worthwhile to ensure that the slot number +for these types are low so they can be encoded in a single byte (via vbr). +This is exactly what the compaction table does.

    + + +
    General Layout
    + +
    +

    This section provides the general layout of the LLVM bytecode file format. + The detailed layout can be found in the next section. +

    +
    + + +
    Structure
    +
    +

    The bytecode file format requires blocks to be in a certain order and +nested in a particular way so that an LLVM module can be constructed +efficiently from the contents of the file. This ordering defines a general +structure for bytecode files as shown below. The table below shows the order +in which all block types may appear. Please note that some of the blocks are +optional and some may be repeated. The structure is fairly loose because +optional blocks, if empty, are completely omitted from the file. +

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    IDParentOptional?Repeated?LevelBlock Type
    N/AFileNoNo0Signature
    0x01FileNoNo0Module
    0x15ModuleNoNo1    + Global Type Pool
    0x14ModuleNoNo1    + Module Globals Info
    0x12ModuleYesNo1    + Module Constant Pool
    0x11ModuleYesYes1    + Function Definitions
    0x12FunctionYesNo2       + Function Constant Pool
    0x33FunctionYesNo2       + Compaction Table
    0x32FunctionNoNo2       + Instruction List
    0x13FunctionYesNo2       + Function Symbol Table
    0x13ModuleYesNo1    + Module Symbol Table
    +

    Use the links in the table or see Block Types for +details about the contents of each of the block types.

    +
    +
    Detailed Layout

    This section provides the detailed layout of the LLVM bytecode file format. -bit and byte level specifics.

    +

    Notation
    -

    The descriptions of the bytecode format that follow describe the bit - fields in detail. These descriptions are provided in tabular form. Each table - has four columns that specify:

    -
      -
    1. Byte(s): The offset in bytes of the field from the start of - its container (block, list, other field).
    2. -
    3. Bit(s): The offset in bits of the field from the start of - the byte field. Bits are always little endian. That is, bit addresses with - smaller values have smaller address (i.e. 20 is at bit 0, - 21 at 1, etc.) -
    4. -
    5. Align?: Indicates if this field is aligned to 32 bits or not. - This indicates where the next field starts, always on a 32 bit - boundary.
    6. -
    7. Type: The basic type of information contained in the field.
    8. -
    9. Description: Describes the contents of the field.
    10. -
    +

    The descriptions of the bytecode format that follow describe the order, type +and bit fields in detail. These descriptions are provided in tabular form. +Each table has four columns that specify:

    +
      +
    1. Byte(s): The offset in bytes of the field from the start of + its container (block, list, other field).
    2. +
    3. Bit(s): The offset in bits of the field from the start of + the byte field. Bits are always little endian. That is, bit addresses with + smaller values have smaller address (i.e. 20 is at bit 0, + 21 at 1, etc.) +
    4. +
    5. Align?: Indicates if this field is aligned to 32 bits or not. + This indicates where the next field starts, always on a 32 bit + boundary.
    6. +
    7. Type: The basic type of information contained in the field.
    8. +
    9. Description: Describes the contents of the field.
    10. +
    Block Types
    @@ -330,90 +421,109 @@ of the block. Essentially, this block is just the "magic number" for the file. - - - - + - - + + - - + + - - + + - - + +
    Byte(s)Bit(s)Align? TypeField DescriptionField Description
    00-NocharConstant "l" (0x6C)charConstant "l" (0x6C)
    01-NocharConstant "l" (0x6C)charConstant "l" (0x6C)
    02-NocharConstant "v" (0x76)charConstant "v" (0x76)
    03-NocharConstant "m" (0x6D)charConstant "m" (0x6D)
    +
    Module Block

    The module block contains a small pre-amble and all the other blocks in -the file. Of particular note, the bytecode format number is simply a 28-bit -monotonically increase integer that identifiers the version of the bytecode -format (which is not directly related to the LLVM release number). The -bytecode versions defined so far are (note that this document only describes -the latest version):

    - - - -

    The table below shows the format of the module block header. It is defined -by blocks described in other sections.

    +the file. The table below shows the structure of the module block. Note that it +only provides the module identifier, size of the module block, and the format +information. Everything else is contained in other blocks, described in other +sections.

    - - - - + - - + + - - + + - - + + - - + + - - + + - - + + - - + + - - - - - + +
    Byte(s)Bit(s)Align? TypeField DescriptionField Description
    04-07-NounsignedModule Identifier (0x01)unsignedModule Identifier (0x01)
    08-11-NounsignedSize of the module block in bytesunsignedSize of the module block in bytes
    12-1500Yesuint32_vbrFormat Informationuint32_vbrFormat Information
    ''0-bitBig Endian?blockGlobal Type Pool
    ''1-bitPointers Are 64-bit?blockModule Globals Info
    ''2-bitHas No Endianess?blockModule Constant Pool
    ''3-bitHas No Pointer Size?blockFunction Definitions
    ''4-31-bitBytecode Format Version
    16-end--blocksThe remaining bytes in the block consist - solely of other block types in sequence.blockModule Symbol Table
    +
    + +
    Format Information
    +
    +

    The format information field is encoded into a 32-bit vbr-encoded unsigned +integer as shown in the following table.

    + + + + + + + + + + + + + + + + + + + + + +
    Bit(s)TypeDescription
    0bitBig Endian?
    1bitPointers Are 64-bit?
    2bitHas No Endianess?
    3bitHas No Pointer Size?
    4-31bitBytecode Format Version
    +

    +Of particular note, the bytecode format number is simply a 28-bit +monotonically increase integer that identifies the version of the bytecode +format (which is not directly related to the LLVM release number). The +bytecode versions defined so far are (note that this document only describes +the latest version, 1.3):

    +

    Note that we plan to eventually expand the target description capabilities -of bytecode files to target -triples.

    - +of bytecode files to target triples. +

    -
    Global Type Pool
    +
    Global Type Pool

    The global type pool consists of type definitions. Their order of appearance in the file determines their slot number (0 based). Slot numbers are used to @@ -423,48 +533,161 @@ pool is written, the global type pool must be written as the first block of a module. If it is not, attempts to read the file will fail because both forward and backward type resolution will not be possible.

    -

    The type pool is simply a list of types definitions, as shown in the table +

    The type pool is simply a list of type definitions, as shown in the table below.

    - - - - + - - + + - - + + - - + + - - + + + + + +
    Byte(s)Bit(s)Align? TypeField DescriptionField Description
    00-03-NounsignedType Pool Identifier (0x13)unsignedType Pool Identifier (0x13)
    04-07-NounsignedSize in bytes of the symbol table block.unsignedSize in bytes of the symbol table block.
    08-111-Nouint32_vbrNumber of entries in type planeuint32_vbrNumber of entries in type plane
    12-151-Nouint32_vbrType plane index for following entriestypeEach of the type definitions (see below)1
    + 1Repeated field.
    +
    +
    + +
    Type Definitions
    +
    +

    Types in the type pool are defined using a different format for each +basic type of type as given in the following sections.

    +

    Primitive Types

    +

    The primitive types encompass the basic integer and floating point types

    + + + + - - + + - + +
    TypeDescription
    16-end1,2-NotypeEach of the type definitions.uint32_vbrType ID For The Primitive (1-11)1
    1Maximum length shown, - may be smaller
    2Repeated field. +
    + 1See the definition of Type::TypeID in Type.h for the numeric + equivalents of the primitive type ids.
    +
    +

    Function Types

    + + + + + + + + + + + + + + + + + + + + + + +
    TypeDescription
    uint32_vbrType ID for function types (13)
    uint32_vbrSlot number of function's return type.
    uint32_vbrThe number of arguments in the function.
    uint32_vbrSlot number of each argument's type.1
    uint32_vbrValue 0 if this is a varargs function.2
    + 1Repeated field.
    + 2Optional field. +
    +

    Structure Types

    + + + + + + + + + + + + + + + + +
    TypeDescription
    uint32_vbrType ID for structure types (14)
    uint32_vbrSlot number of each of the element's fields.1
    uint32_vbrNull Terminator (VoidTy type id)
    + 1Repeated field.
    +
    +

    Array Types

    + + + + + + + + + + + + +
    TypeDescription
    uint32_vbrType ID for Array Types (15)
    uint32_vbrSlot number of array's element type.
    uint32_vbrThe number of elements in the array.
    +

    Pointer Types

    + + + + + + + + + + + +
    TypeDescription
    uint32_vbrType ID For Pointer Types (16)
    uint32_vbrSlot number of pointer's element type.
    +

    Opaque Types

    + + + + + + + + +
    TypeDescription
    uint32_vbrType ID For Opaque Types (17)
    +
    + +
    Module Global Info
    +
    +

    To be determined.

    -
    Module Info
    +
    Constant Pool

    To be determined.

    -
    Constants
    +
    Function Definition

    To be determined.

    -
    Functions
    +
    Compaction Table
    +
    +

    To be determined.

    +
    + +
    Instruction List

    To be determined.

    @@ -483,28 +706,28 @@ Bit(s) Align? Type - Field Description + Field Description 00-03-Nounsigned - Symbol Table Identifier (0x13) + Symbol Table Identifier (0x13) 04-07-Nounsigned - Size in bytes of the symbol table block. + Size in bytes of the symbol table block. 08-111-Nouint32_vbr - Number of entries in type plane + Number of entries in type plane 12-151-Nouint32_vbr - Type plane index for following entries + Type plane index for following entries 16-191,2-Nouint32_vbr - Slot number of a value. + Slot number of a value. variable1,2-Nostring - Name of the value in the symbol table. + Name of the value in the symbol table. - 1Maximum length shown, + 1Maximum length shown, may be smaller
    2Repeated field. @@ -522,22 +745,60 @@
    Version 1.2 Differences From 1.3
    + +
    Type Derives From Value
    -

    TBD: How version 1.2 differs from version 1.3

    +

    In version 1.2, the Type class in the LLVM IR derives from the Value class. + This is not the case in version 1.3. Consequently, in version 1.2 the notion + of a "Type Type" was used to write out values that were Types. The types + always occuped plane 12 (corresponding to the TypeTyID) of any type planed + set of values. In 1.3 this representation is not convenient because the + TypeTyID (12) is not present and its value is now used for LabelTyID. + Consequently, the data structures written that involve types do so by writing + all the types first and then each of the value planes according to those + types. In version 1.2, the types would have been written intermingled with + the values.

    +
    + + +
    Restricted getelementptr Types
    +
    +

    In version 1.2, the getelementptr instruction required a ubyte type index + for accessing a structure field and a long type index for accessing an array + element. Consequently, it was only possible to access structures of 255 or + fewer elements. Starting in version 1.3, this restriction was lifted. + Structures must now be indexed with int or uint types. Arrays must now be + indexed with long or ulong types. This requirement was needed so that LLVM + could compile several test cases that used large numbers of fields in their + structures. The consequence of this was that the bytecode format had to + change in order to accommodate the larger range of structure indices.

    Version 1.1 Differences From 1.2
    + +
    Explicit Primitive Zeros
    +
    +

    In version 1.1, the zero value for primitives was explicitly encoded into + the bytecode format. Since these zero values are constant values in the + LLVM IR and never change, there is no reason to explicitly encode them. This + explicit encoding was removed in version 1.2.

    +
    + + +
    Inconsistent Module Global Info
    -

    TBD: How version 1.1 differs from version 1.2

    +

    In version 1.1, the Module Global Info block was not aligned causing the + next block to be read in on an unaligned boundary. This problem was corrected + in version 1.2.

    Version 1.0 Differences From 1.1
    -

    TBD: How version 1.0 differs from version 1.1

    +

    None. Version 1.0 and 1.1 bytecode formats are identical.

    @@ -551,7 +812,7 @@ Reid Spencer and Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/06/21 23:29:40 $ + Last modified: $Date: 2004/07/05 08:18:07 $ From lattner at cs.uiuc.edu Mon Jul 5 12:56:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Jul 5 12:56:02 2004 Subject: [llvm-commits] CVS: llvm/docs/BytecodeFormat.html Message-ID: <200407051755.MAA26446@apoc.cs.uiuc.edu> Changes in directory llvm/docs: BytecodeFormat.html updated: 1.12 -> 1.13 --- Log message: Structures allow only uint arrays allow int/uint/long/ulong --- Diffs of the changes: (+4 -5) Index: llvm/docs/BytecodeFormat.html diff -u llvm/docs/BytecodeFormat.html:1.12 llvm/docs/BytecodeFormat.html:1.13 --- llvm/docs/BytecodeFormat.html:1.12 Mon Jul 5 03:18:07 2004 +++ llvm/docs/BytecodeFormat.html Mon Jul 5 12:55:28 2004 @@ -767,10 +767,9 @@ for accessing a structure field and a long type index for accessing an array element. Consequently, it was only possible to access structures of 255 or fewer elements. Starting in version 1.3, this restriction was lifted. - Structures must now be indexed with int or uint types. Arrays must now be - indexed with long or ulong types. This requirement was needed so that LLVM - could compile several test cases that used large numbers of fields in their - structures. The consequence of this was that the bytecode format had to + Structures must now be indexed with uint constants. Arrays may now be + indexed with int, uint, long, or ulong typed values. + The consequence of this was that the bytecode format had to change in order to accommodate the larger range of structure indices.

    @@ -812,7 +811,7 @@ Reid Spencer and Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/07/05 08:18:07 $ + Last modified: $Date: 2004/07/05 17:55:28 $ From lattner at cs.uiuc.edu Mon Jul 5 13:07:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Mon Jul 5 13:07:02 2004 Subject: [llvm-commits] CVS: llvm/docs/BytecodeFormat.html Message-ID: <200407051805.NAA26548@apoc.cs.uiuc.edu> Changes in directory llvm/docs: BytecodeFormat.html updated: 1.13 -> 1.14 --- Log message: Add a missing "terminator" :) --- Diffs of the changes: (+2 -2) Index: llvm/docs/BytecodeFormat.html diff -u llvm/docs/BytecodeFormat.html:1.13 llvm/docs/BytecodeFormat.html:1.14 --- llvm/docs/BytecodeFormat.html:1.13 Mon Jul 5 12:55:28 2004 +++ llvm/docs/BytecodeFormat.html Mon Jul 5 13:05:48 2004 @@ -739,7 +739,7 @@

    This section describes the differences in the Bytecode Format across LLVM versions. The versions are listed in reverse order because it assumes the current version is as documented in the previous sections. Each section here -describes the differences between that version and the one that follows +describes the differences between that version and the one that follows.

    @@ -811,7 +811,7 @@ Reid Spencer and Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/07/05 17:55:28 $ + Last modified: $Date: 2004/07/05 18:05:48 $ From llvm at cs.uiuc.edu Mon Jul 5 14:05:34 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Mon Jul 5 14:05:34 2004 Subject: [llvm-commits] CVS: llvm/docs/BytecodeFormat.html Message-ID: <200407051904.OAA28263@zion.cs.uiuc.edu> Changes in directory llvm/docs: BytecodeFormat.html updated: 1.14 -> 1.15 --- Log message: Added sections for Constant Pool, Module Global Info, and Compaction Tables. Two more sections to go. --- Diffs of the changes: (+281 -39) Index: llvm/docs/BytecodeFormat.html diff -u llvm/docs/BytecodeFormat.html:1.14 llvm/docs/BytecodeFormat.html:1.15 --- llvm/docs/BytecodeFormat.html:1.14 Mon Jul 5 13:05:48 2004 +++ llvm/docs/BytecodeFormat.html Mon Jul 5 14:04:27 2004 @@ -5,11 +5,11 @@ LLVM Bytecode File Format @@ -161,7 +161,7 @@ the value. Consequently 32-bit quantities can take from one to five bytes to encode. In general, smaller quantities will encode in fewer bytes, as follows:

    - +
    @@ -222,9 +222,9 @@ - + - -
    Byte # Significant BitsA single bit within some larger integer field.
    stringA uint_vbr indicating the length of the character string - immediately followed by the characters of the string. There is no - terminating null byte in the string.A uint_vbr indicating the type of the character string + which also includes its length, immediately followed by the characters of + the string. There is no terminating null byte in the string.
    data An arbitrarily long segment of data to which no @@ -419,7 +419,7 @@ bytecode file. This block is always four bytes in length and differs from the other blocks because there is no identifier and no block length at the start of the block. Essentially, this block is just the "magic number" for the file. - +
    @@ -447,7 +447,7 @@ only provides the module identifier, size of the module block, and the format information. Everything else is contained in other blocks, described in other sections.

    -
    Type Field Description
    +
    @@ -535,28 +535,29 @@ both forward and backward type resolution will not be possible.

    The type pool is simply a list of type definitions, as shown in the table below.

    -
    Type Field Description
    +
    - + - + - + - -
    Type Field Description
    unsignedType Pool Identifier (0x13)Type Pool Identifier (0x15)
    unsignedSize in bytes of the symbol table block.Size in bytes of the type pool block.
    uint32_vbrNumber of entries in type planeNumber of type definitions that follow in the next + field.
    type Each of the type definitions (see below)1
    - 1Repeated field.
    -
    +Notes: +
      +
    1. Repeated field.
    2. +
    @@ -572,13 +573,13 @@
    uint32_vbr Type ID For The Primitive (1-11)1
    - 1See the definition of Type::TypeID in Type.h for the numeric - equivalents of the primitive type ids.
    -
    +Notes: +
      +
    1. See the definition of Type::TypeID in Type.h for the numeric equivalents + of the primitive type ids.
    2. +

    Function Types

    @@ -599,13 +600,13 @@ - -
    uint32_vbr Value 0 if this is a varargs function.2
    - 1Repeated field.
    - 2Optional field. -
    +Notes: +
      +
    1. Repeated field.
    2. +
    3. Optional field.
    4. +

    Structure Types

    @@ -620,12 +621,12 @@ - -
    uint32_vbr Null Terminator (VoidTy type id)
    - 1Repeated field.
    -
    +Notes: +
      +
    1. Repeatable field.
    2. +

    Array Types

    @@ -669,12 +670,200 @@
    Module Global Info
    -

    To be determined.

    +

    The module global info block contains the definitions of all global + variables including their initializers and the declaration of all + functions. The format is shown in the table below

    +
    + + + + + + + + + + + + + + + + + + + + + + + + +
    TypeField Description
    unsignedModule global info identifier (0x14)
    unsignedSize in bytes of the module global info block.
    globalvarDefinition of the global variable (see below). + 1 +
    uint32_vbrSlot number of the global variable's constant + initializer.1,2 +
    uint32_vbrZero. This terminates the list of global variables. +
    uint32_vbrType slot number of a function defined in this + bytecode file.3 +
    uint32_vbrZero. This terminates the list of function + declarations. +
    + Notes:
      +
    1. Both these fields are repeatable but in pairs.
    2. +
    3. Optional field.
    4. +
    5. Repeatable field.
    6. +
    + + + +
    Global Variable Field +
    +
    +

    Global variables are written using a single + uint32_vbr that encodes information about the global + variable. The table below provides the bit layout of the value written for + each global variable.

    + + + + + + + + + + + + + + + + + + +
    Bit(s)TypeDescription
    0bitIs constant?
    1bitHas initializer?1
    2-4enumerationLinkage type: 0=External, 1=Weak, 2=Appending, + 3=Internal, 4=LinkOnce
    5-31type slotSlot number of type for the global variable.
    + Notes: +
      +
    1. This bit determines whether the constant initializer field follows + immediately after this field
    2. +
    +
    Constant Pool
    -

    To be determined.

    +

    A constant pool defines as set of constant values. There are actually two + types of constant pool blocks: one for modules and one for functions. For + modules, the block begins with the constant strings encountered anywhere in + the module. For functions, the block begins with types only encountered in + the function. In both cases the header is identical. The tables the follow, + show the header, module constant pool preamble, function constant pool + preamble, and the part common to both function and module constant pools.

    +

    Common Block Header

    + + + + + + + + +
    TypeField Description
    unsignedConstant pool identifier (0x12)
    +

    Module Constant Pool Preamble (constant strings)

    + + + + + + + + + + + + + + +
    TypeField Description
    uint32_vbrThe number of constant strings that follow.
    uint32_vbrZero. This identifies the following "plane" as + containing the constant strings. +
    stringSlot number of the constant string's type which + includes the length of the string.1 +
    + Notes: +
      +
    1. Repeated field.
    2. +
    +

    Function Constant Pool Preamble (function types)

    +

    The structure of the types for functions is identical to the + Global Type Pool. Please refer to that section + for the details. +

    Common Part (other constants)

    + + + + + + + + + + + + + + +
    TypeField Description
    uint32_vbrNumber of entries in this type plane.
    uint32_vbrType slot number of this plane.
    constantThe definition of a constant (see below).
    +
    + +
    Constant Field
    +
    +

    Constants come in many shapes and flavors. The sections that followe define + the format for each of them. All constants start with a + uint32_vbr encoded integer that provides the number + of operands for the constant. For primitive, structure, and array constants, + this will always be zero since those types of constants have no operands. + In this case, we have the following field definitions:

    + +

    When the number of operands to the constant is non-zero, we have a + constant expression and its field format is provided in the table below.

    + + + + + + + + + + + + + + +
    TypeField Description
    uint32_vbrOp code of the instruction for the constant + expression.
    uint32_vbrThe slot number of the constant value for an + operand.1
    uint32_vbrThe slot number for the type of the constant value + for an operand.1
    + Notes:
      +
    1. Both these fields are repeatable but only in pairs.
    2. +
    Function Definition
    @@ -684,8 +873,59 @@
    Compaction Table
    -

    To be determined.

    +

    Compaction tables are part of a function definition. They are merely a + device for reducing the size of bytecode files. The size of a bytecode + file is dependent on the value of the slot numbers used because + larger values use more bytes in the variable bit rate encoding scheme. + Furthermore, the compresses instruction format reserves only six bits for + the type of the instruction. In large modules, declaring hundreds or thousands + of types, the values of the slot numbers can be quite large. However, + functions may use only a small fraction of the global types. In such cases + a compaction table is created that maps the global type and value slot + numbers to smaller values used by a function. Compaction tables have the + format shown in the table below.

    + + + + + + + + + + + + + + + + + +
    TypeField Description
    uint32_vbrThe number of types that follow
    uint32_vbrThe slot number in the global type plane of the + type that will be referenced in the function with the index of + this entry in the compaction table.1
    type_lenAn encoding of the type and number of values that + follow.2
    uint32_vbrThe slot number in the globals of the value that + will be referenced in the function with the index of this entry in + the compaction table1
    + Notes:
      +
    1. Repeated field.
    2. +
    3. This field's encoding varies depending on the size of the type plane. + See Type and Length for further details. +
    +
    + + +
    Type and Length
    +
    +

    The type and length of a compaction table type plane is encoded differently + depending on the length of the plane. For planes of length 1 or 2, the length + is encoded into bits 0 and 1 of a uint32_vbr and the + type is encoded into bits 2-31. Because type numbers are often small, this + often saves an extra byte per plane. If the length of the plane is greater + than 2 then the encoding uses a uint32_vbr for each + of the length and type, in that order.

    +
    Instruction List
    @@ -700,7 +940,7 @@ looked up in the global type pool). For each entry in a type plane, the slot number of the value and the name associated with that value are written. The format is given in the table below.

    - +
    @@ -726,11 +966,13 @@ - -
    Byte(s) Bit(s)variable1,2-Nostring Name of the value in the symbol table.
    1Maximum length shown, - may be smaller
    2Repeated field.
    +Notes: +
      +
    1. Maximum length shown, may be smaller
    2. +
    3. Repeated field.
    4. +
    Version Differences
    @@ -811,7 +1053,7 @@ Reid Spencer and Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/07/05 18:05:48 $ + Last modified: $Date: 2004/07/05 19:04:27 $ From llvm at cs.uiuc.edu Mon Jul 5 14:10:04 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Mon Jul 5 14:10:04 2004 Subject: [llvm-commits] CVS: llvm/utils/NightlyTest.gnuplot Message-ID: <200407051909.OAA28295@zion.cs.uiuc.edu> Changes in directory llvm/utils: NightlyTest.gnuplot updated: 1.9 -> 1.10 --- Log message: Caused the labels on the small plots to be drawn vertically instead of horizontally so they no longer overlap. This eye-strain-lessening patch contributed by Vladimir Merzliakov. Thanks! --- Diffs of the changes: (+28 -0) Index: llvm/utils/NightlyTest.gnuplot diff -u llvm/utils/NightlyTest.gnuplot:1.9 llvm/utils/NightlyTest.gnuplot:1.10 --- llvm/utils/NightlyTest.gnuplot:1.9 Wed Feb 18 14:27:06 2004 +++ llvm/utils/NightlyTest.gnuplot Mon Jul 5 14:09:32 2004 @@ -18,11 +18,15 @@ set label "llvm/projects" at "2004-01-04:", 151000 set size .75,.75 +set xtics rotate by 90 +set xlabel 0,-1 plot "running_loc.txt" using 1:2 title '' with lines, \ "running_loc.txt" using 1:2 title "Date vs. Lines of Code" with lines ##------- Plot large Date vs LOC ---- set size 1.5,1.5 +set xtics norotate +set xlabel 0,0 set output "running_loc_large.png" plot "running_loc.txt" using 1:2 title '', \ "running_loc.txt" using 1:2 title "Date vs. Lines of Code" with lines @@ -34,6 +38,8 @@ ##------- Olden CBE performance ---- set size .75,.75 +set xtics rotate by 90 +set xlabel 0,-1 set output "running_Olden_cbe_time.png" set ylabel "CBE compiled execution time (s)" plot "running_Olden_cbe_time.txt" u 1:2 t '' with lines, \ @@ -50,6 +56,8 @@ with lines set size 1.5,1.5 +set xtics norotate +set xlabel 0,0 set output "running_Olden_cbe_time_large.png" plot "running_Olden_cbe_time.txt" u 1:2 t '' with lines, \ "running_Olden_cbe_time.txt" u 1:2 t "bh" with lines, \ @@ -67,6 +75,8 @@ ##------- Olden JIT performance ---- set size .75,.75 +set xtics rotate by 90 +set xlabel 0,-1 set output "running_Olden_jit_time.png" set ylabel "JIT execution time (s)" plot "running_Olden_jit_time.txt" u 1:2 t '' with lines, \ @@ -83,6 +93,8 @@ with lines set size 1.5,1.5 +set xtics norotate +set xlabel 0,0 set output "running_Olden_jit_time_large.png" plot "running_Olden_jit_time.txt" u 1:2 t '' with lines, \ "running_Olden_jit_time.txt" u 1:2 t "bh" with lines, \ @@ -100,6 +112,8 @@ ##------- Olden LLC performance ---- set size .75,.75 +set xtics rotate by 90 +set xlabel 0,-1 set output "running_Olden_llc_time.png" set ylabel "LLC compiled execution time (s)" plot "running_Olden_llc_time.txt" u 1:2 t '' with lines, \ @@ -116,6 +130,8 @@ with lines set size 1.5,1.5 +set xtics norotate +set xlabel 0,0 set output "running_Olden_llc_time_large.png" plot "running_Olden_llc_time.txt" u 1:2 t '' with lines, \ "running_Olden_llc_time.txt" u 1:2 t "bh" with lines, \ @@ -134,6 +150,8 @@ ##------- Olden optimizer time ---- set size .75,.75 +set xtics rotate by 90 +set xlabel 0,-1 set output "running_Olden_opt_time.png" set ylabel "Time to run the optimizer (s)" plot "running_Olden_opt_time.txt" u 1:2 t '' with lines, \ @@ -150,6 +168,8 @@ with lines set size 1.5,1.5 +set xtics norotate +set xlabel 0,0 set output "running_Olden_opt_time_large.png" plot "running_Olden_opt_time.txt" u 1:2 t '' with lines, \ "running_Olden_opt_time.txt" u 1:2 t "bh" with lines, \ @@ -168,6 +188,8 @@ ##------- Machine code size ---- set size .75,.75 +set xtics rotate by 90 +set xlabel 0,-1 set output "running_Olden_machcode.png" set ylabel "Program machine code size (bytes)" plot "running_Olden_machcode.txt" u 1:2 t '' with lines, \ @@ -184,6 +206,8 @@ with lines set size 1.5,1.5 +set xtics norotate +set xlabel 0,0 set output "running_Olden_machcode_large.png" plot "running_Olden_machcode.txt" u 1:2 t '' with lines, \ "running_Olden_machcode.txt" u 1:2 t "bh" with lines, \ @@ -202,6 +226,8 @@ ##------- Bytecode size ---- set size .75,.75 +set xtics rotate by 90 +set xlabel 0,-1 set output "running_Olden_bytecode.png" set ylabel "Program bytecode size (bytes)" plot "running_Olden_bytecode.txt" u 1:2 t '' with lines, \ @@ -218,6 +244,8 @@ with lines set size 1.5,1.5 +set xtics norotate +set xlabel 0,0 set output "running_Olden_bytecode_large.png" plot "running_Olden_bytecode.txt" u 1:2 t '' with lines, \ "running_Olden_bytecode.txt" u 1:2 t "bh" with lines, \ From llvm at cs.uiuc.edu Mon Jul 5 17:29:02 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Mon Jul 5 17:29:02 2004 Subject: [llvm-commits] CVS: llvm/docs/BytecodeFormat.html Message-ID: <200407052228.RAA29248@zion.cs.uiuc.edu> Changes in directory llvm/docs: BytecodeFormat.html updated: 1.15 -> 1.16 --- Log message: First draft completed. All sections written. --- Diffs of the changes: (+314 -118) Index: llvm/docs/BytecodeFormat.html diff -u llvm/docs/BytecodeFormat.html:1.15 llvm/docs/BytecodeFormat.html:1.16 --- llvm/docs/BytecodeFormat.html:1.15 Mon Jul 5 14:04:27 2004 +++ llvm/docs/BytecodeFormat.html Mon Jul 5 17:28:02 2004 @@ -26,15 +26,9 @@
  • Slots
  • -
  • General Layout +
  • General Structure
  • +
  • Block Definitions
      -
    1. Structure
    2. -
    -
  • -
  • Detailed Layout -
      -
    1. Notation
    2. -
    3. Blocks Types
    4. Signature Block
    5. Module Block
    6. Global Type Pool
    7. @@ -58,9 +52,6 @@

      Written by Reid Spencer

      -
      -

      Warning: This is a work in progress.

      -
      @@ -203,7 +194,7 @@ ordering. That is bits 20 through 27 are in the byte with the lowest file offset (little endian). - uint_vbr + uint32_vbr A 32-bit unsigned integer that occupies from one to five bytes using variable bit rate encoding. @@ -222,7 +213,7 @@ A single bit within some larger integer field. string - A uint_vbr indicating the type of the character string + A uint32_vbr indicating the type of the constant string which also includes its length, immediately followed by the characters of the string. There is no terminating null byte in the string. @@ -282,25 +273,17 @@ - +
      -

      This section provides the general layout of the LLVM bytecode file format. - The detailed layout can be found in the next section. -

      -
      - - - -
      -

      The bytecode file format requires blocks to be in a certain order and -nested in a particular way so that an LLVM module can be constructed -efficiently from the contents of the file. This ordering defines a general -structure for bytecode files as shown below. The table below shows the order -in which all block types may appear. Please note that some of the blocks are -optional and some may be repeated. The structure is fairly loose because -optional blocks, if empty, are completely omitted from the file. -

      +

      This section provides the general structur of the LLVM bytecode file + format. The bytecode file format requires blocks to be in a certain order and + nested in a particular way so that an LLVM module can be constructed + efficiently from the contents of the file. This ordering defines a general + structure for bytecode files as shown below. The table below shows the order + in which all block types may appear. Please note that some of the blocks are + optional and some may be repeated. The structure is fairly loose because + optional blocks, if empty, are completely omitted from the file.

      @@ -309,48 +292,68 @@ + + + - + + - + + - + + - + + - + + - + + - + + - + + - + +
      IDRepeated? Level Block TypeDescription
      N/AFileNoNo0 SignatureThis contains the file signature (magic number) + that identifies the file as LLVM bytecode.
      0x01FileNoNo0 ModuleThis is the top level block in a bytecode file. It + contains all the other blocks.
      0x15ModuleNoNo1    - Global Type Pool   Global Type PoolThis block contains all the global (module) level + types.
      0x14ModuleNoNo1    - Module Globals Info   Module Globals InfoThis block contains the type, constness, and linkage + for each of the global variables in the module. It also contains the + type of the functions and the constant initializers.
      0x12ModuleYesNo1    - Module Constant Pool   Module Constant PoolThis block contains all the global constants + except function arguments, global values and constant strings.
      0x11ModuleYesYes1    - Function Definitions   Function DefinitionsOne function block is written for each function in + the module. The function block contains the instructions, compaction + table, type constant pool, and symbol table for the function.
      0x12FunctionYesNo2       - Function Constant Pool      Function Constant PoolAny constants (including types) used solely + within the function are emitted here in the function constant pool. +
      0x33FunctionYesNo2       - Compaction Table      Compaction TableThis table reduces bytecode size by providing a + funtion-local mapping of type and value slot numbers to their + global slot numbers
      0x32FunctionNoNo2       - Instruction List      Instruction ListThis block contains all the instructions of the + function. The basic blocks are inferred by terminating instructions. +
      0x13FunctionYesNo2       - Function Symbol Table      Function Symbol TableThis symbol table provides the names for the + function specific values used (basic block labels mostly).
      0x13ModuleYesNo1    - Module Symbol Table   Module Symbol TableThis symbol table provides the names for the various + entries in the file that are not function specific (global vars, and + functions mostly).

      Use the links in the table or see Block Types for @@ -358,59 +361,13 @@

      - +
      -

      This section provides the detailed layout of the LLVM bytecode file format. -

      -
      - - -
      -

      The descriptions of the bytecode format that follow describe the order, type -and bit fields in detail. These descriptions are provided in tabular form. -Each table has four columns that specify:

      -
        -
      1. Byte(s): The offset in bytes of the field from the start of - its container (block, list, other field).
      2. -
      3. Bit(s): The offset in bits of the field from the start of - the byte field. Bits are always little endian. That is, bit addresses with - smaller values have smaller address (i.e. 20 is at bit 0, - 21 at 1, etc.) -
      4. -
      5. Align?: Indicates if this field is aligned to 32 bits or not. - This indicates where the next field starts, always on a 32 bit - boundary.
      6. -
      7. Type: The basic type of information contained in the field.
      8. -
      9. Description: Describes the contents of the field.
      10. -
      -
      - - -
      -

      The bytecode format encodes the intermediate representation into groups - of bytes known as blocks. The blocks are written sequentially to the file in - the following order:

      -
        -
      1. Signature: This contains the file signature - (magic number) that identifies the file as LLVM bytecode and the bytecode - version number.
      2. -
      3. Module Block: This is the top level block in a - bytecode file. It contains all the other blocks.
      4. -
      5. Global Type Pool: This block contains all the - global (module) level types.
      6. -
      7. Module Info: This block contains the types of the - global variables and functions in the module as well as the constant - initializers for the global variables
      8. -
      9. Constants: This block contains all the global - constants except function arguments, global values and constant strings.
      10. -
      11. Functions: One function block is written for - each function in the module.
      12. -
      13. Symbol Table: The module level symbol table that - provides names for the various other entries in the file is the final block - written.
      14. -
      +

      This section provides the detailed layout of the individual block types + in the LLVM bytecode file format.

      +
      @@ -866,9 +823,44 @@
    -
    Function Definition
    +
    Function Definition

    To be determined.

    + + + + + + + + + + + + + + + + + + + + +
    TypeField Description
    uint32_vbrThe linkage type of the function: 0=External, 1=Weak, + 2=Appending, 3=Internal, 4=LinkOnce1
    constant poolThe constant pool block for this function. + 2 +
    compaction tableThe compaction table block for the function. + 2 +
    instruction listThe list of instructions in the function.
    symbol tableThe function's slot table containing only those + symbols pertinent to the function (mostly block labels). +
    + Notes:
      +
    1. Note that if the linkage type is "External" then none of the other + fields will be present as the function is defined elsewhere.
    2. +
    3. Note that only one of the constant pool or compaction table will be + written. Compaction tables are only written if they will actually save + bytecode space. If not, then a regular constant pool is written.
    4. +
    Compaction Table
    @@ -929,8 +921,168 @@
    Instruction List
    -

    To be determined.

    +

    The instructions in a function are written as a simple list. Basic blocks + are inferred by the terminating instruction types. The format of the block + is given in the following table.

    + + + + + + + + + + + + + + +
    TypeField Description
    unsignedInstruction list identifier (0x33).
    unsignedSize in bytes of the instruction list.
    instructionAn instruction.1
    + Notes: +
      +
    1. A repeated field with a variety of formats. See + Instructions for details.
    2. +
    +
    + + +
    Instructions
    +
    +

    For brevity, instructions are written in one of four formats, depending on + the number of operands to the instruction. Each instruction begins with a + uint32_vbr that encodes the type of the instruction + as well as other things. The tables that follow describe the format of this + first word of each instruction.

    +

    Instruction Format 0

    +

    This format is used for a few instructions that can't easily be optimized + because they have large numbers of operands (e.g. PHI Node or getelementptr). + Each of the opcode, type, and operand fields is as successive fields.

    + + + + + + + + + + + + + + + + + +
    TypeField Description
    uint32_vbrSpecifies the opcode of the instruction. Note that for + compatibility with the other instruction formats, the opcode is shifted + left by 2 bits. Bits 0 and 1 must have value zero for this format.
    uint32_vbrProvides the slot number of the result type of the + instruction
    uint32_vbrThe number of operands that follow.
    uint32_vbrThe slot number of the value for the operand(s). + 1,2
    + Notes:
      +
    1. Repeatable field (limit given by previous field).
    2. +
    3. Note that if the instruction is a getelementptr and the type of the + operand is a sequential type (array or pointer) then the slot number is + shifted up two bits and the low order bits will encode the type of index + used, as follows: 0=uint, 1=int, 2=ulong, 3=long.
    4. +
    +

    Instruction Format 1

    +

    This format encodes the opcode, type and a single operand into a single + uint32_vbr as follows:

    + + + + + + + + + + + + + + + + + + + +
    BitsTypeField Description
    0-1constant "1"These two bits must be the value 1 which identifies + this as an instruction of format 1.
    2-7opcodeSpecifies the opcode of the instruction. Note that + the maximum opcode value si 63.
    8-19unsignedSpecifies the slot number of the type for this + instruction. Maximum slot number is 212-1=4095.
    20-31unsignedSpecifies the slot number of the value for the + first operand. Maximum slot number is 212-1=4095. Note + that the value 212-1 denotes zero operands.
    +

    Instruction Format 2

    +

    This format encodes the opcode, type and two operands into a single + uint32_vbr as follows:

    + + + + + + + + + + + + + + + + + + + + + + +
    BitsTypeField Description
    0-1constant "2"These two bits must be the value 2 which identifies + this as an instruction of format 2.
    2-7opcodeSpecifies the opcode of the instruction. Note that + the maximum opcode value si 63.
    8-15unsignedSpecifies the slot number of the type for this + instruction. Maximum slot number is 28-1=255.
    16-23unsignedSpecifies the slot number of the value for the + first operand. Maximum slot number is 28-1=255.
    24-31unsignedSpecifies the slot number of the value for the + second operand. Maximum slot number is 28-1=255.
    +

    Instruction Format 3

    +

    This format encodes the opcode, type and three operands into a single + uint32_vbr as follows:

    + + + + + + + + + + + + + + + + + + + + + + + + + +
    BitsTypeField Description
    0-1constant "3"These two bits must be the value 3 which identifies + this as an instruction of format 3.
    2-7opcodeSpecifies the opcode of the instruction. Note that + the maximum opcode value si 63.
    8-13unsignedSpecifies the slot number of the type for this + instruction. Maximum slot number is 26-1=63.
    14-19unsignedSpecifies the slot number of the value for the + first operand. Maximum slot number is 26-1=63.
    20-25unsignedSpecifies the slot number of the value for the + second operand. Maximum slot number is 26-1=63.
    26-31unsignedSpecifies the slot number of the value for the + third operand. Maximum slot number is 26-1=63.
    +
    Symbol Table
    @@ -942,38 +1094,81 @@ format is given in the table below.

    - - - - + - + - + - - - - - - - - - + + + + +
    Byte(s)Bit(s)Align? Type Field Description
    00-03-Nounsignedunsigned Symbol Table Identifier (0x13)
    04-07-Nounsignedunsigned Size in bytes of the symbol table block.
    08-111-Nouint32_vbruint32_vbr Number of entries in type plane
    12-151-Nouint32_vbrType plane index for following entries
    16-191,2-Nouint32_vbrSlot number of a value.
    variable1,2-NostringName of the value in the symbol table.
    symtab_entryProvides the slot number of the type and its name. + 1
    symtab_planeA type plane containing value slot number and name + for all values of the same type.1
    Notes:
      -
    1. Maximum length shown, may be smaller
    2. Repeated field.
    + + +
    Symbol Table Plane +
    +
    +

    A symbol table plane provides the symbol table entries for all values of + a common type. The encoding is given in the following table:

    + + + + + + + + + + + + + + +
    TypeField Description
    uint32_vbrNumber of entries in this plane.
    uint32_vbrSlot number of type for this plane.
    symtab_entryThe symbol table entries for this plane (repeated).
    +
    + + +
    Symbol Table Entry +
    +
    +

    A symbol table entry provides the assocation between a type or value's + slot number and the name given to that type or value. The format is given + in the following table:

    + + + + + + + + + + + + + + +
    TypeField Description
    uint32_vbrSlot number of the type or value being given a name. +
    uint32_vbrLength of the character array that follows.
    charThe characters of the name (repeated).
    +
    +
    Version Differences
    @@ -984,6 +1179,7 @@ describes the differences between that version and the one that follows.

    +
    Version 1.2 Differences From 1.3
    @@ -1037,7 +1233,7 @@
    -Version 1.0 Differences From 1.1
    +Version 1.0 Differences From 1.1

    None. Version 1.0 and 1.1 bytecode formats are identical.

    @@ -1053,7 +1249,7 @@ Reid Spencer and Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/07/05 19:04:27 $ + Last modified: $Date: 2004/07/05 22:28:02 $ From llvm at cs.uiuc.edu Mon Jul 5 20:31:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Mon Jul 5 20:31:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.h Message-ID: <200407060130.UAA29953@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.h updated: 1.3 -> 1.4 --- Log message: Remove definition and use of OtherVal enumerator. This just fixes a thinko. --- Diffs of the changes: (+1 -1) Index: llvm/lib/Bytecode/Reader/Reader.h diff -u llvm/lib/Bytecode/Reader/Reader.h:1.3 llvm/lib/Bytecode/Reader/Reader.h:1.4 --- llvm/lib/Bytecode/Reader/Reader.h:1.3 Sun Jul 4 19:57:50 2004 +++ llvm/lib/Bytecode/Reader/Reader.h Mon Jul 5 20:30:36 2004 @@ -72,7 +72,7 @@ /// globals section. /// @brief A list of values as a User of those Values. struct ValueList : public User { - ValueList() : User(Type::VoidTy, Value::OtherVal) {} + ValueList() : User(Type::VoidTy, Value::FunctionVal) {} // vector compatibility methods unsigned size() const { return getNumOperands(); } From llvm at cs.uiuc.edu Mon Jul 5 20:32:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Mon Jul 5 20:32:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Value.h Message-ID: <200407060130.UAA29948@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Value.h updated: 1.54 -> 1.55 --- Log message: Remove definition and use of OtherVal enumerator. This just fixes a thinko. --- Diffs of the changes: (+0 -1) Index: llvm/include/llvm/Value.h diff -u llvm/include/llvm/Value.h:1.54 llvm/include/llvm/Value.h:1.55 --- llvm/include/llvm/Value.h:1.54 Sun Jul 4 05:52:28 2004 +++ llvm/include/llvm/Value.h Mon Jul 5 20:30:36 2004 @@ -127,7 +127,6 @@ GlobalVariableVal, // This is an instance of GlobalVariable ConstantVal, // This is an instance of Constant InstructionVal, // This is an instance of Instruction - OtherVal, // This is an instance of something else }; unsigned getValueType() const { return SubclassID; From lattner at cs.uiuc.edu Tue Jul 6 01:37:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Jul 6 01:37:01 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/UnreachableBlockElim.cpp Message-ID: <200407060636.BAA00356@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: UnreachableBlockElim.cpp updated: 1.1 -> 1.2 --- Log message: Fix a bug in the unreachable block elim pass. Dropping all references on a basic block clear()'s all of the operands lists, including phis. This caused removePredecessor to get confused later. Because of this, we just nuke (without prejudice) PHI nodes in unreachable blocks. --- Diffs of the changes: (+11 -4) Index: llvm/lib/CodeGen/UnreachableBlockElim.cpp diff -u llvm/lib/CodeGen/UnreachableBlockElim.cpp:1.1 llvm/lib/CodeGen/UnreachableBlockElim.cpp:1.2 --- llvm/lib/CodeGen/UnreachableBlockElim.cpp:1.1 Fri Jul 2 00:46:10 2004 +++ llvm/lib/CodeGen/UnreachableBlockElim.cpp Tue Jul 6 01:36:11 2004 @@ -21,6 +21,8 @@ //===----------------------------------------------------------------------===// #include "llvm/CodeGen/Passes.h" +#include "llvm/iPHINode.h" +#include "llvm/Constant.h" #include "llvm/Function.h" #include "llvm/Pass.h" #include "llvm/Support/CFG.h" @@ -52,10 +54,15 @@ std::vector DeadBlocks; for (Function::iterator I = F.begin(), E = F.end(); I != E; ++I) if (!Reachable.count(I)) { - DeadBlocks.push_back(I); - for (succ_iterator SI = succ_begin(&*I), E = succ_end(&*I); SI != E; ++SI) - (*SI)->removePredecessor(I); - I->dropAllReferences(); + BasicBlock *BB = I; + DeadBlocks.push_back(BB); + while (PHINode *PN = dyn_cast(BB->begin())) { + PN->replaceAllUsesWith(Constant::getNullValue(PN->getType())); + BB->getInstList().pop_front(); + } + for (succ_iterator SI = succ_begin(BB), E = succ_end(BB); SI != E; ++SI) + (*SI)->removePredecessor(BB); + BB->dropAllReferences(); } if (DeadBlocks.empty()) return false; From lattner at cs.uiuc.edu Tue Jul 6 02:01:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Jul 6 02:01:02 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/sub.ll Message-ID: <200407060700.CAA00983@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/InstCombine: sub.ll updated: 1.16 -> 1.17 --- Log message: New testcase --- Diffs of the changes: (+5 -0) Index: llvm/test/Regression/Transforms/InstCombine/sub.ll diff -u llvm/test/Regression/Transforms/InstCombine/sub.ll:1.16 llvm/test/Regression/Transforms/InstCombine/sub.ll:1.17 --- llvm/test/Regression/Transforms/InstCombine/sub.ll:1.16 Fri Mar 12 18:11:38 2004 +++ llvm/test/Regression/Transforms/InstCombine/sub.ll Tue Jul 6 02:00:11 2004 @@ -94,3 +94,8 @@ ret int %D } +int %test15(int %A, int %B) { + %C = sub int 0, %A + %D = rem int %B, %C ;; X % -Y === X % Y + ret int %D +} From lattner at cs.uiuc.edu Tue Jul 6 02:02:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Jul 6 02:02:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200407060701.CAA00997@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.217 -> 1.218 --- Log message: Implement InstCombine/sub.ll:test15: X % -Y === X % Y Also, remove X % -1 = 0, because it's not true for unsigneds, and the signed case is superceeded by this new handling. --- Diffs of the changes: (+9 -2) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.217 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.218 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.217 Fri Jul 2 19:26:11 2004 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Tue Jul 6 02:01:22 2004 @@ -844,11 +844,18 @@ Instruction *InstCombiner::visitRem(BinaryOperator &I) { + if (I.getType()->isSigned()) + if (Value *RHSNeg = dyn_castNegVal(I.getOperand(1))) + if (RHSNeg != I.getOperand(1)) { // Avoid problems with MININT + // X % -Y -> X % Y + AddUsesToWorkList(I); + I.setOperand(1, RHSNeg); + return &I; + } + if (ConstantInt *RHS = dyn_cast(I.getOperand(1))) { if (RHS->equalsInt(1)) // X % 1 == 0 return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType())); - if (RHS->isAllOnesValue()) // X % -1 == 0 - return ReplaceInstUsesWith(I, Constant::getNullValue(I.getType())); // Check to see if this is an unsigned remainder with an exact power of 2, // if so, convert to a bitwise and. From lattner at cs.uiuc.edu Tue Jul 6 02:13:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Jul 6 02:13:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200407060711.CAA01654@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.218 -> 1.219 --- Log message: Fix a minor bug where we would go into infinite loops on some constants --- Diffs of the changes: (+2 -1) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.218 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.219 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.218 Tue Jul 6 02:01:22 2004 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Tue Jul 6 02:11:42 2004 @@ -846,7 +846,8 @@ Instruction *InstCombiner::visitRem(BinaryOperator &I) { if (I.getType()->isSigned()) if (Value *RHSNeg = dyn_castNegVal(I.getOperand(1))) - if (RHSNeg != I.getOperand(1)) { // Avoid problems with MININT + if (!isa(RHSNeg) || + cast(RHSNeg)->getValue() >= 0) { // X % -Y -> X % Y AddUsesToWorkList(I); I.setOperand(1, RHSNeg); From lattner at cs.uiuc.edu Tue Jul 6 02:39:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Jul 6 02:39:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200407060738.CAA02813@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.219 -> 1.220 --- Log message: Implement rem.ll:test3 --- Diffs of the changes: (+18 -0) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.219 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.220 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.219 Tue Jul 6 02:11:42 2004 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Tue Jul 6 02:38:18 2004 @@ -1528,6 +1528,24 @@ // operand is a constant, simplify a bit. if (BinaryOperator *BO = dyn_cast(Op0)) { switch (BO->getOpcode()) { + case Instruction::Rem: + // If we have a signed (X % (2^c)) == 0, turn it into an unsigned one. + if (CI->isNullValue() && isa(BO->getOperand(1)) && + BO->hasOneUse() && + cast(BO->getOperand(1))->getValue() > 1) + if (unsigned L2 = + Log2(cast(BO->getOperand(1))->getValue())) { + const Type *UTy = BO->getType()->getUnsignedVersion(); + Value *NewX = InsertNewInstBefore(new CastInst(BO->getOperand(0), + UTy, "tmp"), I); + Constant *RHSCst = ConstantUInt::get(UTy, 1ULL << L2); + Value *NewRem =InsertNewInstBefore(BinaryOperator::createRem(NewX, + RHSCst, BO->getName()), I); + return BinaryOperator::create(I.getOpcode(), NewRem, + Constant::getNullValue(UTy)); + } + break; + case Instruction::Add: // Replace ((add A, B) != C) with (A != C-B) if B & C are constants. if (ConstantInt *BOp1C = dyn_cast(BO->getOperand(1))) { From lattner at cs.uiuc.edu Tue Jul 6 02:39:04 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Jul 6 02:39:04 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/Transforms/InstCombine/rem.ll Message-ID: <200407060738.CAA02804@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Transforms/InstCombine: rem.ll updated: 1.6 -> 1.7 --- Log message: New testcase --- Diffs of the changes: (+6 -0) Index: llvm/test/Regression/Transforms/InstCombine/rem.ll diff -u llvm/test/Regression/Transforms/InstCombine/rem.ll:1.6 llvm/test/Regression/Transforms/InstCombine/rem.ll:1.7 --- llvm/test/Regression/Transforms/InstCombine/rem.ll:1.6 Tue Sep 16 10:29:34 2003 +++ llvm/test/Regression/Transforms/InstCombine/rem.ll Tue Jul 6 02:38:00 2004 @@ -19,3 +19,9 @@ %B = rem uint %A, 8 ; & 7 ret uint %B } + +bool %test3(int %A) { + %B = rem int %A, -8 ; & 7 + %C = setne int %B, 0 + ret bool %C +} From alkis at cs.uiuc.edu Tue Jul 6 08:22:02 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue Jul 6 08:22:02 2004 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200407061321.IAA05605@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.47 -> 1.48 --- Log message: Add required include. --- Diffs of the changes: (+1 -0) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.47 llvm-java/lib/Compiler/Compiler.cpp:1.48 --- llvm-java/lib/Compiler/Compiler.cpp:1.47 Fri Jul 2 05:44:49 2004 +++ llvm-java/lib/Compiler/Compiler.cpp Tue Jul 6 08:21:40 2004 @@ -24,6 +24,7 @@ #include #include #include +#include #include #include From alkis at cs.uiuc.edu Tue Jul 6 08:32:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue Jul 6 08:32:01 2004 Subject: [llvm-commits] CVS: llvm-java/tools/classdump/classdump.cpp Message-ID: <200407061331.IAA05769@zion.cs.uiuc.edu> Changes in directory llvm-java/tools/classdump: classdump.cpp updated: 1.9 -> 1.10 --- Log message: Implement class lookup by name given the CLASSPATH environment variable. Classfile now includes a getClassFile() API that looks up a class specified by its fully qualified name, in the directories specified by CLASSPATH and caches the parsed ClassFile object for later queries. --- Diffs of the changes: (+2 -5) Index: llvm-java/tools/classdump/classdump.cpp diff -u llvm-java/tools/classdump/classdump.cpp:1.9 llvm-java/tools/classdump/classdump.cpp:1.10 --- llvm-java/tools/classdump/classdump.cpp:1.9 Tue Jun 29 12:29:52 2004 +++ llvm-java/tools/classdump/classdump.cpp Tue Jul 6 08:31:34 2004 @@ -17,14 +17,12 @@ #include #include -#include #include -#include using namespace llvm; static cl::opt -InputFilename(cl::Positional, cl::desc(""), cl::init("-")); +InputFilename(cl::Positional, cl::desc("")); int main(int argc, char* argv[]) { @@ -33,8 +31,7 @@ "class dump utility"); try { - std::ifstream in(InputFilename.c_str()); - std::auto_ptr cf(Java::ClassFile::readClassFile(in)); + const Java::ClassFile* cf(Java::ClassFile::getClassFile(InputFilename)); cf->dump(std::cout); } From alkis at cs.uiuc.edu Tue Jul 6 08:33:00 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue Jul 6 08:33:00 2004 Subject: [llvm-commits] CVS: llvm-java/include/llvm/Java/ClassFile.h Message-ID: <200407061331.IAA05790@zion.cs.uiuc.edu> Changes in directory llvm-java/include/llvm/Java: ClassFile.h updated: 1.12 -> 1.13 --- Log message: Implement class lookup by name given the CLASSPATH environment variable. Classfile now includes a getClassFile() API that looks up a class specified by its fully qualified name, in the directories specified by CLASSPATH and caches the parsed ClassFile object for later queries. --- Diffs of the changes: (+5 -1) Index: llvm-java/include/llvm/Java/ClassFile.h diff -u llvm-java/include/llvm/Java/ClassFile.h:1.12 llvm-java/include/llvm/Java/ClassFile.h:1.13 --- llvm-java/include/llvm/Java/ClassFile.h:1.12 Thu May 27 14:37:27 2004 +++ llvm-java/include/llvm/Java/ClassFile.h Tue Jul 6 08:31:35 2004 @@ -61,8 +61,12 @@ const CodeAttribute* getCodeAttribute(const Attributes& attrs); class ClassFile { + static const ClassFile* readClassFile(std::istream& is); + static std::vector getClassPath(); + static std::string getFileForClass(const std::string& classname); + public: - static ClassFile* readClassFile(std::istream& is); + static const ClassFile* getClassFile(const std::string& classname); ~ClassFile(); From alkis at cs.uiuc.edu Tue Jul 6 08:33:03 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue Jul 6 08:33:03 2004 Subject: [llvm-commits] CVS: llvm-java/tools/class2llvm/class2llvm.cpp Message-ID: <200407061331.IAA05776@zion.cs.uiuc.edu> Changes in directory llvm-java/tools/class2llvm: class2llvm.cpp updated: 1.7 -> 1.8 --- Log message: Implement class lookup by name given the CLASSPATH environment variable. Classfile now includes a getClassFile() API that looks up a class specified by its fully qualified name, in the directories specified by CLASSPATH and caches the parsed ClassFile object for later queries. --- Diffs of the changes: (+2 -18) Index: llvm-java/tools/class2llvm/class2llvm.cpp diff -u llvm-java/tools/class2llvm/class2llvm.cpp:1.7 llvm-java/tools/class2llvm/class2llvm.cpp:1.8 --- llvm-java/tools/class2llvm/class2llvm.cpp:1.7 Fri Jul 2 05:49:01 2004 +++ llvm-java/tools/class2llvm/class2llvm.cpp Tue Jul 6 08:31:34 2004 @@ -20,26 +20,12 @@ #include #include -#include #include -#include using namespace llvm; static cl::opt -InputFilename(cl::Positional, cl::desc(""), cl::init("-")); - -namespace { - - std::auto_ptr getInputStream(const std::string& fn) { - std::auto_ptr in; - if (fn == "-") in.reset(new std::istream(std::cin.rdbuf())); - else in.reset(new std::ifstream(fn.c_str())); - - return in; - } - -} +InputFilename(cl::Positional, cl::desc("")); int main(int argc, char* argv[]) { @@ -48,9 +34,7 @@ "classfile to llvm utility"); try { - std::auto_ptr in(getInputStream(InputFilename)); - - std::auto_ptr cf(Java::ClassFile::readClassFile(*in)); + const Java::ClassFile* cf(Java::ClassFile::getClassFile(InputFilename)); Java::Compiler compiler; From alkis at cs.uiuc.edu Tue Jul 6 08:33:05 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue Jul 6 08:33:05 2004 Subject: [llvm-commits] CVS: llvm-java/lib/ClassFile/ClassFile.cpp Message-ID: <200407061331.IAA05783@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/ClassFile: ClassFile.cpp updated: 1.12 -> 1.13 --- Log message: Implement class lookup by name given the CLASSPATH environment variable. Classfile now includes a getClassFile() API that looks up a class specified by its fully qualified name, in the directories specified by CLASSPATH and caches the parsed ClassFile object for later queries. --- Diffs of the changes: (+59 -1) Index: llvm-java/lib/ClassFile/ClassFile.cpp diff -u llvm-java/lib/ClassFile/ClassFile.cpp:1.12 llvm-java/lib/ClassFile/ClassFile.cpp:1.13 --- llvm-java/lib/ClassFile/ClassFile.cpp:1.12 Tue Jun 29 15:26:06 2004 +++ llvm-java/lib/ClassFile/ClassFile.cpp Tue Jul 6 08:31:34 2004 @@ -12,13 +12,19 @@ // //===----------------------------------------------------------------------===// +#define DEBUG_TYPE "classfile" + #include +#include +#include #include #include +#include #include #include #include +#include using namespace llvm::Java; @@ -135,7 +141,7 @@ //===----------------------------------------------------------------------===// // ClassFile implementation -ClassFile* ClassFile::readClassFile(std::istream& is) +const ClassFile* ClassFile::readClassFile(std::istream& is) { if (readU1(is) != 0xCA) throw ClassFileParseError("bad magic"); if (readU1(is) != 0xFE) throw ClassFileParseError("bad magic"); @@ -145,6 +151,58 @@ return new ClassFile(is); } +std::vector ClassFile::getClassPath() +{ + std::string classpath = getenv("CLASSPATH"); + DEBUG(std::cerr << "CLASSPATH=" << classpath << '\n'); + + std::vector result; + unsigned b = 0, e = 0; + do { + e = classpath.find(':', b); + result.push_back(classpath.substr(b, e)); + b = e + 1; + } while (e != std::string::npos); + + return result; +} + +std::string ClassFile::getFileForClass(const std::string& classname) +{ + static const std::vector classpath = getClassPath(); + DEBUG(std::cerr << "Looking up class: " << classname << '\n'); + + std::string clazz = classname; + // replace '.' with '/' + for (unsigned i = 0, e = clazz.size(); i != e; ++i) + if (clazz[i] == '.') + clazz[i] = '/'; + clazz += ".class"; + + for (unsigned i = 0, e = classpath.size(); i != e; ++i) { + std::string filename = classpath[i] + '/' + clazz; + DEBUG(std::cerr << "Trying file: " << filename << '\n'); + if (FileOpenable(filename)) + return filename; + } + + throw ClassFileSemanticError("Class " + classname + " not found"); +} + +const ClassFile* ClassFile::getClassFile(const std::string& classname) +{ + typedef std::map Name2ClassMap; + static Name2ClassMap n2cMap_; + + Name2ClassMap::iterator it = n2cMap_.upper_bound(classname); + if (it == n2cMap_.end() || it->first != classname) { + std::ifstream in(getFileForClass(classname).c_str()); + it = n2cMap_.insert(it, std::make_pair(classname, readClassFile(in))); + } + + return it->second; +} + ClassFile::ClassFile(std::istream& is) { minorV_ = readU2(is); From alkis at cs.uiuc.edu Tue Jul 6 11:04:02 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue Jul 6 11:04:02 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp Message-ID: <200407061603.LAA22455@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.84 -> 1.85 --- Log message: Do not crash when joining two intervals of registers of different classes: just ignore that move. Thanks to Vladimir Prus who found the bug! --- Diffs of the changes: (+10 -1) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.84 llvm/lib/CodeGen/LiveIntervals.cpp:1.85 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.84 Fri Jul 2 00:52:23 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Tue Jul 6 11:03:21 2004 @@ -502,7 +502,9 @@ const TargetRegisterClass *rcA, *rcB; rcA = mf_->getSSARegMap()->getRegClass(intA->reg); rcB = mf_->getSSARegMap()->getRegClass(intB->reg); - assert(rcA == rcB && "registers must be of the same class"); + // if they are not of the same register class we continue + if (rcA != rcB) + continue; // if their intervals do not overlap we join them if (!intB->overlaps(*intA)) { @@ -524,6 +526,13 @@ MRegisterInfo::isVirtualRegister(intB->reg) && "A must be physical and B must be virtual"); + const TargetRegisterClass *rcA, *rcB; + rcA = mri_->getRegClass(intA->reg); + rcB = mf_->getSSARegMap()->getRegClass(intB->reg); + // if they are not of the same register class we continue + if (rcA != rcB) + continue; + if (!intA->overlaps(*intB) && !overlapsAliases(*intA, *intB)) { intA->join(*intB); From llvm at cs.uiuc.edu Tue Jul 6 12:05:02 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Tue Jul 6 12:05:02 2004 Subject: [llvm-commits] CVS: llvm/utils/NightlyTest.gnuplot Message-ID: <200407061704.MAA10048@zion.cs.uiuc.edu> Changes in directory llvm/utils: NightlyTest.gnuplot updated: 1.10 -> 1.11 --- Log message: Change the "rotate by 90" xtics specification to just "rotate" which is equivalent. The "by " syntax is not acceptable for all output devices. Apparently the Sparc and x86 output devices (no color) don't accept this, but should accept the plain "rotate". --- Diffs of the changes: (+7 -7) Index: llvm/utils/NightlyTest.gnuplot diff -u llvm/utils/NightlyTest.gnuplot:1.10 llvm/utils/NightlyTest.gnuplot:1.11 --- llvm/utils/NightlyTest.gnuplot:1.10 Mon Jul 5 14:09:32 2004 +++ llvm/utils/NightlyTest.gnuplot Tue Jul 6 12:04:09 2004 @@ -18,7 +18,7 @@ set label "llvm/projects" at "2004-01-04:", 151000 set size .75,.75 -set xtics rotate by 90 +set xtics rotate set xlabel 0,-1 plot "running_loc.txt" using 1:2 title '' with lines, \ "running_loc.txt" using 1:2 title "Date vs. Lines of Code" with lines @@ -38,7 +38,7 @@ ##------- Olden CBE performance ---- set size .75,.75 -set xtics rotate by 90 +set xtics rotate set xlabel 0,-1 set output "running_Olden_cbe_time.png" set ylabel "CBE compiled execution time (s)" @@ -75,7 +75,7 @@ ##------- Olden JIT performance ---- set size .75,.75 -set xtics rotate by 90 +set xtics rotate set xlabel 0,-1 set output "running_Olden_jit_time.png" set ylabel "JIT execution time (s)" @@ -112,7 +112,7 @@ ##------- Olden LLC performance ---- set size .75,.75 -set xtics rotate by 90 +set xtics rotate set xlabel 0,-1 set output "running_Olden_llc_time.png" set ylabel "LLC compiled execution time (s)" @@ -150,7 +150,7 @@ ##------- Olden optimizer time ---- set size .75,.75 -set xtics rotate by 90 +set xtics rotate set xlabel 0,-1 set output "running_Olden_opt_time.png" set ylabel "Time to run the optimizer (s)" @@ -188,7 +188,7 @@ ##------- Machine code size ---- set size .75,.75 -set xtics rotate by 90 +set xtics rotate set xlabel 0,-1 set output "running_Olden_machcode.png" set ylabel "Program machine code size (bytes)" @@ -226,7 +226,7 @@ ##------- Bytecode size ---- set size .75,.75 -set xtics rotate by 90 +set xtics rotate set xlabel 0,-1 set output "running_Olden_bytecode.png" set ylabel "Program bytecode size (bytes)" From lattner at cs.uiuc.edu Tue Jul 6 12:45:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Jul 6 12:45:02 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/BasicBlock.cpp Value.cpp Message-ID: <200407061744.MAA13376@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: BasicBlock.cpp updated: 1.46 -> 1.47 Value.cpp updated: 1.44 -> 1.45 --- Log message: Find bugs sooner rather than later. In this case, don't allow the creation of instructions that don't have a first-class or void type. --- Diffs of the changes: (+8 -11) Index: llvm/lib/VMCore/BasicBlock.cpp diff -u llvm/lib/VMCore/BasicBlock.cpp:1.46 llvm/lib/VMCore/BasicBlock.cpp:1.47 --- llvm/lib/VMCore/BasicBlock.cpp:1.46 Sat Jun 5 12:43:52 2004 +++ llvm/lib/VMCore/BasicBlock.cpp Tue Jul 6 12:44:17 2004 @@ -130,17 +130,11 @@ void BasicBlock::removePredecessor(BasicBlock *Pred) { assert(find(pred_begin(this), pred_end(this), Pred) != pred_end(this) && "removePredecessor: BB is not a predecessor!"); - if (!isa(front())) return; // Quick exit. - - pred_iterator PI(pred_begin(this)), EI(pred_end(this)); - unsigned max_idx; - - // Loop over the rest of the predecessors until we run out, or until we find - // out that there are more than 2 predecessors. - for (max_idx = 0; PI != EI && max_idx < 3; ++PI, ++max_idx) /*empty*/; + PHINode *APN = dyn_cast(&front()); + if (!APN) return; // Quick exit. // If there are exactly two predecessors, then we want to nuke the PHI nodes - // altogether. We cannot do this, however if this in this case however: + // altogether. However, we cannot do this, if this in this case: // // Loop: // %x = phi [X, Loop] @@ -151,10 +145,10 @@ // basic block. The only case this can happen is with a self loop, so we // check for this case explicitly now. // + unsigned max_idx = APN->getNumIncomingValues(); assert(max_idx != 0 && "PHI Node in block with 0 predecessors!?!?!"); if (max_idx == 2) { - PI = pred_begin(this); - BasicBlock *Other = *PI == Pred ? *++PI : *PI; + BasicBlock *Other = APN->getIncomingBlock(APN->getIncomingBlock(0) == Pred); // Disable PHI elimination! if (this == Other) max_idx = 3; Index: llvm/lib/VMCore/Value.cpp diff -u llvm/lib/VMCore/Value.cpp:1.44 llvm/lib/VMCore/Value.cpp:1.45 --- llvm/lib/VMCore/Value.cpp:1.44 Sun Jul 4 06:55:37 2004 +++ llvm/lib/VMCore/Value.cpp Tue Jul 6 12:44:17 2004 @@ -31,6 +31,9 @@ Value::Value(const Type *ty, unsigned scid, const std::string &name) : SubclassID(scid), Ty(checkType(ty)), Name(name) { + if (!isa(this) && !isa(this)) + assert((Ty->isFirstClassType() || Ty == Type::VoidTy) && + "Cannot create non-first-class values except for constants!"); } Value::~Value() { From gaeke at cs.uiuc.edu Tue Jul 6 13:16:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Jul 6 13:16:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp Message-ID: <200407061815.NAA10021@kain.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: DecomposeMultiDimRefs.cpp updated: 1.32 -> 1.33 --- Log message: Add helper function. Don't touch GEPs for which DecomposeArrayRef is not going to do anything special (e.g., < 2 indices, or 2 indices and the last one is a constant.) --- Diffs of the changes: (+14 -2) Index: llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp diff -u llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp:1.32 llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp:1.33 --- llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp:1.32 Fri Jul 2 00:30:01 2004 +++ llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp Tue Jul 6 13:15:39 2004 @@ -24,6 +24,7 @@ #include "llvm/BasicBlock.h" #include "llvm/Pass.h" #include "Support/Statistic.h" +#include "Support/Debug.h" using namespace llvm; namespace { @@ -52,6 +53,10 @@ return new DecomposePass(); } +static inline bool isZeroConst (Value *V) { + return isa (V) && (cast(V)->isNullValue()); +} + // Function: DecomposeArrayRef() // // For any GetElementPtrInst with 2 or more array and structure indices: @@ -76,8 +81,15 @@ // Return value: true if the instruction was replaced; false otherwise. // bool llvm::DecomposeArrayRef(GetElementPtrInst* GEP) { - if (GEP->getNumIndices() < 2) + if (GEP->getNumIndices() < 2 + || (GEP->getNumIndices() == 2 + && isZeroConst(GEP->getOperand(1)) + && isa(GEP->getOperand(2)))) { + DEBUG (std::cerr << "DecomposeArrayRef: Skipping " << *GEP); return false; + } else { + DEBUG (std::cerr << "DecomposeArrayRef: Decomposing " << *GEP); + } BasicBlock *BB = GEP->getParent(); Value *LastPtr = GEP->getPointerOperand(); @@ -90,7 +102,7 @@ // If this is the first index and is 0, skip it and move on! if (OI == GEP->idx_begin()) { - if (*OI == ConstantInt::getNullValue((*OI)->getType())) + if (isZeroConst (*OI)) continue; } else // Not the first index: include initial [0] to deref the last ptr From gaeke at cs.uiuc.edu Tue Jul 6 13:17:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Jul 6 13:17:02 2004 Subject: [llvm-commits] CVS: reopt/test/run-tests Message-ID: <200407061815.NAA10035@kain.cs.uiuc.edu> Changes in directory reopt/test: run-tests updated: 1.9 -> 1.10 --- Log message: Add stanford benchmarks. --- Diffs of the changes: (+3 -0) Index: reopt/test/run-tests diff -u reopt/test/run-tests:1.9 reopt/test/run-tests:1.10 --- reopt/test/run-tests:1.9 Fri Jun 25 23:56:15 2004 +++ reopt/test/run-tests Tue Jul 6 13:15:41 2004 @@ -43,6 +43,7 @@ siod) SUBDIR=MultiSource/Applications/siod ;; shootout) SUBDIR=SingleSource/Benchmarks/Shootout ;; + stanford) SUBDIR=SingleSource/Benchmarks/Stanford ;; olden) SUBDIR=MultiSource/Benchmarks/Olden ;; ary3) SUBDIR=SingleSource/Reoptimizer/Ary3 ;; @@ -52,6 +53,8 @@ mynestedloop) SUBDIR=SingleSource/Reoptimizer/MyNestedLoop ;; fib2) SUBDIR=SingleSource/Reoptimizer/Fib2 ;; hash) SUBDIR=SingleSource/Reoptimizer/Hash ;; + towers) SUBDIR=SingleSource/Reoptimizer/Towers ;; + treesort) SUBDIR=SingleSource/Reoptimizer/Treesort ;; mcf) SUBDIR=External/SPEC/CINT2000/181.mcf; spectest=1 ;; art) SUBDIR=External/SPEC/CFP2000/179.art; spectest=1;; From gaeke at cs.uiuc.edu Tue Jul 6 13:17:04 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Jul 6 13:17:04 2004 Subject: [llvm-commits] CVS: reopt/test/TEST.reopt.Makefile Message-ID: <200407061815.NAA10028@kain.cs.uiuc.edu> Changes in directory reopt/test: TEST.reopt.Makefile updated: 1.18 -> 1.19 --- Log message: Add traceio library. --- Diffs of the changes: (+2 -1) Index: reopt/test/TEST.reopt.Makefile diff -u reopt/test/TEST.reopt.Makefile:1.18 reopt/test/TEST.reopt.Makefile:1.19 --- reopt/test/TEST.reopt.Makefile:1.18 Fri Jun 25 03:04:03 2004 +++ reopt/test/TEST.reopt.Makefile Tue Jul 6 13:15:40 2004 @@ -28,7 +28,8 @@ # Libraries that contain the Reoptimizer itself REOPTIMIZER_OBJS = $(REOPTLIBDIR)/firstTrigger.o \ $(REOPTLIBDIR)/tracecache.o $(REOPTLIBDIR)/mapinfo.o \ - $(REOPTLIBDIR)/scratchmemory.o $(REOPTLIBDIR)/tracetofunction.o $(REOPTLIBDIR)/tracejit.o + $(REOPTLIBDIR)/scratchmemory.o $(REOPTLIBDIR)/tracetofunction.o \ + $(REOPTLIBDIR)/tracejit.o $(REOPTLIBDIR)/traceio.o # Object files that contain common LLVM code the Reoptimizer depends on REOPTIMIZER_LLVMOBJS = $(DESTLIBCURRENT)/vmcore.o \ From gaeke at cs.uiuc.edu Tue Jul 6 14:26:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Jul 6 14:26:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp Message-ID: <200407061924.OAA12192@kain.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: DecomposeMultiDimRefs.cpp updated: 1.33 -> 1.34 --- Log message: It doesn't matter what the 2nd operand is; if the GEP has 2 operands and the first is a zero, we should leave it alone. --- Diffs of the changes: (+1 -2) Index: llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp diff -u llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp:1.33 llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp:1.34 --- llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp:1.33 Tue Jul 6 13:15:39 2004 +++ llvm/lib/Transforms/Scalar/DecomposeMultiDimRefs.cpp Tue Jul 6 14:24:47 2004 @@ -83,8 +83,7 @@ bool llvm::DecomposeArrayRef(GetElementPtrInst* GEP) { if (GEP->getNumIndices() < 2 || (GEP->getNumIndices() == 2 - && isZeroConst(GEP->getOperand(1)) - && isa(GEP->getOperand(2)))) { + && isZeroConst(GEP->getOperand(1)))) { DEBUG (std::cerr << "DecomposeArrayRef: Skipping " << *GEP); return false; } else { From lattner at cs.uiuc.edu Tue Jul 6 14:30:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Jul 6 14:30:03 2004 Subject: [llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp Message-ID: <200407061928.OAA11853@zion.cs.uiuc.edu> Changes in directory llvm/lib/Transforms/Scalar: InstructionCombining.cpp updated: 1.220 -> 1.221 --- Log message: Check to make sure types are sized before calling getTypeSize on them. --- Diffs of the changes: (+15 -13) Index: llvm/lib/Transforms/Scalar/InstructionCombining.cpp diff -u llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.220 llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.221 --- llvm/lib/Transforms/Scalar/InstructionCombining.cpp:1.220 Tue Jul 6 02:38:18 2004 +++ llvm/lib/Transforms/Scalar/InstructionCombining.cpp Tue Jul 6 14:28:42 2004 @@ -2098,22 +2098,24 @@ if (const PointerType *PTy = dyn_cast(CI.getType())) { // Get the type really allocated and the type casted to... const Type *AllocElTy = AI->getAllocatedType(); - unsigned AllocElTySize = TD->getTypeSize(AllocElTy); const Type *CastElTy = PTy->getElementType(); - unsigned CastElTySize = TD->getTypeSize(CastElTy); + if (AllocElTy->isSized() && CastElTy->isSized()) { + unsigned AllocElTySize = TD->getTypeSize(AllocElTy); + unsigned CastElTySize = TD->getTypeSize(CastElTy); - // If the allocation is for an even multiple of the cast type size - if (CastElTySize && (AllocElTySize % CastElTySize == 0)) { - Value *Amt = ConstantUInt::get(Type::UIntTy, + // If the allocation is for an even multiple of the cast type size + if (CastElTySize && (AllocElTySize % CastElTySize == 0)) { + Value *Amt = ConstantUInt::get(Type::UIntTy, AllocElTySize/CastElTySize); - std::string Name = AI->getName(); AI->setName(""); - AllocationInst *New; - if (isa(AI)) - New = new MallocInst(CastElTy, Amt, Name); - else - New = new AllocaInst(CastElTy, Amt, Name); - InsertNewInstBefore(New, *AI); - return ReplaceInstUsesWith(CI, New); + std::string Name = AI->getName(); AI->setName(""); + AllocationInst *New; + if (isa(AI)) + New = new MallocInst(CastElTy, Amt, Name); + else + New = new AllocaInst(CastElTy, Amt, Name); + InsertNewInstBefore(New, *AI); + return ReplaceInstUsesWith(CI, New); + } } } From lattner at cs.uiuc.edu Tue Jul 6 15:00:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Jul 6 15:00:03 2004 Subject: [llvm-commits] CVS: llvm/docs/BytecodeFormat.html Message-ID: <200407061959.OAA13691@apoc.cs.uiuc.edu> Changes in directory llvm/docs: BytecodeFormat.html updated: 1.16 -> 1.17 --- Log message: Punctuate --- Diffs of the changes: (+2 -2) Index: llvm/docs/BytecodeFormat.html diff -u llvm/docs/BytecodeFormat.html:1.16 llvm/docs/BytecodeFormat.html:1.17 --- llvm/docs/BytecodeFormat.html:1.16 Mon Jul 5 17:28:02 2004 +++ llvm/docs/BytecodeFormat.html Tue Jul 6 14:58:54 2004 @@ -629,7 +629,7 @@

    The module global info block contains the definitions of all global variables including their initializers and the declaration of all - functions. The format is shown in the table below

    + functions. The format is shown in the table below:

    @@ -1249,7 +1249,7 @@ Reid Spencer and Chris Lattner
    The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/07/05 22:28:02 $ + Last modified: $Date: 2004/07/06 19:58:54 $ From gaeke at cs.uiuc.edu Tue Jul 6 15:30:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Jul 6 15:30:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Support/Mangler.cpp Message-ID: <200407062029.PAA12734@zion.cs.uiuc.edu> Changes in directory llvm/lib/Support: Mangler.cpp updated: 1.11 -> 1.12 --- Log message: Work around apparent Apple compiler bug which was making all mangled names start with l0_. --- Diffs of the changes: (+2 -2) Index: llvm/lib/Support/Mangler.cpp diff -u llvm/lib/Support/Mangler.cpp:1.11 llvm/lib/Support/Mangler.cpp:1.12 --- llvm/lib/Support/Mangler.cpp:1.11 Mon Apr 5 15:17:53 2004 +++ llvm/lib/Support/Mangler.cpp Tue Jul 6 15:29:05 2004 @@ -71,8 +71,8 @@ } else { // Non-global, or global with internal linkage / colliding name // -> mangle. - name = "l" + utostr(V->getType()->getUniqueID()) + "_" + - makeNameProper(V->getName()); + unsigned TypeUniqueID = V->getType()->getUniqueID(); + name = "l" + utostr(TypeUniqueID) + "_" + makeNameProper(V->getName()); } } else { name = "ltmp_" + utostr(Count++) + "_" From lattner at cs.uiuc.edu Tue Jul 6 18:26:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Jul 6 18:26:02 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200407062325.SAA15589@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.105 -> 1.106 --- Log message: Make sure people don't make functiontypes with an invalid return type --- Diffs of the changes: (+2 -0) Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.105 llvm/lib/VMCore/Type.cpp:1.106 --- llvm/lib/VMCore/Type.cpp:1.105 Sun Jul 4 07:15:11 2004 +++ llvm/lib/VMCore/Type.cpp Tue Jul 6 18:25:19 2004 @@ -402,6 +402,8 @@ const std::vector &Params, bool IsVarArgs) : DerivedType(FunctionTyID), isVarArgs(IsVarArgs) { + assert((Result->isFirstClassType() || Result == Type::VoidTy) && + "LLVM functions cannot return aggregates"); bool isAbstract = Result->isAbstract(); ContainedTys.reserve(Params.size()+1); ContainedTys.push_back(PATypeHandle(Result, this)); From alkis at cs.uiuc.edu Tue Jul 6 21:04:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Tue Jul 6 21:04:01 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp Message-ID: <200407070203.VAA00386@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.85 -> 1.86 --- Log message: Disable coalescing. --- Diffs of the changes: (+1 -1) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.85 llvm/lib/CodeGen/LiveIntervals.cpp:1.86 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.85 Tue Jul 6 11:03:21 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Tue Jul 6 21:03:12 2004 @@ -59,7 +59,7 @@ cl::opt join("join-liveintervals", cl::desc("Join compatible live intervals"), - cl::init(true)); + cl::init(false)); }; void LiveIntervals::getAnalysisUsage(AnalysisUsage &AU) const From gaeke at cs.uiuc.edu Tue Jul 6 21:21:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Jul 6 21:21:02 2004 Subject: [llvm-commits] CVS: reopt/include/reopt/TraceToFunction.h Message-ID: <200407070220.VAA15160@kain.cs.uiuc.edu> Changes in directory reopt/include/reopt: TraceToFunction.h updated: 1.15 -> 1.16 --- Log message: Make LiveIn, LiveOut, and AlternateEntryPoint vectors that exist in parallel with the sets. The idea is to gradually reduce dependence on the sets and use the vectors instead. --- Diffs of the changes: (+3 -0) Index: reopt/include/reopt/TraceToFunction.h diff -u reopt/include/reopt/TraceToFunction.h:1.15 reopt/include/reopt/TraceToFunction.h:1.16 --- reopt/include/reopt/TraceToFunction.h:1.15 Wed Jun 23 16:41:33 2004 +++ reopt/include/reopt/TraceToFunction.h Tue Jul 6 21:19:51 2004 @@ -16,6 +16,7 @@ namespace llvm { typedef std::set LiveVariableSet; +typedef std::vector LiveVariableVector; typedef std::map BasicBlockMap; typedef std::map ValueMap; typedef std::map ValueToIntMap; @@ -47,10 +48,12 @@ /// Variables live going in to TraceFn from MatrixFn /// LiveVariableSet LiveInSet; + LiveVariableVector LiveInVector; /// Variables live going out from TraceFn back into MatrixFn /// LiveVariableSet LiveOutSet; + LiveVariableVector LiveOutVector; /// Constructor - you can't have a TraceFunction without a Trace. /// This gives you a "blank" TraceFunction without a TraceFn or any From lattner at cs.uiuc.edu Tue Jul 6 21:21:09 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Jul 6 21:21:09 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/CFrontend/2004-07-06-FunctionCast.c Message-ID: <200407070220.VAA16531@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/CFrontend: 2004-07-06-FunctionCast.c added (r1.1) --- Log message: New testcase for PR396: http://llvm.cs.uiuc.edu/PR396 --- Diffs of the changes: (+8 -0) Index: llvm/test/Regression/CFrontend/2004-07-06-FunctionCast.c diff -c /dev/null llvm/test/Regression/CFrontend/2004-07-06-FunctionCast.c:1.1 *** /dev/null Tue Jul 6 21:20:12 2004 --- llvm/test/Regression/CFrontend/2004-07-06-FunctionCast.c Tue Jul 6 21:20:02 2004 *************** *** 0 **** --- 1,8 ---- + static int unused_func(void) { + return 1; + } + + int foo(void) { + (void)unused_func; /* avoid compiler warning */ + return 2; + } From gaeke at cs.uiuc.edu Tue Jul 6 21:21:14 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Jul 6 21:21:14 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Message-ID: <200407070220.VAA15167@kain.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: UnpackTraceFunction.cpp updated: 1.90 -> 1.91 --- Log message: Make LiveIn, LiveOut, and AlternateEntryPoint vectors that exist in parallel with the sets. The idea is to gradually reduce dependence on the sets and use the vectors instead. --- Diffs of the changes: (+6 -6) Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.90 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.91 --- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.90 Thu Jul 1 03:39:48 2004 +++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Tue Jul 6 21:19:51 2004 @@ -113,9 +113,9 @@ // Get the saved register allocator state for all live-in variables. // We are going to need to save live-in values which reside in registers // on the stack, so we need to dig their register numbers out now. - LiveVariableSet &Si = TF->LiveInSet; + LiveVariableVector &Si = TF->LiveInVector; AllocStates.clear (); - for (LiveVariableSet::iterator SI = Si.begin (), SE = Si.end (); SI != SE; + for (LiveVariableVector::iterator SI = Si.begin (), SE = Si.end (); SI != SE; ++SI) { Value *V = *SI; std::pair > as = @@ -208,8 +208,8 @@ // 3. Insert a copy for each live-in variable to copy it from the stack // to the register or stack slot that was allocated for it in the TraceFn. - LiveVariableSet &Si = TF->LiveInSet; - for (LiveVariableSet::iterator SI = Si.begin (), SE = Si.end (); SI != SE; + LiveVariableVector &Si = TF->LiveInVector; + for (LiveVariableVector::iterator SI = Si.begin (), SE = Si.end (); SI != SE; ++SI) { Value *V = *SI; std::pair &ai = AllocStates[V]; @@ -457,8 +457,8 @@ // to its stack slot in the trace function, from which it will be // reloaded below into a register. std::vector mvec; - LiveVariableSet &So = TF->LiveOutSet; - for (LiveVariableSet::iterator SI = So.begin (), SE = So.end (); + LiveVariableVector &So = TF->LiveOutVector; + for (LiveVariableVector::iterator SI = So.begin (), SE = So.end (); SI != SE; ++SI) { Value *V = *SI; std::pair ai = GetValueAllocState (TF, V, false); From gaeke at cs.uiuc.edu Tue Jul 6 21:21:18 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Jul 6 21:21:18 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceToFunction/TraceToFunction.cpp Message-ID: <200407070220.VAA15174@kain.cs.uiuc.edu> Changes in directory reopt/lib/TraceToFunction: TraceToFunction.cpp updated: 1.68 -> 1.69 --- Log message: Make LiveIn, LiveOut, and AlternateEntryPoint vectors that exist in parallel with the sets. The idea is to gradually reduce dependence on the sets and use the vectors instead. --- Diffs of the changes: (+54 -40) Index: reopt/lib/TraceToFunction/TraceToFunction.cpp diff -u reopt/lib/TraceToFunction/TraceToFunction.cpp:1.68 reopt/lib/TraceToFunction/TraceToFunction.cpp:1.69 --- reopt/lib/TraceToFunction/TraceToFunction.cpp:1.68 Wed Jun 23 16:41:34 2004 +++ reopt/lib/TraceToFunction/TraceToFunction.cpp Tue Jul 6 21:19:51 2004 @@ -52,8 +52,11 @@ BranchNumberMap BranchNumber; TraceFunction *TF; std::set AlternateEntryPoints; - void getTraceLiveInSet (LiveVariableSet &S, Trace &T); - void getTraceLiveOutSet (LiveVariableSet &S, Trace &T); + std::vector AlternateEntryPointsV; + void getTraceLiveInSet (LiveVariableSet &S, LiveVariableVector &LVV, + Trace &T); + void getTraceLiveOutSet (LiveVariableSet &S, LiveVariableVector &LVV, + Trace &T); FLIMapTy FLIMap; BasicBlock *getFLIEdgeSource (BasicBlock *BB) const; @@ -62,12 +65,12 @@ void buildFLIMap (Trace &T, FLIMapTy &FLIMap); TypeVector createFunctionArgTypeVector (PointerType *ST, - const LiveVariableSet &S); - void fillInFunctionBody (Trace &T, Function *F, LiveVariableSet &So); + const LiveVariableVector &S); + void fillInFunctionBody (Trace &T, Function *F, LiveVariableVector &So); int findOffTracePhiSource (const PHINode *newPN); void fixupFunctionBodyBB (Trace &T, Function *F, BasicBlock *srcB, BasicBlock *dstB, ValueMap &O2CMap, - LiveVariableSet &So); + LiveVariableVector &So); void cloneMapDump (); public: @@ -170,17 +173,28 @@ return true; } +static void insert (LiveVariableSet &Set, LiveVariableVector &Vector, Value *V){ + Set.insert (V); + if (std::find (Vector.begin (), Vector.end (), V) == Vector.end ()) + Vector.push_back (V); +} +static void insert (std::set &Set, std::vector &Vector, BasicBlock *V){ + Set.insert (V); + if (std::find (Vector.begin (), Vector.end (), V) == Vector.end ()) + Vector.push_back (V); +} + /// addTraceLiveInsToSet - helper fn. for getTraceLiveInSet and /// getTraceLiveOutSet. Adds the live-ins of T to S, assuming that /// the trace starts at StartingFrom and ends at T.end(). -static void addTraceLiveInsToSet (LiveVariableSet &S, Trace &T, - Trace::iterator StartingFrom) { +static void addTraceLiveInsToSet (LiveVariableSet &S, LiveVariableVector &LVV, + Trace &T, Trace::iterator StartingFrom) { for (Trace::iterator TI = StartingFrom, TE = T.end (); TI != TE; ++TI) for (BasicBlock::iterator Inst = (*TI)->begin (), BE = (*TI)->end (); Inst != BE; ++Inst) { if (PHINode *PN = dyn_cast (Inst)) { if (TI == StartingFrom) { - S.insert (Inst); // Add phis from first BB + insert(S, LVV, Inst); // Add phis from first BB } else { // Phi node internal to trace DEBUG (std::cerr << "TLV: considering Phi internal to trace: " << Inst->getName () << "\n"); @@ -193,7 +207,7 @@ || isa(V))) { DEBUG (std::cerr << "TLV: considering Phi source which is on-trace: " << InB->getName () << " with value " << V->getName () << "\n"); if (!DefinedInTraceBeforeUse (V, T, StartingFrom, true)) - S.insert (V); + insert (S, LVV, V); } } } @@ -206,7 +220,7 @@ if (!(isa (V) || isa (V) || isa(V))) if (!DefinedInTraceBeforeUse (V, T, StartingFrom, true)) - S.insert (V); + insert (S, LVV, V); } } } @@ -216,8 +230,8 @@ /// EXCEPT if it's a constant or a global, OR it is defined before being used /// in the trace. /// -void TraceFunctionBuilder::getTraceLiveInSet (LiveVariableSet &S, Trace &T) { - addTraceLiveInsToSet (S, T, T.begin ()); +void TraceFunctionBuilder::getTraceLiveInSet (LiveVariableSet &S, LiveVariableVector &LVV, Trace &T) { + addTraceLiveInsToSet (S, LVV, T, T.begin ()); } /// getTraceLiveOutSet - Initializes S with the live-out set of trace T. @@ -227,7 +241,7 @@ /// to the NON-traced version of the code caused by early exits that end up /// taking back-edge branches. /// -void TraceFunctionBuilder::getTraceLiveOutSet (LiveVariableSet &S, Trace &T) { +void TraceFunctionBuilder::getTraceLiveOutSet (LiveVariableSet &S, LiveVariableVector &LVV, Trace &T) { // Iterate over the instructions in the trace, adding live-out values to S. for (Trace::iterator TI = T.begin (), TE = T.end (); TI != TE; ++TI) for (BasicBlock::iterator Inst = (*TI)->begin (), BE = (*TI)->end (); @@ -236,18 +250,18 @@ if (!(Inst->getType () == Type::VoidTy || Inst->getType () == Type::LabelTy)) if (!DefinedInTraceBeforeUse (Inst, T, T.begin (), false)) - S.insert (Inst); + insert (S, LVV, Inst); } // If there are alternate entry points into the trace, their live-INs are // live-OUT from the main trace. if (!AlternateEntryPoints.empty ()) { - for (std::set::iterator i = AlternateEntryPoints.begin (), - e = AlternateEntryPoints.end (); i != e; ++i) { + for (std::vector::iterator i = AlternateEntryPointsV.begin (), + e = AlternateEntryPointsV.end (); i != e; ++i) { // Find the position of the block in the trace. Trace::iterator StartingFrom = std::find (T.begin (), T.end (), *i); assert (StartingFrom != T.end () && "AlternateEntryPoint not on trace?!"); - addTraceLiveInsToSet (S, T, StartingFrom); + addTraceLiveInsToSet (S, LVV, T, StartingFrom); } } } @@ -270,13 +284,13 @@ /// createLiveOutType - Given the live-out set S of a trace, create a /// pointer-to-structure type that will encapsulate all the live-outs from S. /// -static PointerType *createLiveOutType (const LiveVariableSet &S) { +static PointerType *createLiveOutType (const LiveVariableVector &LVV) { TypeVector T; unsigned Counter = 0; // For each variable in S, make a new entry in T having its type. DEBUG (std::cerr << "Live-out values:\n"); - for (LiveVariableSet::const_iterator I = S.begin (), E = S.end (); I != E; - ++I) { + for (LiveVariableVector::const_iterator I = LVV.begin (), E = LVV.end (); + I != E; ++I) { DEBUG (WriteAsOperand (std::cerr, *I, true, true, cast(*I)->getParent ()->getParent () ->getParent ()); @@ -286,20 +300,20 @@ return PointerType::get (StructType::get (T)); } -/// createFunctionArgTypeVector - Given the live-in set S of a trace, +/// createFunctionArgTypeVector - Given the live-in vector LVV of a trace, /// create a parameter list containing a parameter for each of the -/// variables in S as well as a pointer-to-structure type PST to fill +/// variables in LVV as well as a pointer-to-structure type PST to fill /// in which contains the live-outs. As a side effect, fill in the /// mapping between live-ins and parameters in /// TF->LiveInToParameterMap. /// TypeVector TraceFunctionBuilder::createFunctionArgTypeVector (PointerType *PST, - const LiveVariableSet &S) { + const LiveVariableVector &LVV) { TypeVector P; P.push_back (PST); TF->LiveInToParameterMap.clear (); - for (LiveVariableSet::const_iterator I = S.begin (), E = S.end (); I != E; + for (LiveVariableVector::const_iterator I = LVV.begin (), E = LVV.end (); I != E; ++I) { Value *V = *I; P.push_back (V->getType ()); @@ -317,10 +331,9 @@ } /// giveNamesToFunctionArgs - Name the first argument of F "liveOut", -/// then use the ordering imposed by S's iterator to name the -/// remaining arguments of F. +/// then name the remaining arguments of F according to LVV. /// -static void giveNamesToFunctionArgs (LiveVariableSet S, Function *F) { +static void giveNamesToFunctionArgs (LiveVariableVector LVV, Function *F) { Function::aiterator argIterator = F->abegin (); unsigned argPosition = 0; @@ -328,7 +341,8 @@ ++argPosition; ++argIterator; - for (LiveVariableSet::iterator I = S.begin (), E = S.end (); I != E; ++I) { + for (LiveVariableVector::iterator I = LVV.begin (), E = LVV.end (); I != E; + ++I) { std::string name ((*I)->getName ()); if (name == "") name = "arg" + utostr (argPosition); @@ -358,7 +372,7 @@ /// static void cloneTraceBBsIntoFunction (TraceFunction *TF) { Function *MF = TF->MatrixFn; - LiveVariableSet &Si = TF->LiveInSet; + LiveVariableVector &Si = TF->LiveInVector; ValueMap &O2CMap = TF->O2CMap; for (Function::aiterator AI = MF->abegin (), AE = MF->aend (); AI != AE; ++AI) O2CMap[AI] = AI; @@ -369,7 +383,7 @@ ++BI) O2CMap[BI] = BI; } - for (LiveVariableSet::iterator I = Si.begin (), E = Si.end (); I != E; ++I) + for (LiveVariableVector::iterator I = Si.begin (), E = Si.end (); I != E; ++I) O2CMap[*I] = getFunctionArg (TF->TraceFn, TF->LiveInToParameterMap[*I]); CloneTraceInto (TF->TraceFn, TF->T, O2CMap, ".ttf"); } @@ -461,7 +475,7 @@ /// argument. /// void TraceFunctionBuilder::fillInFunctionBody (Trace &T, Function *F, - LiveVariableSet &So) { + LiveVariableVector &So) { // First copy the basic blocks from the trace. cloneTraceBBsIntoFunction (TF); @@ -570,7 +584,7 @@ if (T.contains (edge.second) && edge.second != T.getEntryBasicBlock ()) { DEBUG (std::cerr << "buildFLIMap: " << edge.second->getName() << " is a back-edge target that's internal to the trace\n"); - AlternateEntryPoints.insert (edge.second); + insert (AlternateEntryPoints, AlternateEntryPointsV, edge.second); } // 1. remove the block from the trace if it is in there BasicBlock *bb = i; @@ -623,7 +637,7 @@ BasicBlock *srcB, BasicBlock *dstB, ValueMap &O2CMap, - LiveVariableSet &So) { + LiveVariableVector &So) { assert (T.contains (srcB) && "Source BB is not on the trace"); assert (dstB->getParent () == F && "Clone is not in the function"); @@ -707,7 +721,7 @@ // Add the getelementptr/store instruction pairs here that // correspond to each live-out variable. unsigned Slot = 0; - for (LiveVariableSet::iterator SI = So.begin (), SE = So.end (); + for (LiveVariableVector::iterator SI = So.begin (), SE = So.end (); SI != SE; ++SI) { if (dominates (T, cast ((*SI))->getParent (), BI->getParent ())) { @@ -822,11 +836,11 @@ // Get some information about the trace's relationship to its parent // function. - getTraceLiveInSet (TF->LiveInSet, T); - getTraceLiveOutSet (TF->LiveOutSet, T); + getTraceLiveInSet (TF->LiveInSet, TF->LiveInVector, T); + getTraceLiveOutSet (TF->LiveOutSet, TF->LiveOutVector, T); TypeVector P = - createFunctionArgTypeVector (createLiveOutType (TF->LiveOutSet), - TF->LiveInSet); + createFunctionArgTypeVector (createLiveOutType (TF->LiveOutVector), + TF->LiveInVector); // Make a new internal Function with return type int and parameter // list P, in the same Module as the trace's parent function. @@ -834,8 +848,8 @@ TF->TraceFn = new Function (FunctionType::get (Type::UIntTy, P, false), GlobalValue::InternalLinkage, name, T.getModule ()); - DEBUG(giveNamesToFunctionArgs (TF->LiveInSet, TF->TraceFn)); - fillInFunctionBody (T, TF->TraceFn, TF->LiveOutSet); + DEBUG(giveNamesToFunctionArgs (TF->LiveInVector, TF->TraceFn)); + fillInFunctionBody (T, TF->TraceFn, TF->LiveOutVector); return TF; } From gaeke at cs.uiuc.edu Tue Jul 6 21:22:03 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Tue Jul 6 21:22:03 2004 Subject: [llvm-commits] CVS: reopt/test/run-tests Message-ID: <200407070220.VAA15181@kain.cs.uiuc.edu> Changes in directory reopt/test: run-tests updated: 1.10 -> 1.11 --- Log message: Add intMM. --- Diffs of the changes: (+1 -0) Index: reopt/test/run-tests diff -u reopt/test/run-tests:1.10 reopt/test/run-tests:1.11 --- reopt/test/run-tests:1.10 Tue Jul 6 13:15:41 2004 +++ reopt/test/run-tests Tue Jul 6 21:19:52 2004 @@ -55,6 +55,7 @@ hash) SUBDIR=SingleSource/Reoptimizer/Hash ;; towers) SUBDIR=SingleSource/Reoptimizer/Towers ;; treesort) SUBDIR=SingleSource/Reoptimizer/Treesort ;; + intmm) SUBDIR=SingleSource/Reoptimizer/IntMM ;; mcf) SUBDIR=External/SPEC/CINT2000/181.mcf; spectest=1 ;; art) SUBDIR=External/SPEC/CFP2000/179.art; spectest=1;; From lattner at cs.uiuc.edu Tue Jul 6 21:23:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Jul 6 21:23:02 2004 Subject: [llvm-commits] CVS: llvm-gcc/gcc/llvm-expand.c Message-ID: <200407070222.VAA18287@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: llvm-expand.c updated: 1.46 -> 1.47 --- Log message: Fix PR396: http://llvm.cs.uiuc.edu/PR396 and test/Regression/CFrontend/2004-07-06-FunctionCast.c --- Diffs of the changes: (+2 -0) Index: llvm-gcc/gcc/llvm-expand.c diff -u llvm-gcc/gcc/llvm-expand.c:1.46 llvm-gcc/gcc/llvm-expand.c:1.47 --- llvm-gcc/gcc/llvm-expand.c:1.46 Mon Jun 28 23:43:42 2004 +++ llvm-gcc/gcc/llvm-expand.c Tue Jul 6 21:22:24 2004 @@ -5762,6 +5762,8 @@ return llvm_constant_VoidPtr_null; DestTy = llvm_type_get_from_tree(type); + if (DestTy->ID == FunctionTyID) DestTy = llvm_type_get_pointer(DestTy); + isDestTyComposite = llvm_type_is_composite(DestTy); /* Check to make sure DestLoc is set when it is supposed to be. */ From lattner at cs.uiuc.edu Tue Jul 6 21:26:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Jul 6 21:26:01 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200407070225.VAA18318@apoc.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.210 -> 1.211 --- Log message: Bug fixed --- Diffs of the changes: (+2 -1) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.210 llvm/docs/ReleaseNotes.html:1.211 --- llvm/docs/ReleaseNotes.html:1.210 Fri Jul 2 11:23:17 2004 +++ llvm/docs/ReleaseNotes.html Tue Jul 6 21:25:24 2004 @@ -301,6 +301,7 @@ length array of structures
  • [llvmgcc] miscompilation of staticly initialized unsigned bitfields
  • +
  • [llvm-gcc] Crash casting function to void
  • @@ -747,7 +748,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/07/02 16:23:17 $ + Last modified: $Date: 2004/07/07 02:25:24 $ From lattner at cs.uiuc.edu Tue Jul 6 21:28:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Jul 6 21:28:01 2004 Subject: [llvm-commits] CVS: llvm-www/releases/1.2/docs/ReleaseNotes.html Message-ID: <200407070227.VAA18343@apoc.cs.uiuc.edu> Changes in directory llvm-www/releases/1.2/docs: ReleaseNotes.html updated: 1.23 -> 1.24 --- Log message: Bug found --- Diffs of the changes: (+2 -1) Index: llvm-www/releases/1.2/docs/ReleaseNotes.html diff -u llvm-www/releases/1.2/docs/ReleaseNotes.html:1.23 llvm-www/releases/1.2/docs/ReleaseNotes.html:1.24 --- llvm-www/releases/1.2/docs/ReleaseNotes.html:1.23 Mon Jun 21 22:45:20 2004 +++ llvm-www/releases/1.2/docs/ReleaseNotes.html Tue Jul 6 21:27:05 2004 @@ -396,6 +396,7 @@
  • [llvmgcc] Variable length array indexing miscompiled
  • [llvmgcc] Errors handling function prototypes that take opaque structs by-value
  • [llvmgcc] Crash compiling variable length array of structures
  • +
  • [llvm-gcc] Crash casting function to void
  • @@ -689,7 +690,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
    - Last modified: $Date: 2004/06/22 03:45:20 $ + Last modified: $Date: 2004/07/07 02:27:05 $ From lattner at cs.uiuc.edu Tue Jul 6 22:15:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Jul 6 22:15:02 2004 Subject: [llvm-commits] CVS: llvm-gcc/gcc/llvm-types.c llvm-representation.h Message-ID: <200407070313.WAA23202@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: llvm-types.c updated: 1.9 -> 1.10 llvm-representation.h updated: 1.7 -> 1.8 --- Log message: Add a global IntPtrTy type. --- Diffs of the changes: (+10 -2) Index: llvm-gcc/gcc/llvm-types.c diff -u llvm-gcc/gcc/llvm-types.c:1.9 llvm-gcc/gcc/llvm-types.c:1.10 --- llvm-gcc/gcc/llvm-types.c:1.9 Tue Jun 8 02:12:43 2004 +++ llvm-gcc/gcc/llvm-types.c Tue Jul 6 22:13:44 2004 @@ -60,6 +60,12 @@ case ArrayTyID: return llvm_type_get_size(Ty->Elements[0])*Ty->x.Array.Size; case StructTyID: return Ty->x.Struct.Size; case PointerTyID: /* Target dependant pointer size */ + switch (ptr_mode) { + case SImode: case PSImode: return 4; + case DImode: case PDImode: return 8; + default: + assert(0 && "Unknown mode for pointer type!"); + } return (TREE_INT_CST_LOW(TYPE_SIZE(ptr_type_node))+7)/8; default: fprintf(stderr, "ERROR: Type doesn't have size: "); @@ -96,7 +102,7 @@ llvm_type *FloatTy = &TheFloatTy; llvm_type *DoubleTy = &TheDoubleTy; llvm_type *LabelTy = &TheLabelTy; -llvm_type *VoidPtrTy = 0; +llvm_type *VoidPtrTy = 0, *IntPtrTy; /*===---------------------------------------------------------------------===*\ * More complex type functions built on primitives @@ -203,6 +209,8 @@ /* Commonly used derived types... */ VoidPtrTy = llvm_type_get_pointer(VoidTy); + + IntPtrTy = llvm_type_get_size(VoidPtrTy) == 4 ? IntTy : LongTy; } llvm_type *llvm_type_get_cannonical_struct(llvm_type *Ty) { Index: llvm-gcc/gcc/llvm-representation.h diff -u llvm-gcc/gcc/llvm-representation.h:1.7 llvm-gcc/gcc/llvm-representation.h:1.8 --- llvm-gcc/gcc/llvm-representation.h:1.7 Wed Jun 2 13:45:07 2004 +++ llvm-gcc/gcc/llvm-representation.h Tue Jul 6 22:13:44 2004 @@ -405,7 +405,7 @@ extern llvm_type *VoidTy, *BoolTy, *UByteTy, *SByteTy, *UShortTy, *ShortTy; extern llvm_type *UIntTy, *IntTy, *ULongTy, *LongTy, *FloatTy, *DoubleTy; -extern llvm_type *LabelTy, *VoidPtrTy; +extern llvm_type *LabelTy, *VoidPtrTy, *IntPtrTy; void llvm_type_print(llvm_type *Ty, FILE *F); void llvm_type_dump(llvm_type *Ty); From lattner at cs.uiuc.edu Tue Jul 6 22:21:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Jul 6 22:21:02 2004 Subject: [llvm-commits] CVS: llvm-gcc/gcc/llvm-representation.h llvm-representation.c Message-ID: <200407070320.WAA24570@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: llvm-representation.h updated: 1.8 -> 1.9 llvm-representation.c updated: 1.8 -> 1.9 --- Log message: Add a new intptr_0 constant --- Diffs of the changes: (+7 -0) Index: llvm-gcc/gcc/llvm-representation.h diff -u llvm-gcc/gcc/llvm-representation.h:1.8 llvm-gcc/gcc/llvm-representation.h:1.9 --- llvm-gcc/gcc/llvm-representation.h:1.8 Tue Jul 6 22:13:44 2004 +++ llvm-gcc/gcc/llvm-representation.h Tue Jul 6 22:19:52 2004 @@ -104,6 +104,7 @@ extern llvm_value *llvm_constant_int_0; extern llvm_value *llvm_constant_uint_0; extern llvm_value *llvm_constant_long_0; +extern llvm_value *llvm_constant_intptr_0; extern llvm_value *llvm_constant_bool_true; extern llvm_value *llvm_constant_bool_false; Index: llvm-gcc/gcc/llvm-representation.c diff -u llvm-gcc/gcc/llvm-representation.c:1.8 llvm-gcc/gcc/llvm-representation.c:1.9 --- llvm-gcc/gcc/llvm-representation.c:1.8 Fri May 7 13:32:35 2004 +++ llvm-gcc/gcc/llvm-representation.c Tue Jul 6 22:19:52 2004 @@ -312,6 +312,7 @@ llvm_value *llvm_constant_long_0; llvm_value *llvm_constant_int_0; llvm_value *llvm_constant_uint_0; +llvm_value *llvm_constant_intptr_0; llvm_value *llvm_constant_VoidPtr_null; llvm_value *llvm_constant_bool_true; llvm_value *llvm_constant_bool_false; @@ -325,6 +326,11 @@ llvm_constant_uint_0 = llvm_constant_new(UIntTy, "0"); llvm_constant_uint_1 = llvm_constant_new(UIntTy, "1"); llvm_constant_VoidPtr_null = llvm_constant_new(VoidPtrTy, "null"); + + if (llvm_type_get_size(llvm_constant_VoidPtr_null->Ty) == 8) + llvm_constant_intptr_0 = llvm_constant_long_0; + else + llvm_constant_intptr_0 = llvm_constant_int_0; } llvm_value *llvm_constant_get_null(llvm_type *Ty) { From lattner at cs.uiuc.edu Tue Jul 6 22:35:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Jul 6 22:35:02 2004 Subject: [llvm-commits] CVS: llvm-gcc/gcc/llvm-expand.c Message-ID: <200407070334.WAA24604@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: llvm-expand.c updated: 1.47 -> 1.48 --- Log message: Fix PR394: http://llvm.cs.uiuc.edu/PR394 . This makes the CFE emit int indices for sequential gep instructions on 32-bit targets. While I'm at it, use uint constants instead of ubyte constants for indexing into structure fields. --- Diffs of the changes: (+62 -62) Index: llvm-gcc/gcc/llvm-expand.c diff -u llvm-gcc/gcc/llvm-expand.c:1.47 llvm-gcc/gcc/llvm-expand.c:1.48 --- llvm-gcc/gcc/llvm-expand.c:1.47 Tue Jul 6 21:22:24 2004 +++ llvm-gcc/gcc/llvm-expand.c Tue Jul 6 22:34:17 2004 @@ -181,14 +181,14 @@ llvm_instruction *GEP = llvm_instruction_new(Ty, "tmp", O_GetElementPtr, 2+Depth); GEP->Operands[0] = V; - GEP->Operands[1] = llvm_constant_long_0; + GEP->Operands[1] = llvm_constant_intptr_0; STy = GET_POINTER_TYPE_ELEMENT(V->Ty); for (Depth = 2; STy != DTy; STy = STy->Elements[0]) if (STy->ID == StructTyID) - GEP->Operands[Depth++] = llvm_constant_ubyte_0; + GEP->Operands[Depth++] = llvm_constant_uint_0; else - GEP->Operands[Depth++] = llvm_constant_long_0; + GEP->Operands[Depth++] = llvm_constant_intptr_0; return append_inst(Fn, GEP); } } @@ -225,8 +225,8 @@ } else if (ElTy->ID == StructTyID) { unsigned i; for (i = 0; i != ElTy->NumElements; ++i) { - llvm_instruction *OffsetInst = create_gep3(Dest, llvm_constant_long_0, - llvm_constant_new_integral(UByteTy, i)); + llvm_instruction *OffsetInst = create_gep3(Dest, llvm_constant_intptr_0, + llvm_constant_new_integral(UIntTy, i)); llvm_zero_initialize(Fn, append_inst(Fn, OffsetInst)); } @@ -234,8 +234,8 @@ unsigned i; for (i = 0; i != GET_ARRAY_TYPE_SIZE(ElTy); ++i) { llvm_instruction *OffsetInst = - create_gep3(Dest, llvm_constant_long_0, - llvm_constant_new_integral(LongTy, i)); + create_gep3(Dest, llvm_constant_intptr_0, + llvm_constant_new_integral(IntPtrTy, i)); llvm_zero_initialize(Fn, append_inst(Fn, OffsetInst)); } @@ -297,8 +297,8 @@ unsigned i; for (i = 0; i != ElTy->NumElements; ++i) { llvm_instruction *OffsetInst = - create_gep3(Dest, llvm_constant_long_0, - llvm_constant_new_integral(UByteTy, i)); + create_gep3(Dest, llvm_constant_intptr_0, + llvm_constant_new_integral(UIntTy, i)); llvm_get_composite_vararg(Fn, VAList, append_inst(Fn, OffsetInst)); } @@ -306,8 +306,8 @@ unsigned i; for (i = 0; i != GET_ARRAY_TYPE_SIZE(ElTy); ++i) { llvm_instruction *OffsetInst = - create_gep3(Dest, llvm_constant_long_0, - llvm_constant_new_integral(LongTy, i)); + create_gep3(Dest, llvm_constant_intptr_0, + llvm_constant_new_integral(IntPtrTy, i)); llvm_get_composite_vararg(Fn, VAList, append_inst(Fn, OffsetInst)); } @@ -466,7 +466,7 @@ */ if (llvm_type_get_size(ObjTy) > 128) { EmitMemCpyMove(Fn, DestPtr, SrcPtr, - llvm_constant_new_integral(LongTy,llvm_type_get_size(ObjTy)), + llvm_constant_new_integral(IntPtrTy,llvm_type_get_size(ObjTy)), Alignment, 0); return; } @@ -475,11 +475,11 @@ switch (ObjTy->ID) { case StructTyID: for (i = 0; i < ObjTy->NumElements; ++i) { - llvm_value *FieldNo = llvm_constant_new_integral(UByteTy, i); + llvm_value *FieldNo = llvm_constant_new_integral(UIntTy, i); llvm_value *DestElPtr = append_inst(Fn, create_gep3(DestPtr, - llvm_constant_long_0, FieldNo)); + llvm_constant_intptr_0, FieldNo)); llvm_value *SrcElPtr = append_inst(Fn, create_gep3(SrcPtr, - llvm_constant_long_0, FieldNo)); + llvm_constant_intptr_0, FieldNo)); llvm_copy_aggregate(Fn, DestElPtr, SrcElPtr, isSourceVolatile, isDestVolatile, 1); @@ -488,11 +488,11 @@ case ArrayTyID: { for (i = 0; i < GET_ARRAY_TYPE_SIZE(ObjTy); ++i) { - llvm_value *FieldNo = llvm_constant_new_integral(LongTy, i); + llvm_value *FieldNo = llvm_constant_new_integral(IntPtrTy, i); llvm_value *DestElPtr = append_inst(Fn, create_gep3(DestPtr, - llvm_constant_long_0, FieldNo)); + llvm_constant_intptr_0, FieldNo)); llvm_value *SrcElPtr = append_inst(Fn, create_gep3(SrcPtr, - llvm_constant_long_0, FieldNo)); + llvm_constant_intptr_0, FieldNo)); llvm_copy_aggregate(Fn, DestElPtr, SrcElPtr, isSourceVolatile, isDestVolatile, 1); } @@ -2746,8 +2746,7 @@ if (BitSize == 0) return Src; /* Not a bitfield reference */ if (BitStart+BitSize != ValSize) { - Idx = llvm_constant_new_integral(UByteTy, - ValSize-(BitStart+BitSize)); + Idx = llvm_constant_new_integral(UByteTy, ValSize-(BitStart+BitSize)); Src = append_inst(Fn, create_binary_inst("tmp", O_Shl, Src, Idx)); } @@ -2880,9 +2879,9 @@ unsigned i, e; for (i = 0, e = llvm_type_get_composite_num_elements(ValTy); i != e; ++i) { llvm_value *Element = llvm_constant_new_integral(ValTy->ID == StructTyID ? - UByteTy : LongTy, i); + UIntTy : IntPtrTy, i); llvm_value *Addr = append_inst(Fn, create_gep3(ArgAddr, - llvm_constant_long_0, Element)); + llvm_constant_intptr_0, Element)); NumArgs = PassStructureByValue(Fn, Addr, Call, CalledFuncType, ArgOffset, NumArgs); } @@ -3167,10 +3166,9 @@ I = llvm_instruction_new(Op->Ty, isIncrement ? "inc" : "dec", O_GetElementPtr, 2); I->Operands[0] = Op; - I->Operands[1] = llvm_constant_new_integral(LongTy, isIncrement ? 1 : -1); + I->Operands[1] = llvm_constant_new_integral(IntPtrTy, isIncrement ? 1 : -1); IV = append_inst(Fn, I); } else { - llvm_type *IntPtrTy = llvm_type_get_size(VoidPtrTy) == 4 ? IntTy : LongTy; llvm_value *OpTmp = cast_if_type_not_equal(Fn, Op, IntPtrTy); llvm_value *Inc = llvm_expand_expr(Fn, TREE_OPERAND(exp, 1), 0); @@ -3272,7 +3270,7 @@ unsigned Depth = 0; llvm_type *CTy, *OTy; - /*return 0; // Used to disabled addsub transformation */ + /*return 0; // Used to disable the addsub transformation */ assert(DestTy->ID == PointerTyID && op0->Ty->ID == PointerTyID); @@ -3293,11 +3291,13 @@ llvm_instruction *I = llvm_instruction_new(DestTy, "tmp", O_GetElementPtr, 2); I->Operands[0] = op0; - I->Operands[1] = cast_if_type_not_equal(Fn, op1, LongTy); + I->Operands[1] = cast_if_type_not_equal(Fn, op1, IntPtrTy); if (!isAdd) { /* If this is a subtract, negate the index! */ + llvm_value *Zero = + cast_if_type_not_equal(0, llvm_constant_uint_0, IntPtrTy); I->Operands[1] = append_inst(Fn, create_binary_inst("tmp", O_Sub, - llvm_constant_long_0, I->Operands[1])); + Zero, I->Operands[1])); } return append_inst(Fn, I); @@ -3320,7 +3320,7 @@ if (!isAdd) GEPIdx *= -1; I->Operands[0] = op0; - I->Operands[1] = llvm_constant_new_integral(LongTy, GEPIdx); + I->Operands[1] = llvm_constant_new_integral(IntPtrTy, GEPIdx); return append_inst(Fn, I); } } @@ -3375,13 +3375,13 @@ 1+Depth); Depth = 0; GEP->Operands[Depth++] = op0; - GEP->Operands[Depth++] = llvm_constant_new_integral(LongTy, Value / Size); + GEP->Operands[Depth++] = llvm_constant_new_integral(IntPtrTy, Value / Size); Value %= Size; CTy = OTy; while (Value && llvm_type_is_composite(CTy)) if (CTy->ID == ArrayTyID) { unsigned ElSize = llvm_type_get_size(CTy->Elements[0]); - GEP->Operands[Depth++]=llvm_constant_new_integral(LongTy, Value/ElSize); + GEP->Operands[Depth++]=llvm_constant_new_integral(IntPtrTy, Value/ElSize); Value %= ElSize; CTy = CTy->Elements[0]; } else { @@ -3392,7 +3392,7 @@ assert(i < CTy->NumElements && CTy->x.Struct.MemberOffsets[i] <= Value); Value -= CTy->x.Struct.MemberOffsets[i]; CTy = CTy->Elements[i]; - GEP->Operands[Depth++] = llvm_constant_new_integral(UByteTy, i); + GEP->Operands[Depth++] = llvm_constant_new_integral(UIntTy, i); } /* Now that the pointer has been adjusted by the appropriate amount, convert @@ -3423,8 +3423,8 @@ --Idx; Offset -= ElTy->x.Struct.MemberOffsets[Idx]; *ResOffset += ElTy->x.Struct.MemberOffsets[Idx]; - Ptr = append_inst(Fn, create_gep3(Ptr, llvm_constant_long_0, - llvm_constant_new_integral(UByteTy,Idx))); + Ptr = append_inst(Fn, create_gep3(Ptr, llvm_constant_intptr_0, + llvm_constant_new_integral(UIntTy, Idx))); return IndexIntoCompositeToByteOffset(Fn, Ptr, Offset, ResOffset); } else if (ElTy->ID == ArrayTyID) { llvm_type *ArrEl = GET_ARRAY_TYPE_ELEMENT(ElTy); @@ -3433,8 +3433,8 @@ assert(Idx < ElTy->x.Array.Size && "Array idx out of range!"); Offset -= ElSize*Idx; *ResOffset += ElSize*Idx; - Ptr = append_inst(Fn, create_gep3(Ptr, llvm_constant_long_0, - llvm_constant_new_integral(LongTy,Idx))); + Ptr = append_inst(Fn, create_gep3(Ptr, llvm_constant_intptr_0, + llvm_constant_new_integral(IntPtrTy, Idx))); return IndexIntoCompositeToByteOffset(Fn, Ptr, Offset, ResOffset); } else { assert(0 && "Unknown composite type!"); @@ -3585,7 +3585,7 @@ */ if (llvm_type_is_composite(ElTy) && Target) { llvm_instruction *OffsetInst - = create_gep3(Target, llvm_constant_long_0, IdxExpr); + = create_gep3(Target, llvm_constant_intptr_0, IdxExpr); llvm_value *Offset = append_inst(Fn, OffsetInst); @@ -3863,7 +3863,7 @@ if (Result[i] == 0) { llvm_type *FieldType = Ty->Elements[i]; Result[i] = llvm_expand_constructor_element(Fn, target, 0, FieldType, - llvm_constant_new_integral(UByteTy, i), + llvm_constant_new_integral(UIntTy, i), isVolatile); } @@ -3996,7 +3996,7 @@ Result[FieldOffset] = llvm_expand_constructor_element(Fn, target, value, FieldType, - llvm_constant_new_integral(LongTy, FieldOffset), + llvm_constant_new_integral(IntPtrTy, FieldOffset), isVolatile); } } @@ -4008,7 +4008,7 @@ for (i = 0; i != Size; ++i) if (Result[i] == 0) Result[i] = llvm_expand_constructor_element(Fn, target, 0, FieldType, - llvm_constant_new_integral(LongTy, i), + llvm_constant_new_integral(IntPtrTy, i), isVolatile); } else @@ -4063,8 +4063,8 @@ /* Composite elements handled already */ if (!llvm_type_is_composite(Ty->Elements[i])) { /* Make a getelementptr instruction that addresses the field */ - OffsetInst = create_gep3(target, llvm_constant_long_0, - llvm_constant_new_integral(UByteTy, i)); + OffsetInst = create_gep3(target, llvm_constant_intptr_0, + llvm_constant_new_integral(UIntTy, i)); Offset = append_inst(Fn, OffsetInst); /* Add it to the program */ append_inst(Fn, create_store_inst(Elements[i], Offset, isVolatile)); } @@ -4122,8 +4122,8 @@ for (i = 0; i != Size; ++i) { /* Make a getelementptr instruction that addresses the field */ - OffsetInst = create_gep3(target, llvm_constant_long_0, - llvm_constant_new_integral(LongTy, i)); + OffsetInst = create_gep3(target, llvm_constant_intptr_0, + llvm_constant_new_integral(IntPtrTy, i)); Offset = append_inst(Fn, OffsetInst); /* Add it to the program */ append_inst(Fn, create_store_inst(Elements[i], Offset, isVolatile)); } @@ -4980,7 +4980,7 @@ if (llvm_type_is_integral(ReqTy)) return V2C(llvm_constant_new_integral(ReqTy, IntValue)); else if (ReqTy->ID == PointerTyID) { - Val = llvm_constant_new_integral(LongTy, IntValue); + Val = llvm_constant_new_integral(IntPtrTy, IntValue); return V2C(cast_if_type_not_equal(0, Val, ReqTy)); } else { char Buffer[50]; @@ -5096,8 +5096,8 @@ op1 = cast_if_type_not_equal(0, op1, op0->Ty); if (op0->Ty->ID == PointerTyID && op1->Ty->ID == PointerTyID) { - op0 = cast_if_type_not_equal(0, op0, LongTy); - op1 = cast_if_type_not_equal(0, op1, LongTy); + op0 = cast_if_type_not_equal(0, op0, IntPtrTy); + op1 = cast_if_type_not_equal(0, op1, IntPtrTy); } Inst = create_binary_inst("tmp", isPlus ? O_Add : O_Sub, op0, op1); @@ -5272,7 +5272,7 @@ llvm_value *Op0 = llvm_expand_lvalue_expr(Fn, tOp0, 0, 0); llvm_value *Op1 = llvm_expand_expr(Fn, tOp1, 0); Op1 = cast_if_type_not_equal(Fn, Op1, IntPtrTy); - Result = append_inst(Fn, create_gep3(Op0, llvm_constant_long_0, Op1)); + Result = append_inst(Fn, create_gep3(Op0, llvm_constant_intptr_0, Op1)); } else { llvm_instruction *I; /* As a "special extension" we have perverted ARRAY_REF's so that they can @@ -5348,7 +5348,7 @@ unsigned ActualSize; llvm_value *FieldNo = DECL_LLVM(FieldDecl); llvm_type *ResultElTy; - I = create_gep3(Op0, llvm_constant_long_0, FieldNo); + I = create_gep3(Op0, llvm_constant_intptr_0, FieldNo); Result = append_inst(Fn, I); ResultElTy = GET_POINTER_TYPE_ELEMENT(Result->Ty); @@ -5390,7 +5390,7 @@ llvm_instruction *GEP = llvm_instruction_new(SBPtr, "tmp", O_GetElementPtr, 2); GEP->Operands[0] = Ptr; - GEP->Operands[1] = llvm_constant_new_integral(LongTy, Offset/8); + GEP->Operands[1] = llvm_constant_new_integral(IntPtrTy, Offset/8); Ptr = append_inst(Fn, GEP); } Result = cast_if_type_not_equal(Fn, Ptr, Result->Ty); @@ -5518,8 +5518,8 @@ /* Get the address of the complex */ Result = llvm_expand_lvalue_expr(Fn, TREE_OPERAND(exp, 0), 0, 0); /* Get a pointer to the 0th or 1st element */ - Result = append_inst(Fn, create_gep3(Result, llvm_constant_long_0, - llvm_constant_new_integral(UByteTy, TREE_CODE(exp) == IMAGPART_EXPR))); + Result = append_inst(Fn, create_gep3(Result, llvm_constant_intptr_0, + llvm_constant_new_integral(UIntTy, TREE_CODE(exp) == IMAGPART_EXPR))); break; case CONSTRUCTOR: @@ -5639,12 +5639,12 @@ llvm_value *Real, llvm_value *Imag, int isVolatile) { llvm_instruction *I; - I = create_gep3(DestLoc, llvm_constant_long_0, - llvm_constant_new_integral(UByteTy, 0)); + I = create_gep3(DestLoc, llvm_constant_intptr_0, + llvm_constant_new_integral(UIntTy, 0)); append_inst(Fn, create_store_inst(Real, append_inst(Fn, I), isVolatile)); - I = create_gep3(DestLoc, llvm_constant_long_0, - llvm_constant_new_integral(UByteTy, 1)); + I = create_gep3(DestLoc, llvm_constant_intptr_0, + llvm_constant_new_integral(UIntTy, 1)); append_inst(Fn, create_store_inst(Imag, append_inst(Fn, I), isVolatile)); } @@ -5655,8 +5655,8 @@ llvm_value *Complex, int ImagPart, int isVolatile) { llvm_value *Addr = - append_inst(Fn, create_gep3(Complex, llvm_constant_long_0, - llvm_constant_new_integral(UByteTy, ImagPart))); + append_inst(Fn, create_gep3(Complex, llvm_constant_intptr_0, + llvm_constant_new_integral(UIntTy, ImagPart))); return append_inst(Fn, create_load_inst("tmp", Addr, isVolatile)); } @@ -6192,7 +6192,7 @@ case RSHIFT_EXPR: /* Shift amount -> ubyte */ op1 = cast_if_type_not_equal(Fn, op1, UByteTy); if (op0->Ty->ID == PointerTyID) - op0 = cast_if_type_not_equal(Fn, op0, LongTy); + op0 = cast_if_type_not_equal(Fn, op0, IntPtrTy); break; case NE_EXPR: @@ -6227,8 +6227,8 @@ if (Opcode < O_SetEQ && (op0->Ty->ID == PointerTyID || op1->Ty->ID == PointerTyID)) { /* Disallow pointer arithmetic. */ - op0 = cast_if_type_not_equal(Fn, op0, LongTy); - op1 = cast_if_type_not_equal(Fn, op1, LongTy); + op0 = cast_if_type_not_equal(Fn, op0, IntPtrTy); + op1 = cast_if_type_not_equal(Fn, op1, IntPtrTy); break; } @@ -6553,7 +6553,7 @@ */ unsigned i, NameLen = strlen(Name); char *SubName = (char*)xmalloc(NameLen+6); /* Should use alloca, oh well */ - llvm_type *ElIdxTy = Ty->ID == StructTyID ? UByteTy : LongTy; + llvm_type *ElIdxTy = Ty->ID == StructTyID ? UIntTy : IntPtrTy; strcpy(SubName, Name); for (i = 0; i != llvm_type_get_composite_num_elements(Ty); ++i) { llvm_type *ElTy = llvm_type_get_composite_element(Ty, i); @@ -6564,7 +6564,7 @@ if (Address) { llvm_instruction *GEP = 0; sprintf(SubName+NameLen, ".%d", i); - GEP = create_gep3(Address, llvm_constant_long_0, + GEP = create_gep3(Address, llvm_constant_intptr_0, llvm_constant_new(ElIdxTy, SubName+NameLen+1)); Offset = append_inst(Fn, GEP); /* Add the inst to the stream */ } From lattner at cs.uiuc.edu Tue Jul 6 23:20:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Jul 6 23:20:01 2004 Subject: [llvm-commits] CVS: llvm-gcc/gcc/llvm-representation.c Message-ID: <200407070419.XAA25449@apoc.cs.uiuc.edu> Changes in directory llvm-gcc/gcc: llvm-representation.c updated: 1.9 -> 1.10 --- Log message: Fix a buggy assertion, thanks to Markus for his infinite patience with me :) --- Diffs of the changes: (+3 -1) Index: llvm-gcc/gcc/llvm-representation.c diff -u llvm-gcc/gcc/llvm-representation.c:1.9 llvm-gcc/gcc/llvm-representation.c:1.10 --- llvm-gcc/gcc/llvm-representation.c:1.9 Tue Jul 6 22:19:52 2004 +++ llvm-gcc/gcc/llvm-representation.c Tue Jul 6 23:19:38 2004 @@ -594,7 +594,9 @@ llvm_instruction *create_gep3(llvm_value *Op0, llvm_value *Op1,llvm_value *Op2){ llvm_instruction *I; llvm_type *ResultTy = GET_POINTER_TYPE_ELEMENT(Op0->Ty); - assert(Op1->Ty == LongTy && "First GEP index must be long type!"); + assert((Op1->Ty == LongTy || Op1->Ty == IntTy || + Op1->Ty == ULongTy || Op1->Ty == UIntTy) && + "First GEP index must be long type!"); assert(llvm_type_is_composite(ResultTy) && "Cannot index into noncomposite!"); assert(((ResultTy->ID == ArrayTyID && (Op2->Ty == LongTy || Op2->Ty == ULongTy || From lattner at cs.uiuc.edu Tue Jul 6 23:46:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Tue Jul 6 23:46:01 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/ConstantFolding.cpp Message-ID: <200407070445.XAA26396@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: ConstantFolding.cpp updated: 1.59 -> 1.60 --- Log message: When folding constant expr gep's, don't force the use of long indices. --- Diffs of the changes: (+6 -3) Index: llvm/lib/VMCore/ConstantFolding.cpp diff -u llvm/lib/VMCore/ConstantFolding.cpp:1.59 llvm/lib/VMCore/ConstantFolding.cpp:1.60 --- llvm/lib/VMCore/ConstantFolding.cpp:1.59 Thu Jun 17 13:18:53 2004 +++ llvm/lib/VMCore/ConstantFolding.cpp Tue Jul 6 23:45:13 2004 @@ -993,11 +993,14 @@ // Add the last index of the source with the first index of the new GEP. // Make sure to handle the case when they are actually different types. Constant *Combined = CE->getOperand(CE->getNumOperands()-1); - if (!IdxList[0]->isNullValue()) // Otherwise it must be an array + if (!IdxList[0]->isNullValue()) { // Otherwise it must be an array + const Type *IdxTy = Combined->getType(); + if (IdxTy != IdxList[0]->getType()) IdxTy = Type::LongTy; Combined = ConstantExpr::get(Instruction::Add, - ConstantExpr::getCast(IdxList[0], Type::LongTy), - ConstantExpr::getCast(Combined, Type::LongTy)); + ConstantExpr::getCast(IdxList[0], IdxTy), + ConstantExpr::getCast(Combined, IdxTy)); + } NewIndices.push_back(Combined); NewIndices.insert(NewIndices.end(), IdxList.begin()+1, IdxList.end()); From lattner at cs.uiuc.edu Wed Jul 7 00:26:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Jul 7 00:26:01 2004 Subject: [llvm-commits] CVS: poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp Message-ID: <200407070525.AAA25301@apoc.cs.uiuc.edu> Changes in directory poolalloc/lib/PoolAllocate: TransformFunctionBody.cpp updated: 1.24 -> 1.25 --- Log message: Fix compilation --- Diffs of the changes: (+1 -0) Index: poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp diff -u poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.24 poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.25 --- poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.24 Sun May 23 02:56:48 2004 +++ poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp Wed Jul 7 00:25:29 2004 @@ -17,6 +17,7 @@ #include "llvm/Support/InstVisitor.h" #include "Support/Debug.h" #include "Support/VectorExtras.h" +#include using namespace llvm; using namespace PA; From lattner at cs.uiuc.edu Wed Jul 7 00:55:05 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Jul 7 00:55:05 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DataStructure/ Message-ID: <200407070553.AAA26554@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis/DataStructure: --- Log message: Directory /home/vadve/shared/PublicCVS/llvm/include/llvm/Analysis/DataStructure added to the repository --- Diffs of the changes: (+0 -0) From lattner at cs.uiuc.edu Wed Jul 7 01:13:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Jul 7 01:13:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DSNode.h DSSupport.h Message-ID: <200407070612.BAA01395@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: DSNode.h updated: 1.42 -> 1.43 DSSupport.h updated: 1.31 -> 1.32 --- Log message: As much as I hate to say it, the whole setNode interface for DSNodeHandles is HOPELESSLY broken. The problem is that the embedded getNode call can change the offset of the node handle in unpredictable ways. As it turns out, all of the clients of this method really want to set both the node and the offset, thus it is more efficient (and less buggy) to just do both of them in one method call. This fixes some obscure bugs handling non-forwarded node handles. --- Diffs of the changes: (+18 -17) Index: llvm/include/llvm/Analysis/DSNode.h diff -u llvm/include/llvm/Analysis/DSNode.h:1.42 llvm/include/llvm/Analysis/DSNode.h:1.43 --- llvm/include/llvm/Analysis/DSNode.h:1.42 Sun May 23 02:34:53 2004 +++ llvm/include/llvm/Analysis/DSNode.h Wed Jul 7 01:12:36 2004 @@ -175,7 +175,7 @@ void stopForwarding() { assert(isForwarding() && "Node isn't forwarding, cannot stopForwarding()!"); - ForwardNH.setNode(0); + ForwardNH.setTo(0, 0); assert(ParentGraph == 0 && "Forwarding nodes must have been removed from graph!"); delete this; @@ -336,7 +336,7 @@ void dropAllReferences() { Links.clear(); if (isForwarding()) - ForwardNH.setNode(0); + ForwardNH.setTo(0, 0); } /// remapLinks - Change all of the Links in the current node according to the @@ -401,10 +401,11 @@ return HandleForwarding(); } -inline void DSNodeHandle::setNode(DSNode *n) const { +inline void DSNodeHandle::setTo(DSNode *n, unsigned NewOffset) const { assert(!n || !n->isForwarding() && "Cannot set node to a forwarded node!"); if (N) getNode()->NumReferrers--; N = n; + Offset = NewOffset; if (N) { N->NumReferrers++; if (Offset >= N->Size) { @@ -457,8 +458,8 @@ getNode()->mergeWith(Node, Offset); else { // No node to merge with, so just point to Node Offset = 0; - setNode(Node.getNode()); - Offset = Node.getOffset(); + DSNode *NN = Node.getNode(); + setTo(NN, Node.getOffset()); } } Index: llvm/include/llvm/Analysis/DSSupport.h diff -u llvm/include/llvm/Analysis/DSSupport.h:1.31 llvm/include/llvm/Analysis/DSSupport.h:1.32 --- llvm/include/llvm/Analysis/DSSupport.h:1.31 Thu Mar 11 17:08:20 2004 +++ llvm/include/llvm/Analysis/DSSupport.h Wed Jul 7 01:12:36 2004 @@ -58,17 +58,18 @@ void operator==(const DSNode *N); // DISALLOW, use to promote N to nodehandle public: // Allow construction, destruction, and assignment... - DSNodeHandle(DSNode *n = 0, unsigned offs = 0) : N(0), Offset(offs) { - setNode(n); + DSNodeHandle(DSNode *n = 0, unsigned offs = 0) : N(0), Offset(0) { + setTo(n, offs); } DSNodeHandle(const DSNodeHandle &H) : N(0), Offset(0) { - setNode(H.getNode()); - Offset = H.Offset; // Must read offset AFTER the getNode() + DSNode *NN = H.getNode(); + setTo(NN, H.Offset); // Must read offset AFTER the getNode() } - ~DSNodeHandle() { setNode((DSNode*)0); } + ~DSNodeHandle() { setTo(0, 0); } DSNodeHandle &operator=(const DSNodeHandle &H) { if (&H == this) return *this; // Don't set offset to 0 if self assigning. - Offset = 0; setNode(H.getNode()); Offset = H.Offset; + DSNode *NN = H.getNode(); // Call getNode() before .Offset + setTo(NN, H.Offset); return *this; } @@ -96,7 +97,6 @@ inline DSNode *getNode() const; // Defined inline in DSNode.h unsigned getOffset() const { return Offset; } - inline void setNode(DSNode *N) const; // Defined inline in DSNode.h void setOffset(unsigned O) { //assert((!N || Offset < N->Size || (N->Size == 0 && Offset == 0) || // !N->ForwardNH.isNull()) && "Node handle offset out of range!"); @@ -105,6 +105,8 @@ Offset = O; } + inline void setTo(DSNode *N, unsigned O) const; // Defined inline in DSNode.h + void addEdgeTo(unsigned LinkNo, const DSNodeHandle &N); void addEdgeTo(const DSNodeHandle &N) { addEdgeTo(0, N); } @@ -154,9 +156,7 @@ if (DSNode *N = Src.getNode()) { hash_map::const_iterator I = NodeMap.find(N); assert(I != NodeMap.end() && "Node not in mapping!"); - - NH.setOffset(Src.getOffset()); - NH.setNode(I->second); + NH.setTo(I->second, Src.getOffset()); } } @@ -166,8 +166,8 @@ hash_map::const_iterator I = NodeMap.find(N); assert(I != NodeMap.end() && "Node not in mapping!"); - NH.setOffset(Src.getOffset()+I->second.getOffset()); - NH.setNode(I->second.getNode()); + DSNode *NN = I->second.getNode(); // Call getNode before getOffset() + NH.setTo(NN, Src.getOffset()+I->second.getOffset()); } } From lattner at cs.uiuc.edu Wed Jul 7 01:14:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Jul 7 01:14:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/DataStructure.cpp Local.cpp Message-ID: <200407070613.BAA01461@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: DataStructure.cpp updated: 1.175 -> 1.176 Local.cpp updated: 1.105 -> 1.106 --- Log message: As much as I hate to say it, the whole setNode interface for DSNodeHandles is HOPELESSLY broken. The problem is that the embedded getNode call can change the offset of the node handle in unpredictable ways. As it turns out, all of the clients of this method really want to set both the node and the offset, thus it is more efficient (and less buggy) to just do both of them in one method call. This fixes some obscure bugs handling non-forwarded node handles. --- Diffs of the changes: (+7 -11) Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.175 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.176 --- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.175 Wed Jun 23 01:29:59 2004 +++ llvm/lib/Analysis/DataStructure/DataStructure.cpp Wed Jul 7 01:12:51 2004 @@ -120,8 +120,7 @@ if (To->Size <= 1) Offset = 0; assert((Offset < To->Size || (Offset == To->Size && Offset == 0)) && "Forwarded offset is wrong!"); - ForwardNH.setNode(To); - ForwardNH.setOffset(Offset); + ForwardNH.setTo(To, Offset); NodeType = DEAD; Size = 0; Ty = Type::VoidTy; @@ -1096,10 +1095,9 @@ for (unsigned i = 0, e = Links.size(); i != e; ++i) if (DSNode *N = Links[i].getNode()) { DSGraph::NodeMapTy::const_iterator ONMI = OldNodeMap.find(N); - if (ONMI != OldNodeMap.end()) { - Links[i].setNode(ONMI->second.getNode()); - Links[i].setOffset(Links[i].getOffset()+ONMI->second.getOffset()); - } + if (ONMI != OldNodeMap.end()) + Links[i].setTo(ONMI->second.getNode(), + Links[i].getOffset()+ONMI->second.getOffset()); } } @@ -1475,7 +1473,7 @@ // No interesting info? if ((N->getNodeFlags() & ~DSNode::Incomplete) == 0 && N->getType() == Type::VoidTy && !N->isNodeCompletelyFolded()) - Edge.setNode(0); // Kill the edge! + Edge.setTo(0, 0); // Kill the edge! } static inline bool nodeContainsExternalFunction(const DSNode *N) { @@ -1979,8 +1977,7 @@ return; } - Entry.setNode(N2); - Entry.setOffset(NH2.getOffset()-NH1.getOffset()); + Entry.setTo(N2, NH2.getOffset()-NH1.getOffset()); // Loop over all of the fields that N1 and N2 have in common, recursively // mapping the edges together now. Index: llvm/lib/Analysis/DataStructure/Local.cpp diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.105 llvm/lib/Analysis/DataStructure/Local.cpp:1.106 --- llvm/lib/Analysis/DataStructure/Local.cpp:1.105 Sun Jul 4 07:19:55 2004 +++ llvm/lib/Analysis/DataStructure/Local.cpp Wed Jul 7 01:12:52 2004 @@ -259,8 +259,7 @@ N = createNode(); } - NH.setNode(N); // Remember that we are pointing to it... - NH.setOffset(0); + NH.setTo(N, 0); // Remember that we are pointing to it... return NH; } From lattner at cs.uiuc.edu Wed Jul 7 01:24:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Jul 7 01:24:02 2004 Subject: [llvm-commits] CVS: poolalloc/lib/PoolAllocate/EquivClassGraphs.cpp PoolAllocate.cpp TransformFunctionBody.cpp Message-ID: <200407070623.BAA05719@apoc.cs.uiuc.edu> Changes in directory poolalloc/lib/PoolAllocate: EquivClassGraphs.cpp updated: 1.1 -> 1.2 PoolAllocate.cpp updated: 1.69 -> 1.70 TransformFunctionBody.cpp updated: 1.25 -> 1.26 --- Log message: Moving headers --- Diffs of the changes: (+7 -7) Index: poolalloc/lib/PoolAllocate/EquivClassGraphs.cpp diff -u poolalloc/lib/PoolAllocate/EquivClassGraphs.cpp:1.1 poolalloc/lib/PoolAllocate/EquivClassGraphs.cpp:1.2 --- poolalloc/lib/PoolAllocate/EquivClassGraphs.cpp:1.1 Sun May 23 02:54:02 2004 +++ poolalloc/lib/PoolAllocate/EquivClassGraphs.cpp Wed Jul 7 01:22:54 2004 @@ -16,10 +16,10 @@ #define DEBUG_TYPE "ECGraphs" #include "EquivClassGraphs.h" -#include "llvm/Analysis/DataStructure.h" #include "llvm/Module.h" #include "llvm/Pass.h" -#include "llvm/Analysis/DSGraph.h" +#include "llvm/Analysis/DataStructure/DSGraph.h" +#include "llvm/Analysis/DataStructure/DataStructure.h" #include "llvm/Support/CallSite.h" #include "Support/Debug.h" #include "Support/SCCIterator.h" Index: poolalloc/lib/PoolAllocate/PoolAllocate.cpp diff -u poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.69 poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.70 --- poolalloc/lib/PoolAllocate/PoolAllocate.cpp:1.69 Sun May 23 02:55:12 2004 +++ poolalloc/lib/PoolAllocate/PoolAllocate.cpp Wed Jul 7 01:22:54 2004 @@ -13,9 +13,9 @@ #include "llvm/Instructions.h" #include "llvm/Module.h" #include "llvm/Constants.h" -#include "llvm/Analysis/DataStructure.h" -#include "llvm/Analysis/DSGraph.h" -#include "llvm/Analysis/DSGraphTraits.h" +#include "llvm/Analysis/DataStructure/DataStructure.h" +#include "llvm/Analysis/DataStructure/DSGraph.h" +#include "llvm/Analysis/DataStructure/DSGraphTraits.h" #include "llvm/Support/CFG.h" #include "llvm/Target/TargetData.h" #include "llvm/Transforms/Utils/BasicBlockUtils.h" Index: poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp diff -u poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.25 poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.26 --- poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp:1.25 Wed Jul 7 00:25:29 2004 +++ poolalloc/lib/PoolAllocate/TransformFunctionBody.cpp Wed Jul 7 01:22:54 2004 @@ -7,8 +7,8 @@ #define DEBUG_TYPE "PoolAllocator" #include "EquivClassGraphs.h" #include "poolalloc/PoolAllocate.h" -#include "llvm/Analysis/DataStructure.h" -#include "llvm/Analysis/DSGraph.h" +#include "llvm/Analysis/DataStructure//DataStructure.h" +#include "llvm/Analysis/DataStructure/DSGraph.h" #include "llvm/Module.h" #include "llvm/DerivedTypes.h" #include "llvm/Constants.h" From lattner at cs.uiuc.edu Wed Jul 7 01:30:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Jul 7 01:30:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DataStructure/DSGraph.h DSGraphTraits.h DSNode.h Message-ID: <200407070629.BAA08368@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis/DataStructure: DSGraph.h updated: 1.80 -> 1.81 DSGraphTraits.h updated: 1.20 -> 1.21 DSNode.h updated: 1.43 -> 1.44 --- Log message: Move DSA headers into Analysis/DataStructure to make it more obvious what is implemented by the DataStructure library. --- Diffs of the changes: (+3 -3) Index: llvm/include/llvm/Analysis/DataStructure/DSGraph.h diff -u llvm/include/llvm/Analysis/DataStructure/DSGraph.h:1.80 llvm/include/llvm/Analysis/DataStructure/DSGraph.h:1.81 --- llvm/include/llvm/Analysis/DataStructure/DSGraph.h:1.80 Thu Mar 11 17:08:20 2004 +++ llvm/include/llvm/Analysis/DataStructure/DSGraph.h Wed Jul 7 01:29:26 2004 @@ -15,7 +15,7 @@ #ifndef LLVM_ANALYSIS_DSGRAPH_H #define LLVM_ANALYSIS_DSGRAPH_H -#include "llvm/Analysis/DSNode.h" +#include "llvm/Analysis/DataStructure/DSNode.h" namespace llvm { Index: llvm/include/llvm/Analysis/DataStructure/DSGraphTraits.h diff -u llvm/include/llvm/Analysis/DataStructure/DSGraphTraits.h:1.20 llvm/include/llvm/Analysis/DataStructure/DSGraphTraits.h:1.21 --- llvm/include/llvm/Analysis/DataStructure/DSGraphTraits.h:1.20 Sun Feb 29 19:42:26 2004 +++ llvm/include/llvm/Analysis/DataStructure/DSGraphTraits.h Wed Jul 7 01:29:26 2004 @@ -16,7 +16,7 @@ #ifndef LLVM_ANALYSIS_DSGRAPHTRAITS_H #define LLVM_ANALYSIS_DSGRAPHTRAITS_H -#include "llvm/Analysis/DSGraph.h" +#include "llvm/Analysis/DataStructure/DSGraph.h" #include "Support/GraphTraits.h" #include "Support/iterator" #include "Support/STLExtras.h" Index: llvm/include/llvm/Analysis/DataStructure/DSNode.h diff -u llvm/include/llvm/Analysis/DataStructure/DSNode.h:1.43 llvm/include/llvm/Analysis/DataStructure/DSNode.h:1.44 --- llvm/include/llvm/Analysis/DataStructure/DSNode.h:1.43 Wed Jul 7 01:12:36 2004 +++ llvm/include/llvm/Analysis/DataStructure/DSNode.h Wed Jul 7 01:29:26 2004 @@ -14,7 +14,7 @@ #ifndef LLVM_ANALYSIS_DSNODE_H #define LLVM_ANALYSIS_DSNODE_H -#include "llvm/Analysis/DSSupport.h" +#include "llvm/Analysis/DataStructure/DSSupport.h" namespace llvm { From lattner at cs.uiuc.edu Wed Jul 7 01:33:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Jul 7 01:33:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp DSCallSiteIterator.h DataStructure.cpp DataStructureAA.cpp DataStructureOpt.cpp DataStructureStats.cpp GraphChecker.cpp IPModRef.cpp Local.cpp MemoryDepAnalysis.cpp Parallelize.cpp Printer.cpp Steensgaard.cpp TopDownClosure.cpp Message-ID: <200407070632.BAA10387@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: CompleteBottomUp.cpp updated: 1.11 -> 1.12 DSCallSiteIterator.h updated: 1.8 -> 1.9 DataStructure.cpp updated: 1.176 -> 1.177 DataStructureAA.cpp updated: 1.18 -> 1.19 DataStructureOpt.cpp updated: 1.5 -> 1.6 DataStructureStats.cpp updated: 1.10 -> 1.11 GraphChecker.cpp updated: 1.13 -> 1.14 IPModRef.cpp updated: 1.22 -> 1.23 Local.cpp updated: 1.106 -> 1.107 MemoryDepAnalysis.cpp updated: 1.15 -> 1.16 Parallelize.cpp updated: 1.15 -> 1.16 Printer.cpp updated: 1.69 -> 1.70 Steensgaard.cpp updated: 1.39 -> 1.40 TopDownClosure.cpp updated: 1.67 -> 1.68 --- Log message: Move all of the DSA headers into the Analysis/DataStructure subdir. --- Diffs of the changes: (+31 -29) Index: llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp diff -u llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp:1.11 llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp:1.12 --- llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp:1.11 Sun May 23 03:00:34 2004 +++ llvm/lib/Analysis/DataStructure/CompleteBottomUp.cpp Wed Jul 7 01:32:21 2004 @@ -13,9 +13,9 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Analysis/DataStructure.h" +#include "llvm/Analysis/DataStructure/DataStructure.h" #include "llvm/Module.h" -#include "llvm/Analysis/DSGraph.h" +#include "llvm/Analysis/DataStructure/DSGraph.h" #include "Support/Debug.h" #include "Support/SCCIterator.h" #include "Support/Statistic.h" Index: llvm/lib/Analysis/DataStructure/DSCallSiteIterator.h diff -u llvm/lib/Analysis/DataStructure/DSCallSiteIterator.h:1.8 llvm/lib/Analysis/DataStructure/DSCallSiteIterator.h:1.9 --- llvm/lib/Analysis/DataStructure/DSCallSiteIterator.h:1.8 Tue Nov 11 16:41:32 2003 +++ llvm/lib/Analysis/DataStructure/DSCallSiteIterator.h Wed Jul 7 01:32:21 2004 @@ -16,7 +16,7 @@ #ifndef DSCALLSITEITERATOR_H #define DSCALLSITEITERATOR_H -#include "llvm/Analysis/DSGraph.h" +#include "llvm/Analysis/DataStructure/DSGraph.h" #include "llvm/Function.h" namespace llvm { Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.176 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.177 --- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.176 Wed Jul 7 01:12:51 2004 +++ llvm/lib/Analysis/DataStructure/DataStructure.cpp Wed Jul 7 01:32:21 2004 @@ -11,7 +11,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Analysis/DSGraphTraits.h" +#include "llvm/Analysis/DataStructure/DSGraphTraits.h" #include "llvm/Function.h" #include "llvm/GlobalVariable.h" #include "llvm/iOther.h" Index: llvm/lib/Analysis/DataStructure/DataStructureAA.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructureAA.cpp:1.18 llvm/lib/Analysis/DataStructure/DataStructureAA.cpp:1.19 --- llvm/lib/Analysis/DataStructure/DataStructureAA.cpp:1.18 Sun May 23 16:14:27 2004 +++ llvm/lib/Analysis/DataStructure/DataStructureAA.cpp Wed Jul 7 01:32:21 2004 @@ -14,8 +14,8 @@ #include "llvm/Module.h" #include "llvm/Analysis/AliasAnalysis.h" -#include "llvm/Analysis/DataStructure.h" -#include "llvm/Analysis/DSGraph.h" +#include "llvm/Analysis/DataStructure/DataStructure.h" +#include "llvm/Analysis/DataStructure/DSGraph.h" using namespace llvm; namespace { Index: llvm/lib/Analysis/DataStructure/DataStructureOpt.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructureOpt.cpp:1.5 llvm/lib/Analysis/DataStructure/DataStructureOpt.cpp:1.6 --- llvm/lib/Analysis/DataStructure/DataStructureOpt.cpp:1.5 Wed Nov 12 17:11:14 2003 +++ llvm/lib/Analysis/DataStructure/DataStructureOpt.cpp Wed Jul 7 01:32:21 2004 @@ -12,8 +12,8 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Analysis/DataStructure.h" -#include "llvm/Analysis/DSGraph.h" +#include "llvm/Analysis/DataStructure/DataStructure.h" +#include "llvm/Analysis/DataStructure/DSGraph.h" #include "llvm/Module.h" #include "llvm/Constant.h" #include "Support/Statistic.h" Index: llvm/lib/Analysis/DataStructure/DataStructureStats.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructureStats.cpp:1.10 llvm/lib/Analysis/DataStructure/DataStructureStats.cpp:1.11 --- llvm/lib/Analysis/DataStructure/DataStructureStats.cpp:1.10 Wed Nov 12 17:11:14 2003 +++ llvm/lib/Analysis/DataStructure/DataStructureStats.cpp Wed Jul 7 01:32:21 2004 @@ -1,4 +1,4 @@ -//===- DSGraphStats.cpp - Various statistics for DS Graphs ----------------===// +//===- DataStructureStats.cpp - Various statistics for DS Graphs ----------===// // // The LLVM Compiler Infrastructure // @@ -7,10 +7,12 @@ // //===----------------------------------------------------------------------===// // +// This file defines a little pass that prints out statistics for DS Graphs. +// //===----------------------------------------------------------------------===// -#include "llvm/Analysis/DataStructure.h" -#include "llvm/Analysis/DSGraph.h" +#include "llvm/Analysis/DataStructure/DataStructure.h" +#include "llvm/Analysis/DataStructure/DSGraph.h" #include "llvm/Function.h" #include "llvm/iOther.h" #include "llvm/iMemory.h" Index: llvm/lib/Analysis/DataStructure/GraphChecker.cpp diff -u llvm/lib/Analysis/DataStructure/GraphChecker.cpp:1.13 llvm/lib/Analysis/DataStructure/GraphChecker.cpp:1.14 --- llvm/lib/Analysis/DataStructure/GraphChecker.cpp:1.13 Sun Jul 4 07:19:55 2004 +++ llvm/lib/Analysis/DataStructure/GraphChecker.cpp Wed Jul 7 01:32:21 2004 @@ -23,8 +23,8 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Analysis/DataStructure.h" -#include "llvm/Analysis/DSGraph.h" +#include "llvm/Analysis/DataStructure/DataStructure.h" +#include "llvm/Analysis/DataStructure/DSGraph.h" #include "Support/CommandLine.h" #include "llvm/Value.h" #include Index: llvm/lib/Analysis/DataStructure/IPModRef.cpp diff -u llvm/lib/Analysis/DataStructure/IPModRef.cpp:1.22 llvm/lib/Analysis/DataStructure/IPModRef.cpp:1.23 --- llvm/lib/Analysis/DataStructure/IPModRef.cpp:1.22 Sun Jun 27 19:41:23 2004 +++ llvm/lib/Analysis/DataStructure/IPModRef.cpp Wed Jul 7 01:32:21 2004 @@ -7,13 +7,13 @@ // //===----------------------------------------------------------------------===// // -// See high-level comments in include/llvm/Analysis/IPModRef.h +// See high-level comments in IPModRef.h // //===----------------------------------------------------------------------===// #include "IPModRef.h" -#include "llvm/Analysis/DataStructure.h" -#include "llvm/Analysis/DSGraph.h" +#include "llvm/Analysis/DataStructure/DataStructure.h" +#include "llvm/Analysis/DataStructure/DSGraph.h" #include "llvm/Module.h" #include "llvm/Function.h" #include "llvm/iMemory.h" Index: llvm/lib/Analysis/DataStructure/Local.cpp diff -u llvm/lib/Analysis/DataStructure/Local.cpp:1.106 llvm/lib/Analysis/DataStructure/Local.cpp:1.107 --- llvm/lib/Analysis/DataStructure/Local.cpp:1.106 Wed Jul 7 01:12:52 2004 +++ llvm/lib/Analysis/DataStructure/Local.cpp Wed Jul 7 01:32:21 2004 @@ -12,8 +12,8 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Analysis/DataStructure.h" -#include "llvm/Analysis/DSGraph.h" +#include "llvm/Analysis/DataStructure/DataStructure.h" +#include "llvm/Analysis/DataStructure/DSGraph.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Instructions.h" Index: llvm/lib/Analysis/DataStructure/MemoryDepAnalysis.cpp diff -u llvm/lib/Analysis/DataStructure/MemoryDepAnalysis.cpp:1.15 llvm/lib/Analysis/DataStructure/MemoryDepAnalysis.cpp:1.16 --- llvm/lib/Analysis/DataStructure/MemoryDepAnalysis.cpp:1.15 Sun Jun 27 19:41:23 2004 +++ llvm/lib/Analysis/DataStructure/MemoryDepAnalysis.cpp Wed Jul 7 01:32:21 2004 @@ -22,8 +22,8 @@ #include "llvm/iMemory.h" #include "llvm/iOther.h" #include "IPModRef.h" -#include "llvm/Analysis/DataStructure.h" -#include "llvm/Analysis/DSGraph.h" +#include "llvm/Analysis/DataStructure/DataStructure.h" +#include "llvm/Analysis/DataStructure/DSGraph.h" #include "llvm/Support/InstVisitor.h" #include "llvm/Support/CFG.h" #include "Support/SCCIterator.h" Index: llvm/lib/Analysis/DataStructure/Parallelize.cpp diff -u llvm/lib/Analysis/DataStructure/Parallelize.cpp:1.15 llvm/lib/Analysis/DataStructure/Parallelize.cpp:1.16 --- llvm/lib/Analysis/DataStructure/Parallelize.cpp:1.15 Sun Jun 27 19:20:04 2004 +++ llvm/lib/Analysis/DataStructure/Parallelize.cpp Wed Jul 7 01:32:21 2004 @@ -42,8 +42,8 @@ #include "llvm/Instructions.h" #include "llvm/Module.h" #include "PgmDependenceGraph.h" -#include "llvm/Analysis/DataStructure.h" -#include "llvm/Analysis/DSGraph.h" +#include "llvm/Analysis/DataStructure/DataStructure.h" +#include "llvm/Analysis/DataStructure/DSGraph.h" #include "llvm/Support/InstVisitor.h" #include "llvm/Transforms/Utils/Local.h" #include "Support/Statistic.h" Index: llvm/lib/Analysis/DataStructure/Printer.cpp diff -u llvm/lib/Analysis/DataStructure/Printer.cpp:1.69 llvm/lib/Analysis/DataStructure/Printer.cpp:1.70 --- llvm/lib/Analysis/DataStructure/Printer.cpp:1.69 Tue Jun 22 02:13:10 2004 +++ llvm/lib/Analysis/DataStructure/Printer.cpp Wed Jul 7 01:32:21 2004 @@ -11,9 +11,9 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Analysis/DataStructure.h" -#include "llvm/Analysis/DSGraph.h" -#include "llvm/Analysis/DSGraphTraits.h" +#include "llvm/Analysis/DataStructure/DataStructure.h" +#include "llvm/Analysis/DataStructure/DSGraph.h" +#include "llvm/Analysis/DataStructure/DSGraphTraits.h" #include "llvm/Module.h" #include "llvm/Constants.h" #include "llvm/Assembly/Writer.h" Index: llvm/lib/Analysis/DataStructure/Steensgaard.cpp diff -u llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.39 llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.40 --- llvm/lib/Analysis/DataStructure/Steensgaard.cpp:1.39 Sun Jul 4 07:19:55 2004 +++ llvm/lib/Analysis/DataStructure/Steensgaard.cpp Wed Jul 7 01:32:21 2004 @@ -14,8 +14,8 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Analysis/DataStructure.h" -#include "llvm/Analysis/DSGraph.h" +#include "llvm/Analysis/DataStructure/DataStructure.h" +#include "llvm/Analysis/DataStructure/DSGraph.h" #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Module.h" #include "Support/Debug.h" Index: llvm/lib/Analysis/DataStructure/TopDownClosure.cpp diff -u llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.67 llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.68 --- llvm/lib/Analysis/DataStructure/TopDownClosure.cpp:1.67 Wed Apr 28 23:05:30 2004 +++ llvm/lib/Analysis/DataStructure/TopDownClosure.cpp Wed Jul 7 01:32:21 2004 @@ -14,10 +14,10 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Analysis/DataStructure.h" +#include "llvm/Analysis/DataStructure/DataStructure.h" #include "llvm/Module.h" #include "llvm/DerivedTypes.h" -#include "llvm/Analysis/DSGraph.h" +#include "llvm/Analysis/DataStructure/DSGraph.h" #include "Support/Debug.h" #include "Support/Statistic.h" using namespace llvm; From lattner at cs.uiuc.edu Wed Jul 7 01:34:07 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Jul 7 01:34:07 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Analysis/DSGraph.h DSGraphTraits.h DSNode.h DSSupport.h DataStructure.h Message-ID: <200407070633.BAA10851@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Analysis: DSGraph.h (r1.80) removed DSGraphTraits.h (r1.20) removed DSNode.h (r1.43) removed DSSupport.h (r1.32) removed DataStructure.h (r1.78) removed --- Log message: All of these now live in the DataStructure directory --- Diffs of the changes: (+0 -0) From lattner at cs.uiuc.edu Wed Jul 7 01:35:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Jul 7 01:35:01 2004 Subject: [llvm-commits] CVS: poolalloc/lib/PoolAllocate/EquivClassGraphs.h Message-ID: <200407070634.BAA11607@apoc.cs.uiuc.edu> Changes in directory poolalloc/lib/PoolAllocate: EquivClassGraphs.h updated: 1.1 -> 1.2 --- Log message: Headers moved --- Diffs of the changes: (+2 -2) Index: poolalloc/lib/PoolAllocate/EquivClassGraphs.h diff -u poolalloc/lib/PoolAllocate/EquivClassGraphs.h:1.1 poolalloc/lib/PoolAllocate/EquivClassGraphs.h:1.2 --- poolalloc/lib/PoolAllocate/EquivClassGraphs.h:1.1 Sun May 23 02:54:02 2004 +++ poolalloc/lib/PoolAllocate/EquivClassGraphs.h Wed Jul 7 01:34:28 2004 @@ -15,8 +15,8 @@ //===----------------------------------------------------------------------===// -#include "llvm/Analysis/DataStructure.h" -#include "llvm/Analysis/DSGraph.h" +#include "llvm/Analysis/DataStructure/DataStructure.h" +#include "llvm/Analysis/DataStructure/DSGraph.h" #include "Support/EquivalenceClasses.h" #include "Support/STLExtras.h" #include From lattner at cs.uiuc.edu Wed Jul 7 01:36:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Jul 7 01:36:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Message-ID: <200407070635.BAA11929@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: BottomUpClosure.cpp updated: 1.79 -> 1.80 --- Log message: Headers moved --- Diffs of the changes: (+1 -1) Index: llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp diff -u llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.79 llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.80 --- llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp:1.79 Thu Mar 4 11:05:28 2004 +++ llvm/lib/Analysis/DataStructure/BottomUpClosure.cpp Wed Jul 7 01:35:22 2004 @@ -14,7 +14,7 @@ // //===----------------------------------------------------------------------===// -#include "llvm/Analysis/DataStructure.h" +#include "llvm/Analysis/DataStructure/DataStructure.h" #include "llvm/Module.h" #include "Support/Statistic.h" #include "Support/Debug.h" From gaeke at cs.uiuc.edu Wed Jul 7 01:38:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Jul 7 01:38:01 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceToFunction/TraceToFunction.cpp Message-ID: <200407070637.BAA10446@kain.cs.uiuc.edu> Changes in directory reopt/lib/TraceToFunction: TraceToFunction.cpp updated: 1.69 -> 1.70 --- Log message: Get rid of the std::set version of AlternateEntryPoints, leaving only the vector version. --- Diffs of the changes: (+5 -8) Index: reopt/lib/TraceToFunction/TraceToFunction.cpp diff -u reopt/lib/TraceToFunction/TraceToFunction.cpp:1.69 reopt/lib/TraceToFunction/TraceToFunction.cpp:1.70 --- reopt/lib/TraceToFunction/TraceToFunction.cpp:1.69 Tue Jul 6 21:19:51 2004 +++ reopt/lib/TraceToFunction/TraceToFunction.cpp Wed Jul 7 01:37:14 2004 @@ -51,7 +51,6 @@ class TraceFunctionBuilder { BranchNumberMap BranchNumber; TraceFunction *TF; - std::set AlternateEntryPoints; std::vector AlternateEntryPointsV; void getTraceLiveInSet (LiveVariableSet &S, LiveVariableVector &LVV, Trace &T); @@ -178,11 +177,6 @@ if (std::find (Vector.begin (), Vector.end (), V) == Vector.end ()) Vector.push_back (V); } -static void insert (std::set &Set, std::vector &Vector, BasicBlock *V){ - Set.insert (V); - if (std::find (Vector.begin (), Vector.end (), V) == Vector.end ()) - Vector.push_back (V); -} /// addTraceLiveInsToSet - helper fn. for getTraceLiveInSet and /// getTraceLiveOutSet. Adds the live-ins of T to S, assuming that @@ -255,7 +249,7 @@ // If there are alternate entry points into the trace, their live-INs are // live-OUT from the main trace. - if (!AlternateEntryPoints.empty ()) { + if (!AlternateEntryPointsV.empty ()) { for (std::vector::iterator i = AlternateEntryPointsV.begin (), e = AlternateEntryPointsV.end (); i != e; ++i) { // Find the position of the block in the trace. @@ -584,7 +578,10 @@ if (T.contains (edge.second) && edge.second != T.getEntryBasicBlock ()) { DEBUG (std::cerr << "buildFLIMap: " << edge.second->getName() << " is a back-edge target that's internal to the trace\n"); - insert (AlternateEntryPoints, AlternateEntryPointsV, edge.second); + if (std::find (AlternateEntryPointsV.begin (), + AlternateEntryPointsV.end (), edge.second) + == AlternateEntryPointsV.end ()) + AlternateEntryPointsV.push_back (edge.second); } // 1. remove the block from the trace if it is in there BasicBlock *bb = i; From gaeke at cs.uiuc.edu Wed Jul 7 01:48:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Jul 7 01:48:02 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceToFunction/TraceToFunction.cpp Message-ID: <200407070647.BAA15717@kain.cs.uiuc.edu> Changes in directory reopt/lib/TraceToFunction: TraceToFunction.cpp updated: 1.70 -> 1.71 --- Log message: Make the LiveIn and LiveOut std::sets private to the TraceFunctionBuilder. --- Diffs of the changes: (+8 -4) Index: reopt/lib/TraceToFunction/TraceToFunction.cpp diff -u reopt/lib/TraceToFunction/TraceToFunction.cpp:1.70 reopt/lib/TraceToFunction/TraceToFunction.cpp:1.71 --- reopt/lib/TraceToFunction/TraceToFunction.cpp:1.70 Wed Jul 7 01:37:14 2004 +++ reopt/lib/TraceToFunction/TraceToFunction.cpp Wed Jul 7 01:47:15 2004 @@ -52,6 +52,10 @@ BranchNumberMap BranchNumber; TraceFunction *TF; std::vector AlternateEntryPointsV; + + LiveVariableSet LiveInSet; + LiveVariableSet LiveOutSet; + void getTraceLiveInSet (LiveVariableSet &S, LiveVariableVector &LVV, Trace &T); void getTraceLiveOutSet (LiveVariableSet &S, LiveVariableVector &LVV, @@ -219,7 +223,7 @@ } } -/// getTraceLiveInSet - Initialize TF->LiveInSet with the live-in set of the +/// getTraceLiveInSet - Initialize LiveInSet with the live-in set of the /// trace. Any variable which is used in the trace is potentially live-in, /// EXCEPT if it's a constant or a global, OR it is defined before being used /// in the trace. @@ -653,7 +657,7 @@ // their value from the argument which carries the live-in value. for (BasicBlock::iterator BI = srcB->begin (); PHINode *oldPN = dyn_cast (BI); ++BI) { - assert (TF->LiveInSet.find (oldPN) != TF->LiveInSet.end () + assert (LiveInSet.find (oldPN) != LiveInSet.end () && "Phi nodes in trace entry BB must be live-in"); Argument *phiLiveIn = getFunctionArg (F, TF->LiveInToParameterMap [oldPN]); @@ -833,8 +837,8 @@ // Get some information about the trace's relationship to its parent // function. - getTraceLiveInSet (TF->LiveInSet, TF->LiveInVector, T); - getTraceLiveOutSet (TF->LiveOutSet, TF->LiveOutVector, T); + getTraceLiveInSet (LiveInSet, TF->LiveInVector, T); + getTraceLiveOutSet (LiveOutSet, TF->LiveOutVector, T); TypeVector P = createFunctionArgTypeVector (createLiveOutType (TF->LiveOutVector), TF->LiveInVector); From gaeke at cs.uiuc.edu Wed Jul 7 01:48:07 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Jul 7 01:48:07 2004 Subject: [llvm-commits] CVS: reopt/include/reopt/TraceToFunction.h Message-ID: <200407070647.BAA15683@kain.cs.uiuc.edu> Changes in directory reopt/include/reopt: TraceToFunction.h updated: 1.16 -> 1.17 --- Log message: Get rid of the public LiveIn/LiveOut std::sets. They are only needed by TraceToFunction. --- Diffs of the changes: (+0 -2) Index: reopt/include/reopt/TraceToFunction.h diff -u reopt/include/reopt/TraceToFunction.h:1.16 reopt/include/reopt/TraceToFunction.h:1.17 --- reopt/include/reopt/TraceToFunction.h:1.16 Tue Jul 6 21:19:51 2004 +++ reopt/include/reopt/TraceToFunction.h Wed Jul 7 01:47:14 2004 @@ -47,12 +47,10 @@ /// Variables live going in to TraceFn from MatrixFn /// - LiveVariableSet LiveInSet; LiveVariableVector LiveInVector; /// Variables live going out from TraceFn back into MatrixFn /// - LiveVariableSet LiveOutSet; LiveVariableVector LiveOutVector; /// Constructor - you can't have a TraceFunction without a Trace. From lattner at cs.uiuc.edu Wed Jul 7 01:49:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Jul 7 01:49:01 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200407070648.BAA14566@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.106 -> 1.107 --- Log message: The bytecode reader wants to be able to read types that are not quite resolved yet, then resolve them in it's own sweet time. We must support this. --- Diffs of the changes: (+2 -1) Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.106 llvm/lib/VMCore/Type.cpp:1.107 --- llvm/lib/VMCore/Type.cpp:1.106 Tue Jul 6 18:25:19 2004 +++ llvm/lib/VMCore/Type.cpp Wed Jul 7 01:48:27 2004 @@ -402,7 +402,8 @@ const std::vector &Params, bool IsVarArgs) : DerivedType(FunctionTyID), isVarArgs(IsVarArgs) { - assert((Result->isFirstClassType() || Result == Type::VoidTy) && + assert((Result->isFirstClassType() || Result == Type::VoidTy || + isa(Result)) && "LLVM functions cannot return aggregates"); bool isAbstract = Result->isAbstract(); ContainedTys.reserve(Params.size()+1); From llvm at cs.uiuc.edu Wed Jul 7 07:49:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Wed Jul 7 07:49:01 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/UnitTests/2003-05-31-CastToBool.c Message-ID: <200407071248.HAA08106@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs/SingleSource/UnitTests: 2003-05-31-CastToBool.c updated: 1.3 -> 1.4 --- Log message: Correct a format specifier that causes the program to produce incorrect output. Change suggested by Vladimir Prus. --- Diffs of the changes: (+1 -1) Index: llvm/test/Programs/SingleSource/UnitTests/2003-05-31-CastToBool.c diff -u llvm/test/Programs/SingleSource/UnitTests/2003-05-31-CastToBool.c:1.3 llvm/test/Programs/SingleSource/UnitTests/2003-05-31-CastToBool.c:1.4 --- llvm/test/Programs/SingleSource/UnitTests/2003-05-31-CastToBool.c:1.3 Thu Jul 10 14:23:08 2003 +++ llvm/test/Programs/SingleSource/UnitTests/2003-05-31-CastToBool.c Wed Jul 7 07:48:21 2004 @@ -29,7 +29,7 @@ } void testLong(long long X) { - printf("%ld ", X); + printf("%lld ", X); testBool(X != 0); } From llvm at cs.uiuc.edu Wed Jul 7 08:35:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Wed Jul 7 08:35:01 2004 Subject: [llvm-commits] CVS: llvm/docs/BytecodeFormat.html Message-ID: <200407071334.IAA14883@zion.cs.uiuc.edu> Changes in directory llvm/docs: BytecodeFormat.html updated: 1.17 -> 1.18 --- Log message: An update with corrections to content as well as using a regex style notation that Chris' suggested to make the specification more compact and succinct. Added a section to Describe the notation, made the VBR description its own section, and otherwise generally cleaned things up. --- Diffs of the changes: (+263 -222) Index: llvm/docs/BytecodeFormat.html diff -u llvm/docs/BytecodeFormat.html:1.17 llvm/docs/BytecodeFormat.html:1.18 --- llvm/docs/BytecodeFormat.html:1.17 Tue Jul 6 14:58:54 2004 +++ llvm/docs/BytecodeFormat.html Wed Jul 7 08:34:26 2004 @@ -22,6 +22,7 @@
  • Lists
  • Fields
  • Alignment
  • +
  • Variable Bit-Rate Encoding
  • Encoding Primitives
  • Slots
  • @@ -57,11 +58,15 @@
    -

    This document describes the LLVM bytecode file format as of version 1.3. -It specifies the binary encoding rules of the bytecode file format -so that equivalent systems can encode bytecode files correctly. The LLVM -bytecode representation is used to store the intermediate representation on -disk in compacted form. +

    This document describes the LLVM bytecode file format. It specifies the + binary encoding rules of the bytecode file format so that equivalent systems + can encode bytecode files correctly. The LLVM bytecode representation is + used to store the intermediate representation on disk in compacted form.

    +

    The LLVM bytecode format may change in the future, but LLVM will always be + backwards compatible with older formats. This document will only describe + the most current version of the bytecode format. See + Version Differences for the details on how the + current version is different from previous versions.

    @@ -69,28 +74,26 @@
    -

    This section describes the general concepts of the bytecode file format -without getting into bit and byte level specifics. Note that the LLVM bytecode -format may change in the future, but will always be backwards compatible with -older formats. This document only describes the most current version of the -bytecode format.

    +

    This section describes the general concepts of the bytecode file format + without getting into specific layout details. It is recommended that you read + this section thoroughly before interpreting the detailed descriptions.

    -

    LLVM bytecode files consist simply of a sequence of blocks of bytes. -Each block begins with an header of two unsigned integers. The first value -identifies the type of block and the second value provides the size of the -block in bytes. The block identifier is used because it is possible for entire -blocks to be omitted from the file if they are empty. The block identifier helps -the reader determine which kind of block is next in the file. Note that blocks -can be nested within other blocks.

    -

    All blocks are variable length, and the block header specifies the size of -the block. All blocks begin on a byte index that is aligned to an even 32-bit -boundary. That is, the first block is 32-bit aligned because it starts at offset -0. Each block is padded with zero fill bytes to ensure that the next block also -starts on a 32-bit boundary.

    +

    LLVM bytecode files consist simply of a sequence of blocks of bytes using + a binary encoding Each block begins with an header of two unsigned integers. + The first value identifies the type of block and the second value provides + the size of the block in bytes. The block identifier is used because it is + possible for entire blocks to be omitted from the file if they are empty. + The block identifier helps the reader determine which kind of block is next + in the file. Note that blocks can be nested within other blocks.

    +

    All blocks are variable length, and the block header specifies the size + of the block. All blocks begin on a byte index that is aligned to an even + 32-bit boundary. That is, the first block is 32-bit aligned because it + starts at offset 0. Each block is padded with zero fill bytes to ensure that + the next block also starts on a 32-bit boundary.

    @@ -99,16 +102,9 @@

    LLVM Bytecode blocks often contain lists of things of a similar type. For example, a function contains a list of instructions and a function type contains a list of argument types. There are two basic types of lists: - length lists, and null terminated lists, as described here:

    -
      -
    • Length Lists. Length lists are simply preceded by the number - of items in the list. The bytecode reader will read the count first and - then iterate that many times to read in the list contents.
    • -
    • Null Terminated Lists. For some lists, the number of elements - in the list is not readily available at the time of writing the bytecode. - In these cases, the list is terminated by some null value. What constitutes - a null value differs, but it almost always boils down to a zero value.
    • -
    + length lists (llist), and null terminated lists + (zlist), as described below in the + Encoding Primitives.

    @@ -136,11 +132,8 @@ - +
    -

    Each field that can be put out is encoded into the file using a small set -of primitives. The rules for these primitives are described below.

    -

    Variable Bit Rate Encoding

    Most of the values written to LLVM bytecode files are small integers. To minimize the number of bytes written for these quantities, an encoding scheme similar to UTF-8 is used to write integer data. The scheme is known as @@ -177,52 +170,74 @@ allows small negative quantities to be encoded efficiently. For example, -3 is encoded as "((3 << 1) | 1)" and 3 is encoded as "(3 << 1) | 0)", emitted with the standard vbr encoding above.

    +
    -

    The table below defines the encoding rules for type names used in the -descriptions of blocks and fields in the next section. Any type name with -the suffix _vbr indicate a quantity that is encoded using -variable bit rate encoding as described above.

    + + +
    +

    Each field in the bytecode format is encoded into the file using a small + set of primitive formats. The table below defines the encoding rules for the + various primitives used and gives them each a type name. The type names used + in the descriptions of blocks and fields in the Detailed + Layoutnext section. Any type name with the suffix _vbr indicates + a quantity that is encoded using variable bit rate encoding as described + above.

    Type
    - + - + - + - + - + - - + + - + - + - + + + + + + + - + @@ -356,8 +421,7 @@ functions mostly).
    Type Rule
    unsignedunsigned A 32-bit unsigned integer that always occupies four consecutive bytes. The unsigned integer is encoded using LSB first ordering. That is bits 20 through 27 are in the byte with the lowest file offset (little endian).
    uint32_vbruint32_vbr A 32-bit unsigned integer that occupies from one to five bytes using variable bit rate encoding.
    uint64_vbruint64_vbr A 64-bit unsigned integer that occupies from one to ten bytes using variable bit rate encoding.
    int64_vbrint64_vbr A 64-bit signed integer that occupies from one to ten bytes using the signed variable bit rate encoding.
    charchar A single unsigned character encoded into one byte
    bitA single bit within some larger integer field.bit(n-m)A set of bit within some larger integer field. The + values of n and m specify the inclusive range + of bits that define the subfield. The value for m may be + omitted if its the same as n.
    stringstring A uint32_vbr indicating the type of the constant string which also includes its length, immediately followed by the characters of the string. There is no terminating null byte in the string.
    datadata An arbitrarily long segment of data to which no interpretation is implied. This is used for float, double, and constant initializers.
    blockllist(x)A length list of x. This means the list is encoded as + an uint32_vbr providing the length of the list, + followed by a sequence of that many "x" items. This implies that the reader + should iterate the number of times provided by the length.
    zlist(x)A zero-terminated list of x. This means the list is encoded + as a sequence of an indeterminate number of "x" items, followed by an + uint32_vbr terminating value. This implies that none + of the "x" items can have a zero value (or else the list terminates).
    block A block of data that is logically related. A block begins with an unsigned that provides the block identifier (constant value) and an unsigned that @@ -233,6 +248,56 @@ + +
    +

    In the detailed block and field descriptions that follow, a regex like + notation is used to describe optional and repeated fields. A very limited + subset of regex is used to describe these, as given in the following table: +

    + + + + + + + + + + + + + + + + + + + + +
    CharacterMeaning
    ?The question mark indicates 0 or 1 occurrences of + the thing preceding it.
    *The asterisk indicates 0 or more occurrences of the + thing preceding it.
    +The plus sign indicates 1 or more occurrences of the + thing preceding it.
    ()Parentheses are used for grouping.
    ,The comma separates sequential fields.
    +

    So, for example, consider the following specifications:

    +
    +
      +
    1. string?
    2. +
    3. (uint32_vbr,uin32_vbr)+
    4. +
    5. (unsigned?,uint32_vbr)*
    6. +
    7. (llist(unsigned))?
    8. +
    +
    +

    with the following interpretations:

    +
      +
    1. An optional string. Matches either nothing or a single string
    2. +
    3. One or more pairs of uint32_vbr.
    4. +
    5. Zero or more occurrences of either an unsigned followed by a uint32_vbr + or just a uint32_vbr.
    6. +
    7. An optional length list of unsigned values.
    8. +
    +
    + +

    The bytecode format uses the notion of a "slot" to reference Types and @@ -240,10 +305,10 @@ intermediate representation, there is a need to represent pointers in the file. Slots are used for this purpose. For example, if one has the following assembly:

    -
    +
    %MyType = type { int, sbyte }
    %MyVar = external global %MyType -
    +

    there are two definitions. The definition of %MyVar uses %MyType. In the C++ IR this linkage between %MyVar and %MyType is @@ -276,7 +341,7 @@

    -

    This section provides the general structur of the LLVM bytecode file +

    This section provides the general structure of the LLVM bytecode file format. The bytecode file format requires blocks to be in a certain order and nested in a particular way so that an LLVM module can be constructed efficiently from the contents of the file. This ordering defines a general @@ -321,7 +386,7 @@ except function arguments, global values and constant strings.

    0x11ModuleYesYes1   Function Definitions   Function Definitions* One function block is written for each function in the module. The function block contains the instructions, compaction table, type constant pool, and symbol table for the function.
    -

    Use the links in the table or see Block Types for -details about the contents of each of the block types.

    +

    Use the links in the table for details about the contents of each of the block types.

    @@ -427,7 +491,7 @@ block Module Constant Pool - block + block* Function Definitions block @@ -443,24 +507,23 @@ integer as shown in the following table.

    - - - + + - - + + - - + + - - + + - - + +
    Bit(s) Type Description
    0bitBig Endian?bit(0)Target is big endian?
    1bitPointers Are 64-bit?bit(1)On target pointers are 64-bit?
    2bitHas No Endianess?bit(2)Target has no endianess?
    3bitHas No Pointer Size?bit(3)Target has no pointer size?
    4-31bitBytecode Format Versionbit(4-31)Bytecode format version

    @@ -503,24 +566,16 @@ unsigned Size in bytes of the type pool block. - uint32_vbr - Number of type definitions that follow in the next - field. - - type - Each of the type definitions (see below)1 + llist(type) + A length list of type definitions. -Notes: -

      -
    1. Repeated field.
    2. -
    -

    Types in the type pool are defined using a different format for each -basic type of type as given in the following sections.

    +

    Types in the type pool are defined using a different format for each kind +of type, as given in the following sections.

    Primitive Types

    The primitive types encompass the basic integer and floating point types

    @@ -528,14 +583,29 @@ - - + +
    Type Description
    uint32_vbrType ID For The Primitive (1-11)1uint32_vbrType ID for the primitive types (values 1 to 11) + 1
    Notes:
      -
    1. See the definition of Type::TypeID in Type.h for the numeric equivalents - of the primitive type ids.
    2. +
    3. The values for the Type IDs for the primitive types are provided by the + definition of the llvm::Type::TypeID enumeration in + include/llvm/Type.h. The enumeration gives the following + mapping:
        +
      1. bool
      2. +
      3. ubyte
      4. +
      5. sbyte
      6. +
      7. ushort
      8. +
      9. short
      10. +
      11. uint
      12. +
      13. int
      14. +
      15. ulong
      16. +
      17. long
      18. +
      19. float
      20. +
      21. double
      22. +

    Function Types

    @@ -543,60 +613,45 @@ - + - + - - - - - + + - - + +
    Type Description
    uint32_vbruint32_vbr Type ID for function types (13)
    uint32_vbruint32_vbr Slot number of function's return type.
    uint32_vbrThe number of arguments in the function.
    uint32_vbrSlot number of each argument's type.1llist(uint32_vbr)Slot number of each argument's type.
    uint32_vbrValue 0 if this is a varargs function.2uint32_vbr?Value 0 if this is a varargs function, missing otherwise.
    -Notes: -
      -
    1. Repeated field.
    2. -
    3. Optional field.
    4. -

    Structure Types

    - + - - - - - + +
    Type Description
    uint32_vbruint32_vbr Type ID for structure types (14)
    uint32_vbrSlot number of each of the element's fields.1
    uint32_vbrNull Terminator (VoidTy type id)zlist(uint32_vbr)Slot number of each of the element's fields.
    -Notes: -
      -
    1. Repeatable field.
    2. -

    Array Types

    - + - + - +
    Type Description
    uint32_vbruint32_vbr Type ID for Array Types (15)
    uint32_vbruint32_vbr Slot number of array's element type.
    uint32_vbruint32_vbr The number of elements in the array.
    @@ -606,10 +661,10 @@ Type Description - uint32_vbr + uint32_vbr Type ID For Pointer Types (16) - uint32_vbr + uint32_vbr Slot number of pointer's element type. @@ -619,7 +674,7 @@ Type Description - uint32_vbr + uint32_vbr Type ID For Opaque Types (17) @@ -641,70 +696,60 @@ unsigned Size in bytes of the module global info block. - globalvar - Definition of the global variable (see below). - 1 - - - uint32_vbr - Slot number of the global variable's constant - initializer.1,2 - - - uint32_vbr - Zero. This terminates the list of global variables. - - - uint32_vbr - Type slot number of a function defined in this - bytecode file.3 - - - uint32_vbr - Zero. This terminates the list of function - declarations. + zlist(globalvar) + A zero terminated list of global var definitions + occuring in the module. + + zlist(uint32_vbr) + A zero terminated list of function types occuring in + the module. - Notes:
      -
    1. Both these fields are repeatable but in pairs.
    2. -
    3. Optional field.
    4. -
    5. Repeatable field.
    6. -
    -

    Global variables are written using a single - uint32_vbr that encodes information about the global - variable. The table below provides the bit layout of the value written for - each global variable.

    +

    Global variables are written using an uint32_vbr + that encodes information about the global variable and a list of the constant + initializers for the global var, if any.

    +

    The table below provides the bit layout of the first + uint32_vbr that describes the global variable.

    - - + - - + + - + - +
    Bit(s) Type Description
    0bitbit(0) Is constant?
    1bitHas initializer?1bit(1)Has initializer? Note that this bit determines whether + the constant initializer field (described below) follows.
    2-4enumerationbit(2-4) Linkage type: 0=External, 1=Weak, 2=Appending, 3=Internal, 4=LinkOnce
    5-31type slotbit(5-31) Slot number of type for the global variable.
    - Notes: -
      -
    1. This bit determines whether the constant initializer field follows - immediately after this field
    2. -
    +

    The table below provides the format of the constant initializers for the + global variable field, if it has one.

    + + + + + + + + +
    TypeDescription
    (zlist(uint32_vbr))? + + An optional zero-terminated list of slot numbers of + the global variable's constant initializer.
    @@ -714,7 +759,7 @@ types of constant pool blocks: one for modules and one for functions. For modules, the block begins with the constant strings encountered anywhere in the module. For functions, the block begins with types only encountered in - the function. In both cases the header is identical. The tables the follow, + the function. In both cases the header is identical. The tables that follow, show the header, module constant pool preamble, function constant pool preamble, and the part common to both function and module constant pools.

    Common Block Header

    @@ -725,6 +770,9 @@ unsigned Constant pool identifier (0x12) + + unsigned + Size in bytes of the constant pool block.

    Module Constant Pool Preamble (constant strings)

    @@ -738,19 +786,17 @@ uint32_vbr Zero. This identifies the following "plane" as - containing the constant strings. + containing the constant strings. This is needed to identify it + uniquely from other constant planes that follow. - string - Slot number of the constant string's type which - includes the length of the string.1 + uint32_vbr+ + Slot number of the constant string's type. Note + that the constant string's type implicitly defines the length of + the string. - Notes: -
      -
    1. Repeated field.
    2. -

    Function Constant Pool Preamble (function types)

    The structure of the types for functions is identical to the Global Type Pool. Please refer to that section @@ -767,7 +813,7 @@ uint32_vbr Type slot number of this plane. - constant + constant+ The definition of a constant (see below). @@ -825,33 +871,40 @@

    -

    To be determined.

    +

    Function definitions contain the linkage, constant pool or compaction + table, instruction list, and symbol table for a function. The following table + shows the structure of a function definition.

    + + + + + + - - + + - - + + - - + + - - + +
    Type Field Description
    unsignedFunction definition block identifier (0x11)
    unsignedSize in bytes of the function definition block.
    uint32_vbr The linkage type of the function: 0=External, 1=Weak, 2=Appending, 3=Internal, 4=LinkOnce1
    constant poolThe constant pool block for this function. - 2 - blockThe constant pool block + for this function.2
    compaction tableThe compaction table block for the function. - 2 - blockThe compaction table + block for the function.2
    instruction listThe list of instructions in the function.blockThe instruction list + for the function.
    symbol tableThe function's slot table containing only those - symbols pertinent to the function (mostly block labels). - blockThe function's symbol table + containing only those symbols pertinent to the function (mostly + block labels).
    Notes:
      @@ -869,13 +922,14 @@ device for reducing the size of bytecode files. The size of a bytecode file is dependent on the value of the slot numbers used because larger values use more bytes in the variable bit rate encoding scheme. - Furthermore, the compresses instruction format reserves only six bits for + Furthermore, the compressed instruction format reserves only six bits for the type of the instruction. In large modules, declaring hundreds or thousands of types, the values of the slot numbers can be quite large. However, functions may use only a small fraction of the global types. In such cases a compaction table is created that maps the global type and value slot - numbers to smaller values used by a function. Compaction tables have the - format shown in the table below.

      + numbers to smaller values used by a function. Functions will contain either + a function-specific constant pool or a compaction table but not + both. Compaction tables have the format shown in the table below.

      @@ -884,26 +938,23 @@ - + + this entry in the compaction table. + follow. This field's encoding varies depending on the size of + the type plane. See Type and Length for + further details. - + + the compaction table
      Typeuint32_vbr The number of types that follow
      uint32_vbruint32_vbr+ The slot number in the global type plane of the type that will be referenced in the function with the index of - this entry in the compaction table.1
      type_len An encoding of the type and number of values that - follow.2
      uint32_vbruint32_vbr+ The slot number in the globals of the value that will be referenced in the function with the index of this entry in - the compaction table1
      - Notes:
        -
      1. Repeated field.
      2. -
      3. This field's encoding varies depending on the size of the type plane. - See Type and Length for further details. -
    @@ -935,15 +986,11 @@ unsigned Size in bytes of the instruction list. - instruction - An instruction.1 + instruction+ + An instruction. Instructions have a variety of formats. + See Instructions for details. - Notes: -
      -
    1. A repeated field with a variety of formats. See - Instructions for details.
    2. -
    @@ -975,13 +1022,12 @@ uint32_vbr The number of operands that follow. - uint32_vbr - The slot number of the value for the operand(s). - 1,2 + uint32_vbr+ + The slot number of the value(s) for the operand(s). + 1 Notes:
      -
    1. Repeatable field (limit given by previous field).
    2. Note that if the instruction is a getelementptr and the type of the operand is a sequential type (array or pointer) then the slot number is shifted up two bits and the low order bits will encode the type of index @@ -1003,7 +1049,7 @@ 2-7opcode Specifies the opcode of the instruction. Note that - the maximum opcode value si 63. + the maximum opcode value is 63. 8-19unsigned Specifies the slot number of the type for this @@ -1031,7 +1077,7 @@ 2-7opcode Specifies the opcode of the instruction. Note that - the maximum opcode value si 63. + the maximum opcode value is 63. 8-15unsigned Specifies the slot number of the type for this @@ -1062,7 +1108,7 @@ 2-7opcode Specifies the opcode of the instruction. Note that - the maximum opcode value si 63. + the maximum opcode value is 63. 8-13unsigned Specifies the slot number of the type for this @@ -1106,19 +1152,14 @@ uint32_vbr Number of entries in type plane - symtab_entry - Provides the slot number of the type and its name. - 1 + symtab_entry* + Provides the slot number of the type and its name. - symtab_plane + symtab_plane* A type plane containing value slot number and name - for all values of the same type.1 + for all values of the same type. -Notes: -
        -
      1. Repeated field.
      2. -
      @@ -1138,8 +1179,8 @@ uint32_vbr Slot number of type for this plane. - symtab_entry - The symbol table entries for this plane (repeated). + symtab_entry+ + The symbol table entries for this plane. @@ -1163,8 +1204,8 @@ uint32_vbr Length of the character array that follows. - char - The characters of the name (repeated). + char+ + The characters of the name. @@ -1249,7 +1290,7 @@ Reid Spencer and Chris Lattner
      The LLVM Compiler Infrastructure
      - Last modified: $Date: 2004/07/06 19:58:54 $ + Last modified: $Date: 2004/07/07 13:34:26 $ From llvm at cs.uiuc.edu Wed Jul 7 10:04:02 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Wed Jul 7 10:04:02 2004 Subject: [llvm-commits] CVS: llvm/docs/BytecodeFormat.html Message-ID: <200407071503.KAA15497@zion.cs.uiuc.edu> Changes in directory llvm/docs: BytecodeFormat.html updated: 1.18 -> 1.19 --- Log message: Insert a reference to uint32_vbr encoding. --- Diffs of the changes: (+3 -3) Index: llvm/docs/BytecodeFormat.html diff -u llvm/docs/BytecodeFormat.html:1.18 llvm/docs/BytecodeFormat.html:1.19 --- llvm/docs/BytecodeFormat.html:1.18 Wed Jul 7 08:34:26 2004 +++ llvm/docs/BytecodeFormat.html Wed Jul 7 10:02:54 2004 @@ -503,8 +503,8 @@
      -

      The format information field is encoded into a 32-bit vbr-encoded unsigned -integer as shown in the following table.

      +

      The format information field is encoded into a + uint32_vbr as shown in the following table.

      @@ -1290,7 +1290,7 @@ Reid Spencer and Chris Lattner
      The LLVM Compiler Infrastructure
      - Last modified: $Date: 2004/07/07 13:34:26 $ + Last modified: $Date: 2004/07/07 15:02:54 $ From lattner at cs.uiuc.edu Wed Jul 7 13:09:05 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Jul 7 13:09:05 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Value.cpp Message-ID: <200407071807.NAA19861@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Value.cpp updated: 1.45 -> 1.46 --- Log message: Fix regressions in these testcases: Regression.Assembler.2002-01-24-BadSymbolTableAssert Regression.Assembler.2002-01-24-ValueRefineAbsType Found through the nightly tester :) --- Diffs of the changes: (+2 -1) Index: llvm/lib/VMCore/Value.cpp diff -u llvm/lib/VMCore/Value.cpp:1.45 llvm/lib/VMCore/Value.cpp:1.46 --- llvm/lib/VMCore/Value.cpp:1.45 Tue Jul 6 12:44:17 2004 +++ llvm/lib/VMCore/Value.cpp Wed Jul 7 13:07:46 2004 @@ -32,7 +32,8 @@ Value::Value(const Type *ty, unsigned scid, const std::string &name) : SubclassID(scid), Ty(checkType(ty)), Name(name) { if (!isa(this) && !isa(this)) - assert((Ty->isFirstClassType() || Ty == Type::VoidTy) && + assert((Ty->isFirstClassType() || Ty == Type::VoidTy || + isa(ty)) && "Cannot create non-first-class values except for constants!"); } From gaeke at cs.uiuc.edu Wed Jul 7 14:12:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Jul 7 14:12:02 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceToFunction/TraceToFunction.cpp Message-ID: <200407071911.OAA01042@kain.cs.uiuc.edu> Changes in directory reopt/lib/TraceToFunction: TraceToFunction.cpp updated: 1.71 -> 1.72 --- Log message: Replace LiveInToParameterMap with LiveInToArgMap (which maps live-in values directly to the Argument*s that represent them.) Make giveNamesToFunctionArgs a member of TraceFunctionBuilder. Make it do the job of printing out live-in values and filling in LiveInToArgMap. (Calling it is now therefore no longer optional.) Simplify createFunctionArgTypeVector. --- Diffs of the changes: (+28 -29) Index: reopt/lib/TraceToFunction/TraceToFunction.cpp diff -u reopt/lib/TraceToFunction/TraceToFunction.cpp:1.71 reopt/lib/TraceToFunction/TraceToFunction.cpp:1.72 --- reopt/lib/TraceToFunction/TraceToFunction.cpp:1.71 Wed Jul 7 01:47:15 2004 +++ reopt/lib/TraceToFunction/TraceToFunction.cpp Wed Jul 7 14:11:25 2004 @@ -24,6 +24,7 @@ #include "llvm/Transforms/Utils/Cloning.h" #include "llvm/Pass.h" #include "llvm/Module.h" +#include "llvm/Argument.h" #include "llvm/DerivedTypes.h" #include "llvm/iTerminators.h" #include "llvm/iPHINode.h" @@ -69,6 +70,7 @@ TypeVector createFunctionArgTypeVector (PointerType *ST, const LiveVariableVector &S); + void giveNamesToFunctionArgs (LiveVariableVector LVV, Function *F); void fillInFunctionBody (Trace &T, Function *F, LiveVariableVector &So); int findOffTracePhiSource (const PHINode *newPN); void fixupFunctionBodyBB (Trace &T, Function *F, BasicBlock *srcB, @@ -301,50 +303,47 @@ /// createFunctionArgTypeVector - Given the live-in vector LVV of a trace, /// create a parameter list containing a parameter for each of the /// variables in LVV as well as a pointer-to-structure type PST to fill -/// in which contains the live-outs. As a side effect, fill in the -/// mapping between live-ins and parameters in -/// TF->LiveInToParameterMap. +/// in which contains the live-outs. /// TypeVector TraceFunctionBuilder::createFunctionArgTypeVector (PointerType *PST, const LiveVariableVector &LVV) { TypeVector P; P.push_back (PST); - - TF->LiveInToParameterMap.clear (); - for (LiveVariableVector::const_iterator I = LVV.begin (), E = LVV.end (); I != E; - ++I) { - Value *V = *I; - P.push_back (V->getType ()); - TF->LiveInToParameterMap[V] = P.size () - 1; - } - // Print out mapping of instructions producing live-ins to arg numbers. - DEBUG(std::cerr << "\nLive-in values:\n"; - for (ValueToIntMap::iterator I = TF->LiveInToParameterMap.begin (), - E = TF->LiveInToParameterMap.end (); I != E; ++I) { - WriteAsOperand (std::cerr, I->first, true, true, - TF->MatrixFn->getParent ()); - std::cerr << " is parameter " << I->second << "\n"; - }); + for (LiveVariableVector::const_iterator I = LVV.begin (), E = LVV.end (); + I != E; ++I) + P.push_back ((*I)->getType ()); return P; } /// giveNamesToFunctionArgs - Name the first argument of F "liveOut", -/// then name the remaining arguments of F according to LVV. +/// then name the remaining arguments of F according to LVV. As a +/// side effect, fills in the mapping between live-ins and arguments in +/// TF->LiveInToArgMap. /// -static void giveNamesToFunctionArgs (LiveVariableVector LVV, Function *F) { +void TraceFunctionBuilder::giveNamesToFunctionArgs (LiveVariableVector LVV, + Function *F) { Function::aiterator argIterator = F->abegin (); unsigned argPosition = 0; argIterator->setName ("liveOut"); // Arg 0 is always the live-out struct. ++argPosition; ++argIterator; - + + // Fill in & print out mapping of instructions producing live-ins to + // args, and set arg names. + std::cerr << "\nLive-in values:\n"; for (LiveVariableVector::iterator I = LVV.begin (), E = LVV.end (); I != E; ++I) { - std::string name ((*I)->getName ()); + Value *V = *I; + WriteAsOperand (std::cerr, *I, true, true, TF->MatrixFn->getParent ()); + std::cerr << " is argument # " << argPosition << " (%"; + TF->LiveInToArgMap[V] = &*argIterator; + + std::string name (V->getName ()); if (name == "") name = "arg" + utostr (argPosition); argIterator->setName ("liveIn." + name); + std::cerr << argIterator->getName () << ")\n"; ++argPosition; ++argIterator; } @@ -382,7 +381,7 @@ O2CMap[BI] = BI; } for (LiveVariableVector::iterator I = Si.begin (), E = Si.end (); I != E; ++I) - O2CMap[*I] = getFunctionArg (TF->TraceFn, TF->LiveInToParameterMap[*I]); + O2CMap[*I] = TF->LiveInToArgMap[*I]; CloneTraceInto (TF->TraceFn, TF->T, O2CMap, ".ttf"); } @@ -659,8 +658,6 @@ PHINode *oldPN = dyn_cast (BI); ++BI) { assert (LiveInSet.find (oldPN) != LiveInSet.end () && "Phi nodes in trace entry BB must be live-in"); - Argument *phiLiveIn = getFunctionArg (F, - TF->LiveInToParameterMap [oldPN]); Value *V = O2CMap[oldPN]; assert (V && isa (V) @@ -682,8 +679,10 @@ << "'s off-trace source #" << i << "\n"); newPN->removeIncomingValue (i); } - if (foundOffTracePhiSource) + if (foundOffTracePhiSource) { + Value *phiLiveIn = TF->LiveInToArgMap [oldPN]; newPN->addIncoming (phiLiveIn, EntryFixup); + } } } @@ -730,7 +729,7 @@ Index.push_back (Constant::getNullValue (Type::LongTy)); //long 0 Index.push_back (ConstantUInt::get (Type::UIntTy, Slot));//uint Slot GetElementPtrInst *GEP = - new GetElementPtrInst (getFunctionArg (F, 0), Index, + new GetElementPtrInst (&*F->abegin (), Index, "liveOutP" + utostr (BranchNumber[BI]) + "_" + utostr (i) + "_" + utostr (Slot)); FB->getInstList ().push_back (GEP); @@ -849,7 +848,7 @@ TF->TraceFn = new Function (FunctionType::get (Type::UIntTy, P, false), GlobalValue::InternalLinkage, name, T.getModule ()); - DEBUG(giveNamesToFunctionArgs (TF->LiveInVector, TF->TraceFn)); + giveNamesToFunctionArgs (TF->LiveInVector, TF->TraceFn); fillInFunctionBody (T, TF->TraceFn, TF->LiveOutVector); return TF; } From gaeke at cs.uiuc.edu Wed Jul 7 14:12:15 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Jul 7 14:12:15 2004 Subject: [llvm-commits] CVS: reopt/include/reopt/TraceToFunction.h Message-ID: <200407071911.OAA01035@kain.cs.uiuc.edu> Changes in directory reopt/include/reopt: TraceToFunction.h updated: 1.17 -> 1.18 --- Log message: Replace LiveInToParameterMap with LiveInToArgMap (which maps live-in values directly to the Argument*s that represent them.) --- Diffs of the changes: (+5 -6) Index: reopt/include/reopt/TraceToFunction.h diff -u reopt/include/reopt/TraceToFunction.h:1.17 reopt/include/reopt/TraceToFunction.h:1.18 --- reopt/include/reopt/TraceToFunction.h:1.17 Wed Jul 7 01:47:14 2004 +++ reopt/include/reopt/TraceToFunction.h Wed Jul 7 14:11:24 2004 @@ -74,17 +74,16 @@ /// ValueMap O2CMap; - /// Map of Trace's live-in values in the MatrixFn --> parameter numbers in - /// TraceFn. + /// Map of Trace's live-in values in the MatrixFn --> arguments of TraceFn. /// - ValueToIntMap LiveInToParameterMap; + ValueMap LiveInToArgMap; Value *getCorrespondingValue (const Value *V, bool preferLiveIn = true) { if (isa(V)) return const_cast (V); if (preferLiveIn) { - ValueToIntMap::iterator It = LiveInToParameterMap.find (V); - if (It != LiveInToParameterMap.end ()) - return getFunctionArg (TraceFn, It->second); + ValueMap::iterator It = LiveInToArgMap.find (V); + if (It != LiveInToArgMap.end ()) + return It->second; } // Otherwise, ignore live-in values (useful for getting the live-out // version of a value that is both live-out and live-in) From gaeke at cs.uiuc.edu Wed Jul 7 14:13:05 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Jul 7 14:13:05 2004 Subject: [llvm-commits] CVS: reopt/tools/ttftest/ttftest.cpp Message-ID: <200407071911.OAA01049@kain.cs.uiuc.edu> Changes in directory reopt/tools/ttftest: ttftest.cpp updated: 1.6 -> 1.7 --- Log message: Use live variable vectors instead of sets. --- Diffs of the changes: (+4 -4) Index: reopt/tools/ttftest/ttftest.cpp diff -u reopt/tools/ttftest/ttftest.cpp:1.6 reopt/tools/ttftest/ttftest.cpp:1.7 --- reopt/tools/ttftest/ttftest.cpp:1.6 Wed Jun 30 01:33:15 2004 +++ reopt/tools/ttftest/ttftest.cpp Wed Jul 7 14:11:26 2004 @@ -38,7 +38,7 @@ }; void printLiveSet (std::ostream &OS, const std::string Banner, - LiveVariableSet &S, TraceFunction *TF, + LiveVariableVector &S, TraceFunction *TF, bool printCorrespondingValues = true) { OS << Banner; unsigned Count = 0; @@ -48,7 +48,7 @@ OS << "Set is empty\n\n"; return; } - for (LiveVariableSet::iterator i = S.begin (), e = S.end (); i != e; ++i) { + for (LiveVariableVector::iterator i = S.begin (), e = S.end (); i != e; ++i) { Value *MV = *i; OS << Count << ": "; WriteAsOperand (OS, MV, true, true, M); @@ -67,8 +67,8 @@ } void printLiveSets (TraceFunction *TF) { - printLiveSet (std::cout, "Live-in set:\n", TF->LiveInSet, TF); - printLiveSet (std::cout, "Live-out set:\n", TF->LiveOutSet, TF); + printLiveSet (std::cout, "Live-in set:\n", TF->LiveInVector, TF); + printLiveSet (std::cout, "Live-out set:\n", TF->LiveOutVector, TF); } int main (int argc, char **argv) { From llvm at cs.uiuc.edu Wed Jul 7 16:02:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Wed Jul 7 16:02:01 2004 Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/JIT/JIT.cpp Message-ID: <200407072101.QAA18586@zion.cs.uiuc.edu> Changes in directory llvm/lib/ExecutionEngine/JIT: JIT.cpp updated: 1.34 -> 1.35 --- Log message: Fix for bug 391: http://llvm.cs.uiuc.edu/PR391 . Improve exeception handling around bcreader invocations. --- Diffs of the changes: (+3 -0) Index: llvm/lib/ExecutionEngine/JIT/JIT.cpp diff -u llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.34 llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.35 --- llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.34 Sun Jul 4 07:19:56 2004 +++ llvm/lib/ExecutionEngine/JIT/JIT.cpp Wed Jul 7 16:01:38 2004 @@ -117,6 +117,9 @@ // Make sure we read in the function if it exists in this Module try { MP->materializeFunction(F); + } catch ( std::string& errmsg ) { + std::cerr << "Error parsing bytecode file: " << errmsg << "\n"; + abort(); } catch (...) { std::cerr << "Error parsing bytecode file!\n"; abort(); From llvm at cs.uiuc.edu Wed Jul 7 16:03:02 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Wed Jul 7 16:03:02 2004 Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/ExecutionEngine.cpp Message-ID: <200407072101.QAA18587@zion.cs.uiuc.edu> Changes in directory llvm/lib/ExecutionEngine: ExecutionEngine.cpp updated: 1.52 -> 1.53 --- Log message: Fix for bug 391: http://llvm.cs.uiuc.edu/PR391 . Improve exeception handling around bcreader invocations. --- Diffs of the changes: (+2 -0) Index: llvm/lib/ExecutionEngine/ExecutionEngine.cpp diff -u llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.52 llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.53 --- llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.52 Sun Jun 20 02:46:18 2004 +++ llvm/lib/ExecutionEngine/ExecutionEngine.cpp Wed Jul 7 16:01:38 2004 @@ -137,6 +137,8 @@ } catch (...) { std::cerr << "Error creating the interpreter!\n"; } + } catch (std::string& errmsg) { + std::cerr << "Error reading the bytecode file: " << errmsg << "\n"; } catch (...) { std::cerr << "Error reading the bytecode file!\n"; } From llvm at cs.uiuc.edu Wed Jul 7 16:03:08 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Wed Jul 7 16:03:08 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Pass.cpp Message-ID: <200407072101.QAA18596@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Pass.cpp updated: 1.58 -> 1.59 --- Log message: Fix for bug 391: http://llvm.cs.uiuc.edu/PR391 . Improve exeception handling around bcreader invocations. --- Diffs of the changes: (+9 -1) Index: llvm/lib/VMCore/Pass.cpp diff -u llvm/lib/VMCore/Pass.cpp:1.58 llvm/lib/VMCore/Pass.cpp:1.59 --- llvm/lib/VMCore/Pass.cpp:1.58 Sun Jul 4 06:53:53 2004 +++ llvm/lib/VMCore/Pass.cpp Wed Jul 7 16:01:38 2004 @@ -92,7 +92,15 @@ void FunctionPassManager::add(FunctionPass *P) { PM->add(P); } void FunctionPassManager::add(ImmutablePass *IP) { PM->add(IP); } bool FunctionPassManager::run(Function &F) { - MP->materializeFunction(&F); + try { + MP->materializeFunction(&F); + } catch (std::string& errstr) { + std::cerr << "Error reading bytecode file: " << errstr << "\n"; + abort(); + } catch (...) { + std::cerr << "Error reading bytecode file:\n"; + abort(); + } return PM->run(F); } From llvm at cs.uiuc.edu Wed Jul 7 16:07:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Wed Jul 7 16:07:01 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200407072106.QAA18671@zion.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.211 -> 1.212 --- Log message: Bug 391: http://llvm.cs.uiuc.edu/PR391 fixed. --- Diffs of the changes: (+3 -1) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.211 llvm/docs/ReleaseNotes.html:1.212 --- llvm/docs/ReleaseNotes.html:1.211 Tue Jul 6 21:25:24 2004 +++ llvm/docs/ReleaseNotes.html Wed Jul 7 16:06:28 2004 @@ -179,6 +179,8 @@
    3. All documentation is now conformant to the HTML 4.01 (Strict) level.
    4. The spurious "WARNING: Found global types that are not compatible" warning produced when linking C++ programs has been fixed.
    5. +
    6. lli Doesn't Handle Exceptions From +Bytecode Reader
    7. @@ -748,7 +750,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
      - Last modified: $Date: 2004/07/07 02:25:24 $ + Last modified: $Date: 2004/07/07 21:06:28 $ From llvm at cs.uiuc.edu Wed Jul 7 16:20:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Wed Jul 7 16:20:01 2004 Subject: [llvm-commits] CVS: llvm/utils/llvmgrep Message-ID: <200407072119.QAA18794@zion.cs.uiuc.edu> Changes in directory llvm/utils: llvmgrep updated: 1.1 -> 1.2 --- Log message: Fix some thinkos in the script (error handling, proper argument handling). --- Diffs of the changes: (+4 -2) Index: llvm/utils/llvmgrep diff -u llvm/utils/llvmgrep:1.1 llvm/utils/llvmgrep:1.2 --- llvm/utils/llvmgrep:1.1 Sat Jun 19 15:32:55 2004 +++ llvm/utils/llvmgrep Wed Jul 7 16:19:01 2004 @@ -1,7 +1,7 @@ #!/bin/sh # This is useful because it prints out all of the source files. Useful for # greps. -PATTERN=$* +PATTERN="$*" TOPDIR=`pwd | sed -e 's#(.*/llvm).*#$1#'` if test -d "$TOPDIR" ; then cd $TOPDIR @@ -18,5 +18,7 @@ \! -name 'llvmAsmParser.h' \ \! -name 'FileParser.cpp' \ \! -name 'FileParser.h' \ - -exec egrep -H -n $PATTERN {} \; + -exec egrep -H -n "$PATTERN" {} \; +else + echo "Can't find LLVM top directory in $TOPDIR" fi From llvm at cs.uiuc.edu Wed Jul 7 16:21:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Wed Jul 7 16:21:01 2004 Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/JIT/JIT.cpp Message-ID: <200407072120.QAA18818@zion.cs.uiuc.edu> Changes in directory llvm/lib/ExecutionEngine/JIT: JIT.cpp updated: 1.35 -> 1.36 --- Log message: Make error message consistent with the rest of LLVM by saying that bytecode is read, not parsed. --- Diffs of the changes: (+2 -2) Index: llvm/lib/ExecutionEngine/JIT/JIT.cpp diff -u llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.35 llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.36 --- llvm/lib/ExecutionEngine/JIT/JIT.cpp:1.35 Wed Jul 7 16:01:38 2004 +++ llvm/lib/ExecutionEngine/JIT/JIT.cpp Wed Jul 7 16:20:28 2004 @@ -118,10 +118,10 @@ try { MP->materializeFunction(F); } catch ( std::string& errmsg ) { - std::cerr << "Error parsing bytecode file: " << errmsg << "\n"; + std::cerr << "Error reading bytecode file: " << errmsg << "\n"; abort(); } catch (...) { - std::cerr << "Error parsing bytecode file!\n"; + std::cerr << "Error reading bytecode file!\n"; abort(); } From brukman at cs.uiuc.edu Wed Jul 7 16:23:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Wed Jul 7 16:23:01 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Pass.cpp Message-ID: <200407072122.QAA18849@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Pass.cpp updated: 1.59 -> 1.60 --- Log message: There is no error message to print out, end sentence with `!' --- Diffs of the changes: (+1 -1) Index: llvm/lib/VMCore/Pass.cpp diff -u llvm/lib/VMCore/Pass.cpp:1.59 llvm/lib/VMCore/Pass.cpp:1.60 --- llvm/lib/VMCore/Pass.cpp:1.59 Wed Jul 7 16:01:38 2004 +++ llvm/lib/VMCore/Pass.cpp Wed Jul 7 16:22:05 2004 @@ -98,7 +98,7 @@ std::cerr << "Error reading bytecode file: " << errstr << "\n"; abort(); } catch (...) { - std::cerr << "Error reading bytecode file:\n"; + std::cerr << "Error reading bytecode file!\n"; abort(); } return PM->run(F); From alkis at cs.uiuc.edu Wed Jul 7 19:49:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Jul 7 19:49:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/CodeGen/MachineFunction.h Message-ID: <200407080048.TAA25988@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm/CodeGen: MachineFunction.h updated: 1.37 -> 1.38 --- Log message: Add viewCFG() and viewCFGOnly() APIs. --- Diffs of the changes: (+66 -0) Index: llvm/include/llvm/CodeGen/MachineFunction.h diff -u llvm/include/llvm/CodeGen/MachineFunction.h:1.37 llvm/include/llvm/CodeGen/MachineFunction.h:1.38 --- llvm/include/llvm/CodeGen/MachineFunction.h:1.37 Thu Jul 1 01:01:36 2004 +++ llvm/include/llvm/CodeGen/MachineFunction.h Wed Jul 7 19:47:58 2004 @@ -135,6 +135,21 @@ /// void print(std::ostream &OS) const; + /// viewCFG - This function is meant for use from the debugger. You can just + /// say 'call F->viewCFG()' and a ghostview window should pop up from the + /// program, displaying the CFG of the current function with the code for each + /// basic block inside. This depends on there being a 'dot' and 'gv' program + /// in your path. + /// + void viewCFG() const; + + /// viewCFGOnly - This function is meant for use from the debugger. It works + /// just like viewCFG, but it does not include the contents of basic blocks + /// into the nodes, just the label. If you are only interested in the CFG + /// this can make the graph smaller. + /// + void viewCFGOnly() const; + /// dump - Print the current MachineFunction to cerr, useful for debugger use. /// void dump() const; @@ -206,6 +221,57 @@ } }; +//===--------------------------------------------------------------------===// +// GraphTraits specializations for function basic block graphs (CFGs) +//===--------------------------------------------------------------------===// + +// Provide specializations of GraphTraits to be able to treat a +// machine function as a graph of machine basic blocks... these are +// the same as the machine basic block iterators, except that the root +// node is implicitly the first node of the function. +// +template <> struct GraphTraits : + public GraphTraits { + static NodeType *getEntryNode(MachineFunction *F) { + return &F->front(); + } + + // nodes_iterator/begin/end - Allow iteration over all nodes in the graph + typedef MachineFunction::iterator nodes_iterator; + static nodes_iterator nodes_begin(MachineFunction *F) { return F->begin(); } + static nodes_iterator nodes_end (MachineFunction *F) { return F->end(); } +}; +template <> struct GraphTraits : + public GraphTraits { + static NodeType *getEntryNode(const MachineFunction *F) { + return &F->front(); + } + + // nodes_iterator/begin/end - Allow iteration over all nodes in the graph + typedef MachineFunction::const_iterator nodes_iterator; + static nodes_iterator nodes_begin(const MachineFunction *F) { return F->begin(); } + static nodes_iterator nodes_end (const MachineFunction *F) { return F->end(); } +}; + + +// Provide specializations of GraphTraits to be able to treat a function as a +// graph of basic blocks... and to walk it in inverse order. Inverse order for +// a function is considered to be when traversing the predecessor edges of a BB +// instead of the successor edges. +// +template <> struct GraphTraits > : + public GraphTraits > { + static NodeType *getEntryNode(Inverse G) { + return &G.Graph->front(); + } +}; +template <> struct GraphTraits > : + public GraphTraits > { + static NodeType *getEntryNode(Inverse G) { + return &G.Graph->front(); + } +}; + } // End llvm namespace #endif From alkis at cs.uiuc.edu Wed Jul 7 19:49:07 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Wed Jul 7 19:49:07 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/MachineFunction.cpp Message-ID: <200407080048.TAA25981@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: MachineFunction.cpp updated: 1.63 -> 1.64 --- Log message: Add viewCFG() and viewCFGOnly() APIs. --- Diffs of the changes: (+77 -1) Index: llvm/lib/CodeGen/MachineFunction.cpp diff -u llvm/lib/CodeGen/MachineFunction.cpp:1.63 llvm/lib/CodeGen/MachineFunction.cpp:1.64 --- llvm/lib/CodeGen/MachineFunction.cpp:1.63 Sun Jul 4 07:19:55 2004 +++ llvm/lib/CodeGen/MachineFunction.cpp Wed Jul 7 19:47:58 2004 @@ -26,7 +26,10 @@ #include "llvm/iOther.h" #include "llvm/Type.h" #include "Support/LeakDetector.h" +#include "Support/GraphWriter.h" +#include #include +#include using namespace llvm; @@ -140,6 +143,80 @@ OS << "\n# End machine code for " << Fn->getName () << "().\n\n"; } +/// CFGOnly flag - This is used to control whether or not the CFG graph printer +/// prints out the contents of basic blocks or not. This is acceptable because +/// this code is only really used for debugging purposes. +/// +static bool CFGOnly = false; + +namespace llvm { +template<> +struct DOTGraphTraits : public DefaultDOTGraphTraits { + static std::string getGraphName(const MachineFunction *F) { + return "CFG for '" + F->getFunction()->getName() + "' function"; + } + + static std::string getNodeLabel(const MachineBasicBlock *Node, + const MachineFunction *Graph) { + if (CFGOnly && Node->getBasicBlock() && + !Node->getBasicBlock()->getName().empty()) + return Node->getBasicBlock()->getName() + ":"; + + std::ostringstream Out; + if (CFGOnly) { + Out << Node->getNumber() << ':'; + return Out.str(); + } + + Node->print(Out); + + std::string OutStr = Out.str(); + if (OutStr[0] == '\n') OutStr.erase(OutStr.begin()); + + // Process string output to make it nicer... + for (unsigned i = 0; i != OutStr.length(); ++i) + if (OutStr[i] == '\n') { // Left justify + OutStr[i] = '\\'; + OutStr.insert(OutStr.begin()+i+1, 'l'); + } + return OutStr; + } +}; +} + +void MachineFunction::viewCFG() const +{ + std::string Filename = "/tmp/cfg." + getFunction()->getName() + ".dot"; + std::cerr << "Writing '" << Filename << "'... "; + std::ofstream F(Filename.c_str()); + + if (!F) { + std::cerr << " error opening file for writing!\n"; + return; + } + + WriteGraph(F, this); + F.close(); + std::cerr << "\n"; + + std::cerr << "Running 'dot' program... " << std::flush; + if (system(("dot -Tps -Nfontname=Courier -Gsize=7.5,10 " + Filename + + " > /tmp/cfg.tempgraph.ps").c_str())) { + std::cerr << "Error running dot: 'dot' not in path?\n"; + } else { + std::cerr << "\n"; + system("gv /tmp/cfg.tempgraph.ps"); + } + system(("rm " + Filename + " /tmp/cfg.tempgraph.ps").c_str()); +} + +void MachineFunction::viewCFGOnly() const +{ + CFGOnly = true; + viewCFG(); + CFGOnly = false; +} + // The next two methods are used to construct and to retrieve // the MachineCodeForFunction object for the given function. // construct() -- Allocates and initializes for a given function and target @@ -405,4 +482,3 @@ void MachineFunctionInfo::popAllTempValues() { resetTmpAreaSize(); // clear tmp area to reuse } - From gaeke at cs.uiuc.edu Wed Jul 7 22:21:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Jul 7 22:21:01 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceToFunction/TraceToFunction.cpp Message-ID: <200407080320.WAA03776@kain.cs.uiuc.edu> Changes in directory reopt/lib/TraceToFunction: TraceToFunction.cpp updated: 1.72 -> 1.73 --- Log message: Restructure TraceFn so that instead of having arguments ({ ...live outs... } *liveOut, ...live ins...) it now has (...live ins..., ...pointers to live outs...) createLiveOutType is history. Also, now we only have to generate store instructions, not gep-store pairs. This is loosely modelled after the code extractor. --- Diffs of the changes: (+55 -67) Index: reopt/lib/TraceToFunction/TraceToFunction.cpp diff -u reopt/lib/TraceToFunction/TraceToFunction.cpp:1.72 reopt/lib/TraceToFunction/TraceToFunction.cpp:1.73 --- reopt/lib/TraceToFunction/TraceToFunction.cpp:1.72 Wed Jul 7 14:11:25 2004 +++ reopt/lib/TraceToFunction/TraceToFunction.cpp Wed Jul 7 22:19:58 2004 @@ -68,9 +68,11 @@ void threadFLIEdges (Function *F); void buildFLIMap (Trace &T, FLIMapTy &FLIMap); - TypeVector createFunctionArgTypeVector (PointerType *ST, - const LiveVariableVector &S); - void giveNamesToFunctionArgs (LiveVariableVector LVV, Function *F); + TypeVector createFunctionArgTypeVector (const LiveVariableVector &LiveIns, + const LiveVariableVector &LiveOuts); + void giveNamesToFunctionArgs (const LiveVariableVector &LiveIns, + const LiveVariableVector &LiveOuts, + Function *F); void fillInFunctionBody (Trace &T, Function *F, LiveVariableVector &So); int findOffTracePhiSource (const PHINode *newPN); void fixupFunctionBodyBB (Trace &T, Function *F, BasicBlock *srcB, @@ -281,72 +283,70 @@ return NULL; } -/// createLiveOutType - Given the live-out set S of a trace, create a -/// pointer-to-structure type that will encapsulate all the live-outs from S. +/// createFunctionArgTypeVector - Given the live-in and live-out vectors of a +/// trace, create a parameter list containing a parameter for each of the +/// variables in LiveIns and a parameter for a pointer to each of the +/// variables in LiveOuts. /// -static PointerType *createLiveOutType (const LiveVariableVector &LVV) { - TypeVector T; - unsigned Counter = 0; - // For each variable in S, make a new entry in T having its type. - DEBUG (std::cerr << "Live-out values:\n"); - for (LiveVariableVector::const_iterator I = LVV.begin (), E = LVV.end (); - I != E; ++I) { - DEBUG (WriteAsOperand (std::cerr, *I, true, true, - cast(*I)->getParent ()->getParent () - ->getParent ()); - std::cerr << " is at position " << Counter++ << "\n"); - T.push_back ((*I)->getType ()); - } - return PointerType::get (StructType::get (T)); -} - -/// createFunctionArgTypeVector - Given the live-in vector LVV of a trace, -/// create a parameter list containing a parameter for each of the -/// variables in LVV as well as a pointer-to-structure type PST to fill -/// in which contains the live-outs. -/// -TypeVector TraceFunctionBuilder::createFunctionArgTypeVector (PointerType *PST, - const LiveVariableVector &LVV) { +TypeVector TraceFunctionBuilder::createFunctionArgTypeVector (const LiveVariableVector &LiveIns, const LiveVariableVector &LiveOuts) { TypeVector P; - P.push_back (PST); - for (LiveVariableVector::const_iterator I = LVV.begin (), E = LVV.end (); - I != E; ++I) + for (LiveVariableVector::const_iterator I = LiveIns.begin (), + E = LiveIns.end (); I != E; ++I) P.push_back ((*I)->getType ()); + for (LiveVariableVector::const_iterator I = LiveOuts.begin (), + E = LiveOuts.end (); I != E; ++I) + P.push_back (PointerType::get ((*I)->getType ())); return P; } -/// giveNamesToFunctionArgs - Name the first argument of F "liveOut", -/// then name the remaining arguments of F according to LVV. As a -/// side effect, fills in the mapping between live-ins and arguments in -/// TF->LiveInToArgMap. +/// giveNamesToFunctionArgs - Name the beginning arguments of F according to +/// LiveIns, and name the remainder according to LiveOuts. As a side effect, +/// fills in the mapping between live-ins and arguments in TF->LiveInToArgMap, +/// and the mapping between live-outs and arguments in TF->LiveOutToArgMap. /// -void TraceFunctionBuilder::giveNamesToFunctionArgs (LiveVariableVector LVV, - Function *F) { +void TraceFunctionBuilder::giveNamesToFunctionArgs (const LiveVariableVector &LiveIns, const LiveVariableVector &LiveOuts, Function *F) { Function::aiterator argIterator = F->abegin (); unsigned argPosition = 0; - argIterator->setName ("liveOut"); // Arg 0 is always the live-out struct. - ++argPosition; - ++argIterator; - // Fill in & print out mapping of instructions producing live-ins to // args, and set arg names. - std::cerr << "\nLive-in values:\n"; - for (LiveVariableVector::iterator I = LVV.begin (), E = LVV.end (); I != E; - ++I) { + DEBUG (std::cerr << "\nLive-in values:\n"); + for (LiveVariableVector::const_iterator I = LiveIns.begin (), + E = LiveIns.end (); I != E; ++I) { Value *V = *I; - WriteAsOperand (std::cerr, *I, true, true, TF->MatrixFn->getParent ()); - std::cerr << " is argument # " << argPosition << " (%"; + DEBUG (WriteAsOperand (std::cerr, V, true, true, + TF->MatrixFn->getParent ()); + std::cerr << " is argument # " << argPosition << " (%"); TF->LiveInToArgMap[V] = &*argIterator; - std::string name (V->getName ()); if (name == "") name = "arg" + utostr (argPosition); argIterator->setName ("liveIn." + name); - std::cerr << argIterator->getName () << ")\n"; + DEBUG (std::cerr << argIterator->getName () << ")\n"); + ++argPosition; + ++argIterator; + } + DEBUG (std::cerr << "\n"); + + // Fill in & print out mapping of instructions producing live-outs to + // args, and set arg names. + DEBUG (std::cerr << "\nLive-out values:\n"); + for (LiveVariableVector::const_iterator I = LiveOuts.begin (), + E = LiveOuts.end (); I != E; ++I) { + Value *V = *I; + DEBUG (WriteAsOperand (std::cerr, V, true, true, + TF->MatrixFn->getParent ()); + std::cerr << " is argument # " << argPosition << " (%"); + TF->LiveOutToArgMap[V] = &*argIterator; + std::string name (V->getName ()); + if (name == "") + name = "arg" + utostr (argPosition); + argIterator->setName ("liveOut." + name); + DEBUG (std::cerr << argIterator->getName () << ")\n"); ++argPosition; ++argIterator; } + DEBUG (std::cerr << "\n"); } /// numberExitBranchesInTrace - Fill in M with pairs that map each @@ -720,23 +720,12 @@ TF->ReturnBlockForTraceExit[FB] = successor; // Add the getelementptr/store instruction pairs here that // correspond to each live-out variable. - unsigned Slot = 0; for (LiveVariableVector::iterator SI = So.begin (), SE = So.end (); - SI != SE; ++SI) { + SI != SE; ++SI) if (dominates (T, cast ((*SI))->getParent (), - BI->getParent ())) { - std::vector Index; - Index.push_back (Constant::getNullValue (Type::LongTy)); //long 0 - Index.push_back (ConstantUInt::get (Type::UIntTy, Slot));//uint Slot - GetElementPtrInst *GEP = - new GetElementPtrInst (&*F->abegin (), Index, - "liveOutP" + utostr (BranchNumber[BI]) - + "_" + utostr (i) + "_" + utostr (Slot)); - FB->getInstList ().push_back (GEP); - FB->getInstList ().push_back (new StoreInst (O2CMap[*SI], GEP)); - } - ++Slot; - } + BI->getParent ())) + FB->getInstList ().push_back + (new StoreInst (O2CMap[*SI], TF->LiveOutToArgMap[*SI])); // Make FB contain a return instruction that returns the // number of the taken exit-branch. Add it to the end of FB: FB->getInstList ().push_back @@ -838,9 +827,8 @@ // function. getTraceLiveInSet (LiveInSet, TF->LiveInVector, T); getTraceLiveOutSet (LiveOutSet, TF->LiveOutVector, T); - TypeVector P = - createFunctionArgTypeVector (createLiveOutType (TF->LiveOutVector), - TF->LiveInVector); + TypeVector P = createFunctionArgTypeVector (TF->LiveInVector, + TF->LiveOutVector); // Make a new internal Function with return type int and parameter // list P, in the same Module as the trace's parent function. @@ -848,7 +836,7 @@ TF->TraceFn = new Function (FunctionType::get (Type::UIntTy, P, false), GlobalValue::InternalLinkage, name, T.getModule ()); - giveNamesToFunctionArgs (TF->LiveInVector, TF->TraceFn); + giveNamesToFunctionArgs (TF->LiveInVector, TF->LiveOutVector, TF->TraceFn); fillInFunctionBody (T, TF->TraceFn, TF->LiveOutVector); return TF; } From gaeke at cs.uiuc.edu Wed Jul 7 22:21:07 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Wed Jul 7 22:21:07 2004 Subject: [llvm-commits] CVS: reopt/include/reopt/TraceToFunction.h Message-ID: <200407080320.WAA03769@kain.cs.uiuc.edu> Changes in directory reopt/include/reopt: TraceToFunction.h updated: 1.18 -> 1.19 --- Log message: Add LiveOutToArgMap. --- Diffs of the changes: (+3 -1) Index: reopt/include/reopt/TraceToFunction.h diff -u reopt/include/reopt/TraceToFunction.h:1.18 reopt/include/reopt/TraceToFunction.h:1.19 --- reopt/include/reopt/TraceToFunction.h:1.18 Wed Jul 7 14:11:24 2004 +++ reopt/include/reopt/TraceToFunction.h Wed Jul 7 22:19:57 2004 @@ -74,9 +74,11 @@ /// ValueMap O2CMap; - /// Map of Trace's live-in values in the MatrixFn --> arguments of TraceFn. + /// Map of Trace's live-in and live-out values in the MatrixFn --> + /// arguments of TraceFn. /// ValueMap LiveInToArgMap; + ValueMap LiveOutToArgMap; Value *getCorrespondingValue (const Value *V, bool preferLiveIn = true) { if (isa(V)) return const_cast (V); From lattner at cs.uiuc.edu Wed Jul 7 22:43:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Wed Jul 7 22:43:01 2004 Subject: [llvm-commits] CVS: llvm/Makefile.rules Message-ID: <200407080342.WAA10438@apoc.cs.uiuc.edu> Changes in directory llvm: Makefile.rules updated: 1.186 -> 1.187 --- Log message: Really, it is not necessary to recompile all files in a profile build every time! --- Diffs of the changes: (+1 -0) Index: llvm/Makefile.rules diff -u llvm/Makefile.rules:1.186 llvm/Makefile.rules:1.187 --- llvm/Makefile.rules:1.186 Tue Jun 8 13:52:45 2004 +++ llvm/Makefile.rules Wed Jul 7 22:42:20 2004 @@ -704,6 +704,7 @@ #--------------------------------------------------------- .PRECIOUS: $(BUILD_OBJ_DIR)/Depend/.dir $(BUILD_OBJ_DIR)/BytecodeObj/.dir .PRECIOUS: $(BUILD_OBJ_DIR)/Debug/.dir $(BUILD_OBJ_DIR)/Release/.dir +.PRECIOUS: $(BUILD_OBJ_DIR)/Profile/.dir # Create .lo files in the ObjectFiles directory from the .cpp and .c files... $(BUILD_OBJ_DIR)/Release/%.lo: %.cpp $(BUILD_OBJ_DIR)/Release/.dir From gaeke at cs.uiuc.edu Thu Jul 8 01:26:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Jul 8 01:26:01 2004 Subject: [llvm-commits] CVS: reopt/lib/README Message-ID: <200407080625.BAA23101@kain.cs.uiuc.edu> Changes in directory reopt/lib: README updated: 1.7 -> 1.8 --- Log message: Major update to README, including the new directories which have recently been added. --- Diffs of the changes: (+34 -4) Index: reopt/lib/README diff -u reopt/lib/README:1.7 reopt/lib/README:1.8 --- reopt/lib/README:1.7 Fri Apr 9 13:21:51 2004 +++ reopt/lib/README Thu Jul 8 01:25:19 2004 @@ -2,8 +2,18 @@ Field guide to Reoptimizer libraries ************************************ -This directory used to be in the llvm cvs module, at -llvm/lib/Reoptimizer. +This is where all of the Reoptimizer libraries live. As a historical +note, this directory used to be in the llvm cvs module, at +llvm/lib/Reoptimizer. Now it is the lib directory of the reopt cvs +module. + +Warning: Although we've tried to make sure that this project will build +on all LLVM-supported architectures, many of the libraries in the +following subdirectories will not link or function correctly on +non-Sparc architectures. Also please note that much of this code is +unmaintained or very lightly maintained, except for the Trace* +directories, ScratchMemory, LightWtProfiling, and Mapping +subdirectories. Inst - Joel Stanley's project. @@ -20,6 +30,7 @@ Trigger - Anand's OLD reoptimizer. + - Uses the Ball & Larus path profiling implementation (I think?). Mapping - Functions to query the mapping between LLVM Instructions and MachineInstrs @@ -45,11 +56,13 @@ - Anand's redesigned tracing framework. Uses first-level and second-level instrumentation. - This used to be in LightWtProfiling/Trigger. - - Also contains Brian's trace optimizer. + - Also contains the UnpackTraceFunction component of Brian's trace optimizer. + - Also contains the ValueAllocState register allocator mapping info extractor. - Portability notes: SecondTrigger - Depends on libcpc.h from Solaris - port to use PAPI. - - Unportable pointer size assumptions + - Unportable pointer size assumptions (change it to use uintptr_t instead + of uint64_t!) - Uses SPARC inline assembly. FirstTrigger - Uses SPARC inline assembly. @@ -74,3 +87,20 @@ - Portability notes: Supports SPARC binaries only. Should compile & link fine on X86. +TraceIO + - Trace reading/writing library. + - Requires bcreader, bcwriter libraries. + - Test program in tools/dumptrace. + +TraceJIT + - This is a copy of the target-independent JIT code from + llvm/lib/ExecutionEngine/JIT, which has been hacked up by Brian to + run passes for the trace optimizer on TraceFunctions (which are + output by the TraceToFunction library). + +TraceToFunction + - Pass written by Brian which turns Trace objects into Functions. + - Test program in tools/ttftest. + +Last updated $Date: 2004/07/08 06:25:19 $ + From gaeke at cs.uiuc.edu Thu Jul 8 02:15:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Jul 8 02:15:01 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceCache/TraceCache.cpp Message-ID: <200407080714.CAA11390@kain.cs.uiuc.edu> Changes in directory reopt/lib/TraceCache: TraceCache.cpp updated: 1.20 -> 1.21 --- Log message: Refactor duplicated code from various TraceCache constructors into init method. --- Diffs of the changes: (+18 -39) Index: reopt/lib/TraceCache/TraceCache.cpp diff -u reopt/lib/TraceCache/TraceCache.cpp:1.20 reopt/lib/TraceCache/TraceCache.cpp:1.21 --- reopt/lib/TraceCache/TraceCache.cpp:1.20 Fri Apr 23 16:25:12 2004 +++ reopt/lib/TraceCache/TraceCache.cpp Thu Jul 8 02:14:16 2004 @@ -21,57 +21,36 @@ using std::cerr; using namespace llvm; -TraceCache::TraceCache(int limitSize){ - mm = new MemoryManager(); - - assert(limitSize <= mm->getMemSize() && "can't allocate this large space"); +void TraceCache::init (int limitSize) { + assert (limitSize <= mm->getMemSize () && "can't allocate this large space"); limit = limitSize; - isLimitSet = true; currSize = 0; - - vm = new VirtualMem(); } -TraceCache::TraceCache(){ - mm = new MemoryManager(); - - isLimitSet = true; //making limit as the size of memory - currSize = 0; - limit = mm->getMemSize(); - - vm = new VirtualMem(); +TraceCache::TraceCache (int lim) + : vm (new VirtualMem), mm (new MemoryManager) { + init (lim); } -TraceCache::TraceCache(VirtualMem *vmem){ - mm = new MemoryManager(); - - isLimitSet = true; //making limit as the size of memory - currSize = 0; - limit = mm->getMemSize(); - - vm = vmem; +TraceCache::TraceCache () + : vm (new VirtualMem), mm (new MemoryManager) { + init (mm->getMemSize ()); } -TraceCache::TraceCache(unsigned int memSize, VirtualMem *vmem){ - mm = new MemoryManager(memSize); - - isLimitSet = true; //making limit as the size of memory - currSize = 0; - limit = mm->getMemSize(); - - vm = vmem; +TraceCache::TraceCache (VirtualMem *vmem) + : vm (vmem), mm (new MemoryManager) { + init (mm->getMemSize ()); } -TraceCache::TraceCache(void (*dfunc)(), unsigned int memSize, - VirtualMem *vmem){ - mm = new MemoryManager(dfunc, memSize); +TraceCache::TraceCache (unsigned int memSize, VirtualMem *vmem) + : vm (vmem), mm (new MemoryManager (memSize)) { + init (mm->getMemSize ()); +} - isLimitSet = true; //making limit as the size of memory - currSize = 0; - limit = mm->getMemSize(); - - vm = vmem; +TraceCache::TraceCache(void (*dfunc)(), unsigned int memSize, VirtualMem *vmem) + : vm (vmem), mm (new MemoryManager (dfunc, memSize)) { + init (mm->getMemSize ()); } void TraceCache::setLimit(int n) { From gaeke at cs.uiuc.edu Thu Jul 8 02:15:07 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Jul 8 02:15:07 2004 Subject: [llvm-commits] CVS: reopt/include/reopt/TraceCache.h Message-ID: <200407080714.CAA11384@kain.cs.uiuc.edu> Changes in directory reopt/include/reopt: TraceCache.h updated: 1.17 -> 1.18 --- Log message: Add prototype for private void init(int) method. --- Diffs of the changes: (+2 -0) Index: reopt/include/reopt/TraceCache.h diff -u reopt/include/reopt/TraceCache.h:1.17 reopt/include/reopt/TraceCache.h:1.18 --- reopt/include/reopt/TraceCache.h:1.17 Wed Nov 19 16:51:42 2003 +++ reopt/include/reopt/TraceCache.h Thu Jul 8 02:14:15 2004 @@ -37,6 +37,8 @@ int limit, currSize; + // common constructor code + void init (int limitSize); //gets addr of target in branch uint64_t getBranchAddr(const std::pair &n); //change every address in F pointing to frm to "to" From lattner at cs.uiuc.edu Thu Jul 8 02:27:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 8 02:27:00 2004 Subject: [llvm-commits] CVS: llvm/lib/Analysis/DataStructure/DataStructure.cpp Message-ID: <200407080726.CAA18723@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Analysis/DataStructure: DataStructure.cpp updated: 1.177 -> 1.178 --- Log message: Disable some code that isn't helping matters --- Diffs of the changes: (+6 -1) Index: llvm/lib/Analysis/DataStructure/DataStructure.cpp diff -u llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.177 llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.178 --- llvm/lib/Analysis/DataStructure/DataStructure.cpp:1.177 Wed Jul 7 01:32:21 2004 +++ llvm/lib/Analysis/DataStructure/DataStructure.cpp Thu Jul 8 02:25:51 2004 @@ -1589,20 +1589,25 @@ void DSGraph::removeTriviallyDeadNodes() { TIME_REGION(X, "removeTriviallyDeadNodes"); +#if 0 + /// NOTE: This code is disabled. This slows down DSA on 177.mesa + /// substantially! + // Loop over all of the nodes in the graph, calling getNode on each field. // This will cause all nodes to update their forwarding edges, causing // forwarded nodes to be delete-able. + { TIME_REGION(X, "removeTriviallyDeadNodes:node_iterate"); for (node_iterator NI = node_begin(), E = node_end(); NI != E; ++NI) { DSNode *N = *NI; for (unsigned l = 0, e = N->getNumLinks(); l != e; ++l) N->getLink(l*N->getPointerSize()).getNode(); } + } // NOTE: This code is disabled. Though it should, in theory, allow us to // remove more nodes down below, the scan of the scalar map is incredibly // expensive for certain programs (with large SCCs). In the future, if we can // make the scalar map scan more efficient, then we can reenable this. -#if 0 { TIME_REGION(X, "removeTriviallyDeadNodes:scalarmap"); // Likewise, forward any edges from the scalar nodes. While we are at it, From gaeke at cs.uiuc.edu Thu Jul 8 02:44:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Jul 8 02:44:01 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp ValueAllocState.cpp Message-ID: <200407080743.CAA04525@zion.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: UnpackTraceFunction.cpp updated: 1.91 -> 1.92 ValueAllocState.cpp updated: 1.4 -> 1.5 --- Log message: These two guys should be including --- Diffs of the changes: (+2 -0) Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.91 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.92 --- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.91 Tue Jul 6 21:19:51 2004 +++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Thu Jul 8 02:43:11 2004 @@ -28,6 +28,7 @@ #include "../../../../lib/Target/SparcV9/RegAlloc/AllocInfo.h" #include "../../../../lib/Target/SparcV9/SparcV9RegInfo.h" #include "../../../../lib/Target/SparcV9/SparcV9TargetMachine.h" +#include namespace llvm { Index: reopt/lib/LightWtProfiling/ValueAllocState.cpp diff -u reopt/lib/LightWtProfiling/ValueAllocState.cpp:1.4 reopt/lib/LightWtProfiling/ValueAllocState.cpp:1.5 --- reopt/lib/LightWtProfiling/ValueAllocState.cpp:1.4 Wed Jun 23 15:06:35 2004 +++ reopt/lib/LightWtProfiling/ValueAllocState.cpp Thu Jul 8 02:43:11 2004 @@ -22,6 +22,7 @@ #include "Support/Debug.h" #include "../../../../lib/Target/SparcV9/RegAlloc/AllocInfo.h" #include "../../../../lib/Target/SparcV9/RegAlloc/PhyRegAlloc.h" +#include namespace llvm { From gaeke at cs.uiuc.edu Thu Jul 8 03:04:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Jul 8 03:04:01 2004 Subject: [llvm-commits] CVS: reopt/include/reopt/TraceCache.h Message-ID: <200407080803.DAA01354@kain.cs.uiuc.edu> Changes in directory reopt/include/reopt: TraceCache.h updated: 1.18 -> 1.19 --- Log message: isLimitSet is always dynamically true. So get rid of it. --- Diffs of the changes: (+1 -3) Index: reopt/include/reopt/TraceCache.h diff -u reopt/include/reopt/TraceCache.h:1.18 reopt/include/reopt/TraceCache.h:1.19 --- reopt/include/reopt/TraceCache.h:1.18 Thu Jul 8 02:14:15 2004 +++ reopt/include/reopt/TraceCache.h Thu Jul 8 03:03:26 2004 @@ -33,8 +33,6 @@ std::list allocationOrder; - bool isLimitSet; //this must be set during initialization!!! - int limit, currSize; // common constructor code @@ -51,7 +49,7 @@ uint64_t getAddrLessThan(uint64_t brAddr); uint64_t getEndAddress(uint64_t addr); - bool hasMaxSize(){ return isLimitSet;} + bool hasMaxSize(){ return true; } bool hasTraceAddr(uint64_t n){ return (traces.find(n)!=traces.end()); } bool hasTraceAddr(uint64_t start, uint64_t end){ From gaeke at cs.uiuc.edu Thu Jul 8 03:04:06 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Jul 8 03:04:06 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceCache/TraceCache.cpp Message-ID: <200407080803.DAA01357@kain.cs.uiuc.edu> Changes in directory reopt/lib/TraceCache: TraceCache.cpp updated: 1.21 -> 1.22 --- Log message: isLimitSet is always dynamically true. So get rid of it. --- Diffs of the changes: (+4 -6) Index: reopt/lib/TraceCache/TraceCache.cpp diff -u reopt/lib/TraceCache/TraceCache.cpp:1.21 reopt/lib/TraceCache/TraceCache.cpp:1.22 --- reopt/lib/TraceCache/TraceCache.cpp:1.21 Thu Jul 8 02:14:16 2004 +++ reopt/lib/TraceCache/TraceCache.cpp Thu Jul 8 03:03:26 2004 @@ -24,7 +24,6 @@ void TraceCache::init (int limitSize) { assert (limitSize <= mm->getMemSize () && "can't allocate this large space"); limit = limitSize; - isLimitSet = true; currSize = 0; } @@ -54,7 +53,6 @@ } void TraceCache::setLimit(int n) { - assert(isLimitSet && "can't chage limit, if not set initially"); assert(currSize < n && "trying to set to a smaller limit than current size"); limit = n; } @@ -118,7 +116,7 @@ sz += 8; } - while(isLimitSet && currSize+sz>limit){ + while(currSize+sz>limit){ //assert(0 && "out of space"); @@ -270,7 +268,7 @@ int sz = trace.size(); - while(isLimitSet && currSize+sz>limit){ + while(currSize+sz>limit){ if(currSize == 0) return false; @@ -348,7 +346,7 @@ if(hasTraceAddr(instAddr)) removeTrace(instAddr); - while(isLimitSet && currSize+sz>limit){ + while(currSize+sz>limit){ if(currSize == 0) return false; @@ -430,7 +428,7 @@ sz = sz + 8; } - while(isLimitSet && currSize+sz>limit){ + while(currSize+sz>limit){ //assert(0 && "Can't allocate more mem!"); From gaeke at cs.uiuc.edu Thu Jul 8 03:27:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Jul 8 03:27:01 2004 Subject: [llvm-commits] CVS: reopt/include/reopt/TraceCache.h Message-ID: <200407080826.DAA08572@kain.cs.uiuc.edu> Changes in directory reopt/include/reopt: TraceCache.h updated: 1.19 -> 1.20 --- Log message: Remove a few dead methods. Make vm and mm data members private (they have accessors, after all.) --- Diffs of the changes: (+5 -10) Index: reopt/include/reopt/TraceCache.h diff -u reopt/include/reopt/TraceCache.h:1.19 reopt/include/reopt/TraceCache.h:1.20 --- reopt/include/reopt/TraceCache.h:1.19 Thu Jul 8 03:03:26 2004 +++ reopt/include/reopt/TraceCache.h Thu Jul 8 03:26:35 2004 @@ -19,8 +19,7 @@ class VirtualMem; class MemoryManager; -class TraceCache{ - private: +class TraceCache { std::map traces; //map from addr to addr std::map endAddress; //end of loop address std::map traceSize;//size of trace allocatted @@ -35,6 +34,9 @@ int limit, currSize; + VirtualMem *vm; + MemoryManager *mm; + // common constructor code void init (int limitSize); //gets addr of target in branch @@ -43,13 +45,8 @@ void changeAddr(uint64_t frm, uint64_t to); public: - void setLimit(int n); - int getLimit() { return limit;} - uint64_t getAddrLessThan(uint64_t brAddr); uint64_t getEndAddress(uint64_t addr); - - bool hasMaxSize(){ return true; } bool hasTraceAddr(uint64_t n){ return (traces.find(n)!=traces.end()); } bool hasTraceAddr(uint64_t start, uint64_t end){ @@ -135,11 +132,9 @@ //remove trace starting with address n void removeTrace(uint64_t n); + // accessor functions used by Joel's libraries MemoryManager* getMemMgr() { return mm; } VirtualMem* getVM() { return vm; } - - VirtualMem *vm; - MemoryManager *mm; }; } // end namespace llvm From gaeke at cs.uiuc.edu Thu Jul 8 03:28:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Jul 8 03:28:01 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceCache/TraceCache.cpp Message-ID: <200407080826.DAA08588@kain.cs.uiuc.edu> Changes in directory reopt/lib/TraceCache: TraceCache.cpp updated: 1.22 -> 1.23 --- Log message: Remove dead method. --- Diffs of the changes: (+0 -5) Index: reopt/lib/TraceCache/TraceCache.cpp diff -u reopt/lib/TraceCache/TraceCache.cpp:1.22 reopt/lib/TraceCache/TraceCache.cpp:1.23 --- reopt/lib/TraceCache/TraceCache.cpp:1.22 Thu Jul 8 03:03:26 2004 +++ reopt/lib/TraceCache/TraceCache.cpp Thu Jul 8 03:26:36 2004 @@ -52,11 +52,6 @@ init (mm->getMemSize ()); } -void TraceCache::setLimit(int n) { - assert(currSize < n && "trying to set to a smaller limit than current size"); - limit = n; -} - bool TraceCache::hasTraceInstructions(uint64_t addr){ return (traceInstructions.find(addr) != traceInstructions.end() && traceInstructions[addr].size()!=0); From alkis at cs.uiuc.edu Thu Jul 8 08:42:02 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu Jul 8 08:42:02 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/SingleSource/UnitTests/2002-05-19-DivTest.c Message-ID: <200407081341.IAA11855@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs/SingleSource/UnitTests: 2002-05-19-DivTest.c updated: 1.2 -> 1.3 --- Log message: Pass long longs to the testL function and use the ll modifier to print them with printf. Bug found by Vladimir Prus --- Diffs of the changes: (+3 -3) Index: llvm/test/Programs/SingleSource/UnitTests/2002-05-19-DivTest.c diff -u llvm/test/Programs/SingleSource/UnitTests/2002-05-19-DivTest.c:1.2 llvm/test/Programs/SingleSource/UnitTests/2002-05-19-DivTest.c:1.3 --- llvm/test/Programs/SingleSource/UnitTests/2002-05-19-DivTest.c:1.2 Mon Jul 7 17:46:59 2003 +++ llvm/test/Programs/SingleSource/UnitTests/2002-05-19-DivTest.c Thu Jul 8 08:41:21 2004 @@ -1,8 +1,8 @@ extern int printf(const char *, ...); -void testL(long Arg) { - printf("%ld\n", Arg / (1LL << 4)); - printf("%ld\n", Arg / (1LL << 46)); +void testL(long long Arg) { + printf("%lld\n", Arg / (1LL << 4)); + printf("%lld\n", Arg / (1LL << 46)); } void test(int Arg) { From lattner at cs.uiuc.edu Thu Jul 8 10:39:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 8 10:39:02 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/Assembler/ConstantExprFold.llx Message-ID: <200407081538.KAA19730@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Assembler: ConstantExprFold.llx updated: 1.1 -> 1.2 --- Log message: Fix this testcase --- Diffs of the changes: (+1 -1) Index: llvm/test/Regression/Assembler/ConstantExprFold.llx diff -u llvm/test/Regression/Assembler/ConstantExprFold.llx:1.1 llvm/test/Regression/Assembler/ConstantExprFold.llx:1.2 --- llvm/test/Regression/Assembler/ConstantExprFold.llx:1.1 Mon Jan 12 23:32:27 2004 +++ llvm/test/Regression/Assembler/ConstantExprFold.llx Thu Jul 8 10:38:23 2004 @@ -21,5 +21,5 @@ global bool setlt (long* %A, long* getelementptr (long* %A, long 0)) ; false global bool setlt (int* getelementptr (%Ty* %B, long 0, ubyte 0), int* getelementptr (%Ty* %B, long 0, ubyte 1)) ; true -global bool setne (long* %A, long* cast (%Ty* %B to long*)) ; true +;global bool setne (long* %A, long* cast (%Ty* %B to long*)) ; true From lattner at cs.uiuc.edu Thu Jul 8 10:42:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 8 10:42:02 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/Assembler/2004-04-04-GetElementPtrIndexTypes.ll Message-ID: <200407081541.KAA19753@apoc.cs.uiuc.edu> Changes in directory llvm/test/Regression/Assembler: 2004-04-04-GetElementPtrIndexTypes.ll added (r1.1) --- Log message: Add a test that I have had in my tree for several months now, but apparently forgot to commit --- Diffs of the changes: (+10 -0) Index: llvm/test/Regression/Assembler/2004-04-04-GetElementPtrIndexTypes.ll diff -c /dev/null llvm/test/Regression/Assembler/2004-04-04-GetElementPtrIndexTypes.ll:1.1 *** /dev/null Thu Jul 8 10:41:18 2004 --- llvm/test/Regression/Assembler/2004-04-04-GetElementPtrIndexTypes.ll Thu Jul 8 10:41:08 2004 *************** *** 0 **** --- 1,10 ---- + + + + int *%t1({ float, int }* %X) { + %W = getelementptr { float, int }* %X, int 20, ubyte 1 + %X = getelementptr { float, int }* %X, uint 20, uint 1 + %Y = getelementptr { float, int }* %X, long 20, ubyte 1 + %Z = getelementptr { float, int }* %X, ulong 20, uint 1 + ret int* %Y + } From lattner at cs.uiuc.edu Thu Jul 8 10:55:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 8 10:55:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/DerivedTypes.h Message-ID: <200407081554.KAA24754@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: DerivedTypes.h updated: 1.59 -> 1.60 --- Log message: This file uses the Value class without a forward decl --- Diffs of the changes: (+1 -0) Index: llvm/include/llvm/DerivedTypes.h diff -u llvm/include/llvm/DerivedTypes.h:1.59 llvm/include/llvm/DerivedTypes.h:1.60 --- llvm/include/llvm/DerivedTypes.h:1.59 Sun Jul 4 05:48:27 2004 +++ llvm/include/llvm/DerivedTypes.h Thu Jul 8 10:54:29 2004 @@ -22,6 +22,7 @@ namespace llvm { +class Value; template class TypeMap; class FunctionValType; class ArrayValType; From lattner at cs.uiuc.edu Thu Jul 8 11:10:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 8 11:10:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Type.h Message-ID: <200407081609.LAA09793@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Type.h updated: 1.47 -> 1.48 --- Log message: Update comment. Remove unused forward decl of Value.h Make Type 32 bytes instead of 36 bytes --- Diffs of the changes: (+4 -4) Index: llvm/include/llvm/Type.h diff -u llvm/include/llvm/Type.h:1.47 llvm/include/llvm/Type.h:1.48 --- llvm/include/llvm/Type.h:1.47 Sun Jul 4 05:46:49 2004 +++ llvm/include/llvm/Type.h Thu Jul 8 11:09:38 2004 @@ -15,7 +15,8 @@ // type is ever created. Thus seeing if two types are equal is a matter of // doing a trivial pointer comparison. // -// Types, once allocated, are never free'd. +// Types, once allocated, are never free'd, unless they are an abstract type +// that is resolved to a more concrete type. // // Opaque types are simple derived types with no state. There may be many // different Opaque type objects floating around, but two are only considered @@ -48,7 +49,6 @@ class PointerType; class StructType; class SymbolTable; -class Value; struct Type { ///===-------------------------------------------------------------------===// @@ -81,9 +81,9 @@ }; private: - TypeID ID; // The current base type of this type... - unsigned UID; // The unique ID number for this class + TypeID ID : 8; // The current base type of this type. bool Abstract; // True if type contains an OpaqueType + unsigned UID; // The unique ID number for this class /// RefCount - This counts the number of PATypeHolders that are pointing to /// this type. When this number falls to zero, if the type is abstract and From alkis at cs.uiuc.edu Thu Jul 8 11:20:02 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu Jul 8 11:20:02 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/External/SPEC/Makefile.spec Message-ID: <200407081619.LAA12840@zion.cs.uiuc.edu> Changes in directory llvm/test/Programs/External/SPEC: Makefile.spec updated: 1.31 -> 1.32 --- Log message: Add bugpoint-llc-ls and bugpoint-jit-ls targets for SPEC. --- Diffs of the changes: (+20 -5) Index: llvm/test/Programs/External/SPEC/Makefile.spec diff -u llvm/test/Programs/External/SPEC/Makefile.spec:1.31 llvm/test/Programs/External/SPEC/Makefile.spec:1.32 --- llvm/test/Programs/External/SPEC/Makefile.spec:1.31 Fri Apr 23 14:26:29 2004 +++ llvm/test/Programs/External/SPEC/Makefile.spec Thu Jul 8 11:19:42 2004 @@ -131,7 +131,8 @@ # Specify stdin, reference output, and command line options for the program... BUGPOINT_OPTIONS += -input=$(STDIN_FILENAME) -output=../$*.out-nat -BUGPOINT_OPTIONS += --args -- $(RUN_OPTIONS) +BUGPOINT_OPTIONS += --tool-args $(LLCFLAGS) +BUGPOINT_ARGS += --args -- $(RUN_OPTIONS) # Rules to bugpoint the GCCAS, GCCLD, LLC, or LLI commands... $(PROGRAMS_TO_TEST:%=Output/%.bugpoint-gccas): \ @@ -139,7 +140,7 @@ Output/gccas-pass-args Output/%.out-nat $(SPEC_SANDBOX) bugpoint-$(RUN_TYPE) $@ $(REF_IN_DIR) \ $(LBUGPOINT) ../../$< `cat Output/gccas-pass-args` $(OPTPASSES) \ - $(BUGPOINT_OPTIONS) + $(BUGPOINT_OPTIONS) $(BUGPOINT_ARGS) @echo "===> Leaving Output/bugpoint-$(RUN_TYPE)" $(PROGRAMS_TO_TEST:%=Output/%.bugpoint-gccld): \ @@ -147,19 +148,33 @@ Output/gccld-pass-args Output/%.out-nat $(SPEC_SANDBOX) bugpoint-$(RUN_TYPE) $@ $(REF_IN_DIR) \ $(LBUGPOINT) ../../$< `cat Output/gccld-pass-args` $(OPTPASSES) \ - $(BUGPOINT_OPTIONS) + $(BUGPOINT_OPTIONS) $(BUGPOINT_ARGS) @echo "===> Leaving Output/bugpoint-$(RUN_TYPE)" $(PROGRAMS_TO_TEST:%=Output/%.bugpoint-llc): \ Output/%.bugpoint-llc: Output/%.llvm.bc $(LBUGPOINT) Output/%.out-nat $(SPEC_SANDBOX) bugpoint-$(RUN_TYPE) $@ $(REF_IN_DIR) \ - $(LBUGPOINT) ../../$< -run-llc $(BUGPOINT_OPTIONS) + $(LBUGPOINT) ../../$< -run-llc $(BUGPOINT_OPTIONS) $(BUGPOINT_ARGS) + @echo "===> Leaving Output/bugpoint-$(RUN_TYPE)" + +$(PROGRAMS_TO_TEST:%=Output/%.bugpoint-llc-ls): \ +Output/%.bugpoint-llc-ls: Output/%.llvm.bc $(LBUGPOINT) Output/%.out-nat + $(SPEC_SANDBOX) bugpoint-$(RUN_TYPE) $@ $(REF_IN_DIR) \ + $(LBUGPOINT) ../../$< -run-llc $(BUGPOINT_OPTIONS) \ + -regalloc=linearscan $(BUGPOINT_ARGS) @echo "===> Leaving Output/bugpoint-$(RUN_TYPE)" $(PROGRAMS_TO_TEST:%=Output/%.bugpoint-jit): \ Output/%.bugpoint-jit: Output/%.llvm.bc $(LBUGPOINT) Output/%.out-nat $(SPEC_SANDBOX) bugpoint-$(RUN_TYPE) $@ $(REF_IN_DIR) \ - $(LBUGPOINT) ../../$< -run-jit $(BUGPOINT_OPTIONS) + $(LBUGPOINT) ../../$< -run-jit $(BUGPOINT_OPTIONS) $(BUGPOINT_ARGS) + @echo "===> Leaving Output/bugpoint-$(RUN_TYPE)" + +$(PROGRAMS_TO_TEST:%=Output/%.bugpoint-jit-ls): \ +Output/%.bugpoint-jit-ls: Output/%.llvm.bc $(LBUGPOINT) Output/%.out-nat + $(SPEC_SANDBOX) bugpoint-$(RUN_TYPE) $@ $(REF_IN_DIR) \ + $(LBUGPOINT) ../../$< -run-jit $(BUGPOINT_OPTIONS) \ + -regalloc=linearscan $(BUGPOINT_ARGS) @echo "===> Leaving Output/bugpoint-$(RUN_TYPE)" From lattner at cs.uiuc.edu Thu Jul 8 12:30:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 8 12:30:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Type.h Message-ID: <200407081729.MAA01674@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Type.h updated: 1.48 -> 1.49 --- Log message: isSigned/isUnsigned/isInteger methods do not need to be virtual --- Diffs of the changes: (+11 -7) Index: llvm/include/llvm/Type.h diff -u llvm/include/llvm/Type.h:1.48 llvm/include/llvm/Type.h:1.49 --- llvm/include/llvm/Type.h:1.48 Thu Jul 8 11:09:38 2004 +++ llvm/include/llvm/Type.h Thu Jul 8 12:29:36 2004 @@ -94,8 +94,7 @@ const Type *getForwardedTypeInternal() const; protected: - /// ctor is protected, so only subclasses can create Type objects... - Type(const std::string& Name, TypeID id ); + Type(const std::string& Name, TypeID id); virtual ~Type() {} @@ -158,19 +157,24 @@ /// true for SByteTy, ShortTy, IntTy, LongTy. Note that this is not true for /// Float and Double. /// - virtual bool isSigned() const { return 0; } + bool isSigned() const { + return ID == SByteTyID || ID == ShortTyID || + ID == IntTyID || ID == LongTyID; + } /// isUnsigned - Return whether a numeric type is unsigned. This is not quite /// the complement of isSigned... nonnumeric types return false as they do /// with isSigned. This returns true for UByteTy, UShortTy, UIntTy, and /// ULongTy /// - virtual bool isUnsigned() const { return 0; } + bool isUnsigned() const { + return ID == UByteTyID || ID == UShortTyID || + ID == UIntTyID || ID == ULongTyID; + } - /// isInteger - Equilivent to isSigned() || isUnsigned(), but with only a - /// single virtual function invocation. + /// isInteger - Equilivant to isSigned() || isUnsigned() /// - virtual bool isInteger() const { return 0; } + bool isInteger() const { return ID >= UByteTyID && ID <= LongTyID; } /// isIntegral - Returns true if this is an integral type, which is either /// BoolTy or one of the Integer types. From lattner at cs.uiuc.edu Thu Jul 8 12:31:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 8 12:31:01 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200407081730.MAA01697@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.107 -> 1.108 --- Log message: Eliminate the SignedType and UnsignedType classes. --- Diffs of the changes: (+19 -49) Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.107 llvm/lib/VMCore/Type.cpp:1.108 --- llvm/lib/VMCore/Type.cpp:1.107 Wed Jul 7 01:48:27 2004 +++ llvm/lib/VMCore/Type.cpp Thu Jul 8 12:30:07 2004 @@ -326,58 +326,28 @@ //===----------------------------------------------------------------------===// -// Auxiliary classes -//===----------------------------------------------------------------------===// -// -// These classes are used to implement specialized behavior for each different -// type. -// -struct SignedIntType : public Type { - SignedIntType(std::string name, TypeID id) : Type(name, id) {} - - // isSigned - Return whether a numeric type is signed. - virtual bool isSigned() const { return 1; } - - // isInteger - Equivalent to isSigned() || isUnsigned, but with only a single - // virtual function invocation. - // - virtual bool isInteger() const { return 1; } -}; - -struct UnsignedIntType : public Type { - UnsignedIntType(std::string name, TypeID id) : Type(name,id) {} - - // isUnsigned - Return whether a numeric type is signed. - virtual bool isUnsigned() const { return 1; } - - // isInteger - Equivalent to isSigned() || isUnsigned, but with only a single - // virtual function invocation. - // - virtual bool isInteger() const { return 1; } -}; - -struct OtherType : public Type { - OtherType(std::string name, TypeID id) : Type(name,id) {} -}; - - -//===----------------------------------------------------------------------===// // Static 'Type' data //===----------------------------------------------------------------------===// -static OtherType TheVoidTy ("void" , Type::VoidTyID); -static OtherType TheBoolTy ("bool" , Type::BoolTyID); -static SignedIntType TheSByteTy ("sbyte" , Type::SByteTyID); -static UnsignedIntType TheUByteTy ("ubyte" , Type::UByteTyID); -static SignedIntType TheShortTy ("short" , Type::ShortTyID); -static UnsignedIntType TheUShortTy("ushort", Type::UShortTyID); -static SignedIntType TheIntTy ("int" , Type::IntTyID); -static UnsignedIntType TheUIntTy ("uint" , Type::UIntTyID); -static SignedIntType TheLongTy ("long" , Type::LongTyID); -static UnsignedIntType TheULongTy ("ulong" , Type::ULongTyID); -static OtherType TheFloatTy ("float" , Type::FloatTyID); -static OtherType TheDoubleTy("double", Type::DoubleTyID); -static OtherType TheLabelTy ("label" , Type::LabelTyID); +namespace { + struct PrimType : public Type { + PrimType(const char *S, TypeID ID) : Type(S, ID) {} + }; +} + +static PrimType TheVoidTy ("void" , Type::VoidTyID); +static PrimType TheBoolTy ("bool" , Type::BoolTyID); +static PrimType TheSByteTy ("sbyte" , Type::SByteTyID); +static PrimType TheUByteTy ("ubyte" , Type::UByteTyID); +static PrimType TheShortTy ("short" , Type::ShortTyID); +static PrimType TheUShortTy("ushort", Type::UShortTyID); +static PrimType TheIntTy ("int" , Type::IntTyID); +static PrimType TheUIntTy ("uint" , Type::UIntTyID); +static PrimType TheLongTy ("long" , Type::LongTyID); +static PrimType TheULongTy ("ulong" , Type::ULongTyID); +static PrimType TheFloatTy ("float" , Type::FloatTyID); +static PrimType TheDoubleTy("double", Type::DoubleTyID); +static PrimType TheLabelTy ("label" , Type::LabelTyID); Type *Type::VoidTy = &TheVoidTy; Type *Type::BoolTy = &TheBoolTy; From alkis at cs.uiuc.edu Thu Jul 8 12:43:02 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu Jul 8 12:43:02 2004 Subject: [llvm-commits] CVS: llvm-java/tools/classdump/classdump.cpp Message-ID: <200407081742.MAA15199@zion.cs.uiuc.edu> Changes in directory llvm-java/tools/classdump: classdump.cpp updated: 1.10 -> 1.11 --- Log message: Parameter is no longer an input filename but an input classname. --- Diffs of the changes: (+2 -2) Index: llvm-java/tools/classdump/classdump.cpp diff -u llvm-java/tools/classdump/classdump.cpp:1.10 llvm-java/tools/classdump/classdump.cpp:1.11 --- llvm-java/tools/classdump/classdump.cpp:1.10 Tue Jul 6 08:31:34 2004 +++ llvm-java/tools/classdump/classdump.cpp Thu Jul 8 12:42:34 2004 @@ -22,7 +22,7 @@ using namespace llvm; static cl::opt -InputFilename(cl::Positional, cl::desc("")); +InputClass(cl::Positional, cl::desc("")); int main(int argc, char* argv[]) { @@ -31,7 +31,7 @@ "class dump utility"); try { - const Java::ClassFile* cf(Java::ClassFile::getClassFile(InputFilename)); + const Java::ClassFile* cf(Java::ClassFile::getClassFile(InputClass)); cf->dump(std::cout); } From alkis at cs.uiuc.edu Thu Jul 8 12:43:08 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu Jul 8 12:43:08 2004 Subject: [llvm-commits] CVS: llvm-java/tools/class2llvm/class2llvm.cpp Message-ID: <200407081742.MAA15206@zion.cs.uiuc.edu> Changes in directory llvm-java/tools/class2llvm: class2llvm.cpp updated: 1.8 -> 1.9 --- Log message: Parameter is no longer an input filename but an input classname. --- Diffs of the changes: (+3 -3) Index: llvm-java/tools/class2llvm/class2llvm.cpp diff -u llvm-java/tools/class2llvm/class2llvm.cpp:1.8 llvm-java/tools/class2llvm/class2llvm.cpp:1.9 --- llvm-java/tools/class2llvm/class2llvm.cpp:1.8 Tue Jul 6 08:31:34 2004 +++ llvm-java/tools/class2llvm/class2llvm.cpp Thu Jul 8 12:42:34 2004 @@ -25,7 +25,7 @@ using namespace llvm; static cl::opt -InputFilename(cl::Positional, cl::desc("")); +InputClass(cl::Positional, cl::desc("")); int main(int argc, char* argv[]) { @@ -34,11 +34,11 @@ "classfile to llvm utility"); try { - const Java::ClassFile* cf(Java::ClassFile::getClassFile(InputFilename)); + const Java::ClassFile* cf(Java::ClassFile::getClassFile(InputClass)); Java::Compiler compiler; - Module module(InputFilename); + Module module(InputClass); compiler.compile(module, *cf); PassManager passes; From brukman at cs.uiuc.edu Thu Jul 8 12:46:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Thu Jul 8 12:46:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Type.h Message-ID: <200407081745.MAA15294@zion.cs.uiuc.edu> Changes in directory llvm/include/llvm: Type.h updated: 1.49 -> 1.50 --- Log message: Fix spelling of `equivalent' --- Diffs of the changes: (+1 -1) Index: llvm/include/llvm/Type.h diff -u llvm/include/llvm/Type.h:1.49 llvm/include/llvm/Type.h:1.50 --- llvm/include/llvm/Type.h:1.49 Thu Jul 8 12:29:36 2004 +++ llvm/include/llvm/Type.h Thu Jul 8 12:45:18 2004 @@ -172,7 +172,7 @@ ID == UIntTyID || ID == ULongTyID; } - /// isInteger - Equilivant to isSigned() || isUnsigned() + /// isInteger - Equivalent to isSigned() || isUnsigned() /// bool isInteger() const { return ID >= UByteTyID && ID <= LongTyID; } From lattner at cs.uiuc.edu Thu Jul 8 12:50:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 8 12:50:01 2004 Subject: [llvm-commits] CVS: llvm/docs/ProgrammersManual.html Message-ID: <200407081749.MAA05389@apoc.cs.uiuc.edu> Changes in directory llvm/docs: ProgrammersManual.html updated: 1.64 -> 1.65 --- Log message: statisfy the spelling police --- Diffs of the changes: (+2 -3) Index: llvm/docs/ProgrammersManual.html diff -u llvm/docs/ProgrammersManual.html:1.64 llvm/docs/ProgrammersManual.html:1.65 --- llvm/docs/ProgrammersManual.html:1.64 Tue Jun 22 03:02:25 2004 +++ llvm/docs/ProgrammersManual.html Thu Jul 8 12:49:37 2004 @@ -1748,8 +1748,7 @@ return false as they do with isSigned. This returns true for UByteTy, UShortTy, UIntTy, and ULongTy. -
    8. bool isInteger() const: Equilivent to isSigned() || isUnsigned(), - but with only a single virtual function invocation.
    9. +
    10. bool isInteger() const: Equivalent to isSigned() || isUnsigned().
    11. bool isIntegral() const: Returns true if this is an integral type, which is either Bool type or one of the Integer types.
    12. @@ -2046,7 +2045,7 @@ Dinakar Dhurjati and Chris Lattner
      The LLVM Compiler Infrastructure
      - Last modified: $Date: 2004/06/22 08:02:25 $ + Last modified: $Date: 2004/07/08 17:49:37 $ From gaeke at cs.uiuc.edu Thu Jul 8 14:24:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Jul 8 14:24:01 2004 Subject: [llvm-commits] CVS: reopt/test/run-tests Message-ID: <200407081923.OAA16727@zion.cs.uiuc.edu> Changes in directory reopt/test: run-tests updated: 1.11 -> 1.12 --- Log message: Add -list option that shows which tests we know about. --- Diffs of the changes: (+8 -0) Index: reopt/test/run-tests diff -u reopt/test/run-tests:1.11 reopt/test/run-tests:1.12 --- reopt/test/run-tests:1.11 Tue Jul 6 21:19:52 2004 +++ reopt/test/run-tests Thu Jul 8 14:23:29 2004 @@ -24,11 +24,19 @@ -clean) action=clean ;; -debug) action=debug ;; -test) action=test ;; + -list) action=list ;; *) benchmk=$arg ;; esac done # sanity check arguments +if [ "$action" = "list" ]; then + echo "" + echo "SUPPORTED TESTS:" + echo "----------------" + grep SUBDIR= $0 | egrep -v '(exec|grep)' | sed 's/) / /' | sed 's/;.*$//' + exit 0 +fi if [ -z "$benchmk" ]; then die "Error: You must specify a benchmark." fi From gaeke at cs.uiuc.edu Thu Jul 8 14:26:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Jul 8 14:26:01 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceJIT/TraceJITGlobals.cpp Message-ID: <200407081925.OAA16866@zion.cs.uiuc.edu> Changes in directory reopt/lib/TraceJIT: TraceJITGlobals.cpp updated: 1.3 -> 1.4 --- Log message: Include . --- Diffs of the changes: (+1 -0) Index: reopt/lib/TraceJIT/TraceJITGlobals.cpp diff -u reopt/lib/TraceJIT/TraceJITGlobals.cpp:1.3 reopt/lib/TraceJIT/TraceJITGlobals.cpp:1.4 --- reopt/lib/TraceJIT/TraceJITGlobals.cpp:1.3 Wed Jun 30 01:33:12 2004 +++ reopt/lib/TraceJIT/TraceJITGlobals.cpp Thu Jul 8 14:25:06 2004 @@ -16,6 +16,7 @@ #include "reopt/TraceJIT.h" #include "llvm/Module.h" #include "Support/Debug.h" +#include using namespace llvm; struct InternalGlobalMap { From gaeke at cs.uiuc.edu Thu Jul 8 14:26:08 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Jul 8 14:26:08 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceToFunction/TraceToFunction.cpp Message-ID: <200407081925.OAA16871@zion.cs.uiuc.edu> Changes in directory reopt/lib/TraceToFunction: TraceToFunction.cpp updated: 1.73 -> 1.74 --- Log message: Include . --- Diffs of the changes: (+1 -0) Index: reopt/lib/TraceToFunction/TraceToFunction.cpp diff -u reopt/lib/TraceToFunction/TraceToFunction.cpp:1.73 reopt/lib/TraceToFunction/TraceToFunction.cpp:1.74 --- reopt/lib/TraceToFunction/TraceToFunction.cpp:1.73 Wed Jul 7 22:19:58 2004 +++ reopt/lib/TraceToFunction/TraceToFunction.cpp Thu Jul 8 14:25:06 2004 @@ -37,6 +37,7 @@ #define DEBUG_TYPE "tracetofunction" #include "Support/Debug.h" // for DEBUG() #include +#include namespace llvm { From gaeke at cs.uiuc.edu Thu Jul 8 14:35:02 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Jul 8 14:35:02 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceIO/TraceReader.cpp Message-ID: <200407081934.OAA17088@zion.cs.uiuc.edu> Changes in directory reopt/lib/TraceIO: TraceReader.cpp updated: 1.1 -> 1.2 --- Log message: Include . --- Diffs of the changes: (+1 -0) Index: reopt/lib/TraceIO/TraceReader.cpp diff -u reopt/lib/TraceIO/TraceReader.cpp:1.1 reopt/lib/TraceIO/TraceReader.cpp:1.2 --- reopt/lib/TraceIO/TraceReader.cpp:1.1 Wed Jun 30 01:33:18 2004 +++ reopt/lib/TraceIO/TraceReader.cpp Thu Jul 8 14:34:31 2004 @@ -5,6 +5,7 @@ #include "llvm/Module.h" #include #include +#include using namespace llvm; namespace llvm { From llvm at cs.uiuc.edu Thu Jul 8 14:37:02 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Thu Jul 8 14:37:02 2004 Subject: [llvm-commits] CVS: llvm/include/Support/SetVector.h Message-ID: <200407081936.OAA17110@zion.cs.uiuc.edu> Changes in directory llvm/include/Support: SetVector.h added (r1.1) --- Log message: First version of a vector with uniqueness constraints (or a set with deterministic, insertion-order iteration). --- Diffs of the changes: (+108 -0) Index: llvm/include/Support/SetVector.h diff -c /dev/null llvm/include/Support/SetVector.h:1.1 *** /dev/null Thu Jul 8 14:36:31 2004 --- llvm/include/Support/SetVector.h Thu Jul 8 14:36:21 2004 *************** *** 0 **** --- 1,108 ---- + //===- SetVector.h - A set with insertion order iteration -------*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by Reid Spencer and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file implements a set that has insertion order iteration + // characteristics. This is useful for keeping a set of things that need to be + // visited later but in a deterministic order (insertion order). The interface + // is purposefully minimal. + // + //===----------------------------------------------------------------------===// + + #ifndef SUPPORT_SETVECTOR_H + #define SUPPORT_SETVECTOR_H + + #include + #include + + namespace llvm { + + /// This class provides a way to keep a set of things that also has the + /// property of a deterministic iteration order. The order of iteration is the + /// order of insertion. + /// @breif A vector that has set insertion semantics. + template + class SetVector { + + public: + typedef T value_type; + typedef T key_type; + typedef T& reference; + typedef const T& const_reference; + typedef std::set set_type; + typedef std::vector vector_type; + typedef typename vector_type::iterator iterator; + typedef typename vector_type::const_iterator const_iterator; + typedef typename vector_type::size_type size_type; + + /// @brief Completely clear the SetVector + void clear() { + set_.clear(); + vector_.clear(); + } + + /// @brief Determine if the SetVector is empty or not. + bool empty() const { + return vector_.empty(); + } + + /// @brief Determine the number of elements in the SetVector. + size_type size() const { + return vector_.size(); + } + + /// @brief Get an iterator to the beginning of the SetVector. + iterator begin() { + return vector_.begin(); + } + + /// @brief Get a const_iterator to the beginning of the SetVector. + const_iterator begin() const { + return vector_.begin(); + } + + /// @brief Get an iterator to the end of the SetVector. + iterator end() { + return vector_.end(); + } + + /// @brief Get a const_iterator to the end of the SetVector. + const_iterator end() const { + return vector_.end(); + } + + /// @brief Index into the SetVector. + const_reference operator[](size_type n) const { + return vector_[n]; + } + + /// @returns true iff the element was inserted into the SetVector. + /// @brief Insert a new element into the SetVector. + bool insert( const value_type& X ) { + std::pair insertion_result = set_.insert(X); + if ( insertion_result.second ) { + vector_.push_back(X); + } + return insertion_result.second; + } + + /// @returns 0 if the element is not in the SetVector, 1 if it is. + /// @brief Count the number of elements of a given key in the SetVector. + size_type count( const key_type& key ) const { + return set_.count(key); + } + + private: + set_type set_; ///< The set. + vector_type vector_; ///< The vector. + }; + + } // End llvm namespace + + // vim: sw=2 ai + #endif From llvm at cs.uiuc.edu Thu Jul 8 16:51:02 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Thu Jul 8 16:51:02 2004 Subject: [llvm-commits] CVS: llvm/include/Support/SetVector.h Message-ID: <200407082150.QAA02495@zion.cs.uiuc.edu> Changes in directory llvm/include/Support: SetVector.h updated: 1.1 -> 1.2 --- Log message: Get rid of some cruft in the insert method. --- Diffs of the changes: (+3 -3) Index: llvm/include/Support/SetVector.h diff -u llvm/include/Support/SetVector.h:1.1 llvm/include/Support/SetVector.h:1.2 --- llvm/include/Support/SetVector.h:1.1 Thu Jul 8 14:36:21 2004 +++ llvm/include/Support/SetVector.h Thu Jul 8 16:50:33 2004 @@ -84,11 +84,11 @@ /// @returns true iff the element was inserted into the SetVector. /// @brief Insert a new element into the SetVector. bool insert( const value_type& X ) { - std::pair insertion_result = set_.insert(X); - if ( insertion_result.second ) { + bool result = set_.insert(X).second; + if ( result ) { vector_.push_back(X); } - return insertion_result.second; + return result; } /// @returns 0 if the element is not in the SetVector, 1 if it is. From lattner at cs.uiuc.edu Thu Jul 8 17:10:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 8 17:10:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Support/Mangler.cpp Message-ID: <200407082209.RAA14646@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Support: Mangler.cpp updated: 1.12 -> 1.13 --- Log message: Do not call Type::getUniqueID --- Diffs of the changes: (+12 -4) Index: llvm/lib/Support/Mangler.cpp diff -u llvm/lib/Support/Mangler.cpp:1.12 llvm/lib/Support/Mangler.cpp:1.13 --- llvm/lib/Support/Mangler.cpp:1.12 Tue Jul 6 15:29:05 2004 +++ llvm/lib/Support/Mangler.cpp Thu Jul 8 17:09:34 2004 @@ -46,6 +46,15 @@ return Result; } +/// getTypeID - Return a unique ID for the specified LLVM type. +/// +unsigned Mangler::getTypeID(const Type *Ty) { + unsigned &E = TypeMap[Ty]; + if (E == 0) E = ++TypeCounter; + return E; +} + + std::string Mangler::getValueName(const Value *V) { // Check to see whether we've already named V. ValueMap::iterator VI = Memo.find(V); @@ -71,12 +80,11 @@ } else { // Non-global, or global with internal linkage / colliding name // -> mangle. - unsigned TypeUniqueID = V->getType()->getUniqueID(); + unsigned TypeUniqueID = getTypeID(V->getType()); name = "l" + utostr(TypeUniqueID) + "_" + makeNameProper(V->getName()); } } else { - name = "ltmp_" + utostr(Count++) + "_" - + utostr(V->getType()->getUniqueID()); + name = "ltmp_" + utostr(Count++) + "_" + utostr(getTypeID(V->getType())); } Memo[V] = name; @@ -108,7 +116,7 @@ Mangler::Mangler(Module &m, bool addUnderscorePrefix) - : M(m), AddUnderscorePrefix(addUnderscorePrefix), Count(0) { + : M(m), AddUnderscorePrefix(addUnderscorePrefix), TypeCounter(0), Count(0) { // Calculate which global values have names that will collide when we throw // away type information. std::map Names; From lattner at cs.uiuc.edu Thu Jul 8 17:10:08 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 8 17:10:08 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Support/Mangler.h Message-ID: <200407082209.RAA13834@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Support: Mangler.h updated: 1.9 -> 1.10 --- Log message: Add a new method --- Diffs of the changes: (+8 -0) Index: llvm/include/llvm/Support/Mangler.h diff -u llvm/include/llvm/Support/Mangler.h:1.9 llvm/include/llvm/Support/Mangler.h:1.10 --- llvm/include/llvm/Support/Mangler.h:1.9 Fri Feb 13 18:30:31 2004 +++ llvm/include/llvm/Support/Mangler.h Thu Jul 8 17:09:07 2004 @@ -20,6 +20,7 @@ namespace llvm { class Value; +class Type; class Module; class GlobalValue; @@ -32,6 +33,9 @@ Module &M; bool AddUnderscorePrefix; + unsigned TypeCounter; + std::map TypeMap; + typedef std::map ValueMap; ValueMap Memo; @@ -44,6 +48,10 @@ // symbols will be prefixed with an underscore. Mangler(Module &M, bool AddUnderscorePrefix = false); + /// getTypeID - Return a unique ID for the specified LLVM type. + /// + unsigned getTypeID(const Type *Ty); + /// getValueName - Returns the mangled name of V, an LLVM Value, /// in the current module. /// From lattner at cs.uiuc.edu Thu Jul 8 17:32:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 8 17:32:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Type.h Message-ID: <200407082231.RAA01184@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Type.h updated: 1.50 -> 1.51 --- Log message: Eliminate the UID field in the Type class, bringing it down to 28 bytes. --- Diffs of the changes: (+1 -11) Index: llvm/include/llvm/Type.h diff -u llvm/include/llvm/Type.h:1.50 llvm/include/llvm/Type.h:1.51 --- llvm/include/llvm/Type.h:1.50 Thu Jul 8 12:45:18 2004 +++ llvm/include/llvm/Type.h Thu Jul 8 17:31:37 2004 @@ -83,7 +83,6 @@ private: TypeID ID : 8; // The current base type of this type. bool Abstract; // True if type contains an OpaqueType - unsigned UID; // The unique ID number for this class /// RefCount - This counts the number of PATypeHolders that are pointing to /// this type. When this number falls to zero, if the type is abstract and @@ -97,7 +96,6 @@ Type(const std::string& Name, TypeID id); virtual ~Type() {} - /// Types can become nonabstract later, if they are refined. /// inline void setAbstract(bool Val) { Abstract = Val; } @@ -143,13 +141,6 @@ /// inline TypeID getTypeID() const { return ID; } - /// getUniqueID - Returns the UID of the type. This can be thought of as a - /// small integer version of the pointer to the type class. Two types that - /// are structurally different have different UIDs. This can be used for - /// indexing types into an array. - /// - inline unsigned getUniqueID() const { return UID; } - /// getDescription - Return the string representation of the type... const std::string &getDescription() const; @@ -264,9 +255,8 @@ // instances of Type. // - /// getPrimitiveType/getUniqueIDType - Return a type based on an identifier. + /// getPrimitiveType - Return a type based on an identifier. static const Type *getPrimitiveType(TypeID IDNumber); - static const Type *getUniqueIDType(unsigned UID); //===--------------------------------------------------------------------===// // These are the builtin types that are always available... From lattner at cs.uiuc.edu Thu Jul 8 17:32:07 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 8 17:32:07 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200407082231.RAA01175@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.108 -> 1.109 --- Log message: The uid mapping is no more --- Diffs of the changes: (+1 -12) Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.108 llvm/lib/VMCore/Type.cpp:1.109 --- llvm/lib/VMCore/Type.cpp:1.108 Thu Jul 8 12:30:07 2004 +++ llvm/lib/VMCore/Type.cpp Thu Jul 8 17:31:09 2004 @@ -34,9 +34,6 @@ // Type Class Implementation //===----------------------------------------------------------------------===// -static unsigned CurUID = 0; -static std::vector UIDMappings; - // Concrete/Abstract TypeDescriptions - We lazily calculate type descriptions // for types as they are needed. Because resolution of types must invalidate // all of the abstract type descriptions, we keep them in a seperate map to make @@ -50,8 +47,6 @@ ConcreteTypeDescriptions[this] = name; ID = id; Abstract = false; - UID = CurUID++; // Assign types UID's as they are created - UIDMappings.push_back(this); } void Type::setName(const std::string &Name, SymbolTable *ST) { @@ -59,12 +54,6 @@ if (!Name.empty()) ST->insert(Name, this); } -const Type *Type::getUniqueIDType(unsigned UID) { - assert(UID < UIDMappings.size() && - "Type::getPrimitiveType: UID out of range!"); - return UIDMappings[UID]; -} - const Type *Type::getPrimitiveType(TypeID IDNumber) { switch (IDNumber) { case VoidTyID : return VoidTy; @@ -209,7 +198,7 @@ AbstractTypeDescriptions.lower_bound(Ty); if (I != AbstractTypeDescriptions.end() && I->first == Ty) return I->second; - std::string Desc = "opaque"+utostr(Ty->getUniqueID()); + std::string Desc = "opaque"; AbstractTypeDescriptions.insert(std::make_pair(Ty, Desc)); return Desc; } From lattner at cs.uiuc.edu Thu Jul 8 17:32:13 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Thu Jul 8 17:32:13 2004 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200407082231.RAA01160@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.170 -> 1.171 --- Log message: Eliminate uses of the UniqueID field on Type objects --- Diffs of the changes: (+18 -23) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.170 llvm/lib/AsmParser/llvmAsmParser.y:1.171 --- llvm/lib/AsmParser/llvmAsmParser.y:1.170 Sun Jul 4 07:19:05 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Thu Jul 8 17:30:50 2004 @@ -59,13 +59,13 @@ // destroyed when the function is completed. // typedef std::vector ValueList; // Numbered defs -static void ResolveDefinitions(std::map &LateResolvers, - std::map *FutureLateResolvers = 0); +static void ResolveDefinitions(std::map &LateResolvers, + std::map *FutureLateResolvers = 0); static struct PerModuleInfo { Module *CurrentModule; - std::map Values; // Module level numbered definitions - std::map LateResolveValues; + std::map Values; // Module level numbered definitions + std::map LateResolveValues; std::vector Types; std::map LateResolveTypes; @@ -146,8 +146,8 @@ static struct PerFunctionInfo { Function *CurrentFunction; // Pointer to current function being created - std::map Values; // Keep track of numbered definitions - std::map LateResolveValues; + std::map Values; // Keep track of #'d definitions + std::map LateResolveValues; std::vector Types; std::map LateResolveTypes; SymbolTable LocalSymtab; @@ -173,9 +173,8 @@ if (CurrentFunction->hasName()) { FID = ValID::create((char*)CurrentFunction->getName().c_str()); } else { - unsigned Slot = CurrentFunction->getType()->getUniqueID(); // Figure out which slot number if is... - ValueList &List = CurModule.Values[Slot]; + ValueList &List = CurModule.Values[CurrentFunction->getType()]; for (unsigned i = 0; ; ++i) { assert(i < List.size() && "Function not found!"); if (List[i] == CurrentFunction) { @@ -201,15 +200,13 @@ // Code to handle definitions of all the types //===----------------------------------------------------------------------===// -static int InsertValue(Value *D, - std::map &ValueTab = CurFun.Values) { - if (D->hasName()) return -1; // Is this a numbered definition? +static int InsertValue(Value *V, + std::map &ValueTab = CurFun.Values) { + if (V->hasName()) return -1; // Is this a numbered definition? // Yes, insert the value into the value table... - unsigned type = D->getType()->getUniqueID(); - //printf("Values[%d][%d] = %d\n", type, ValueTab[type].size(), D); - ValueList &List = ValueTab[type]; - List.push_back(D); + ValueList &List = ValueTab[V->getType()]; + List.push_back(V); return List.size()-1; } @@ -296,11 +293,10 @@ switch (D.Type) { case ValID::NumberVal: { // Is it a numbered definition? - unsigned type = Ty->getUniqueID(); unsigned Num = (unsigned)D.Num; // Module constants occupy the lowest numbered slots... - std::map::iterator VI = CurModule.Values.find(type); + std::map::iterator VI = CurModule.Values.find(Ty); if (VI != CurModule.Values.end()) { if (Num < VI->second.size()) return VI->second[Num]; @@ -308,7 +304,7 @@ } // Make sure that our type is within bounds - VI = CurFun.Values.find(type); + VI = CurFun.Values.find(Ty); if (VI == CurFun.Values.end()) return 0; // Check that the number is within bounds... @@ -418,10 +414,10 @@ // time (forward branches, phi functions for loops, etc...) resolve the // defs now... // -static void ResolveDefinitions(std::map &LateResolvers, - std::map *FutureLateResolvers) { +static void ResolveDefinitions(std::map &LateResolvers, + std::map *FutureLateResolvers) { // Loop over LateResolveDefs fixing up stuff that couldn't be resolved - for (std::map::iterator LRI = LateResolvers.begin(), + for (std::map::iterator LRI = LateResolvers.begin(), E = LateResolvers.end(); LRI != E; ++LRI) { ValueList &List = LRI->second; while (!List.empty()) { @@ -429,8 +425,7 @@ List.pop_back(); ValID &DID = getValIDFromPlaceHolder(V); - Value *TheRealValue = - getValNonImprovising(Type::getUniqueIDType(LRI->first), DID); + Value *TheRealValue = getValNonImprovising(LRI->first, DID); if (TheRealValue) { V->replaceAllUsesWith(TheRealValue); delete V; From gaeke at cs.uiuc.edu Thu Jul 8 17:53:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Jul 8 17:53:01 2004 Subject: [llvm-commits] CVS: llvm-www/demo/cathead.png Message-ID: <200407082252.RAA03145@zion.cs.uiuc.edu> Changes in directory llvm-www/demo: cathead.png updated: 1.2 -> 1.3 --- Log message: Older, wiser cat head --- Diffs of the changes: (+0 -0) Index: llvm-www/demo/cathead.png From gaeke at cs.uiuc.edu Thu Jul 8 19:00:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Jul 8 19:00:01 2004 Subject: [llvm-commits] CVS: llvm-www/demo/index.cgi Message-ID: <200407082359.SAA03553@zion.cs.uiuc.edu> Changes in directory llvm-www/demo: index.cgi updated: 1.24 -> 1.25 --- Log message: Don't squish kitty head --- Diffs of the changes: (+2 -2) Index: llvm-www/demo/index.cgi diff -u llvm-www/demo/index.cgi:1.24 llvm-www/demo/index.cgi:1.25 --- llvm-www/demo/index.cgi:1.24 Tue May 11 13:44:17 2004 +++ llvm-www/demo/index.cgi Thu Jul 8 18:59:02 2004 @@ -5,7 +5,7 @@ # doing remote web JO99C compilations. (It could still be used for that # purpose, though the two scripts have diverged somewhat.) # -# Last modified $Date: 2004/05/11 18:44:17 $ +# Last modified $Date: 2004/07/08 23:59:02 $ # use CGI; @@ -125,7 +125,7 @@ EOF if ($LOGO_IMAGE_URL) { - print ""; + print ""; } print < Changes in directory llvm-java/lib/ClassFile: ClassFile.cpp updated: 1.13 -> 1.14 --- Log message: Add map from name+descriptor to method for easy method lookup. --- Diffs of the changes: (+26 -1) Index: llvm-java/lib/ClassFile/ClassFile.cpp diff -u llvm-java/lib/ClassFile/ClassFile.cpp:1.13 llvm-java/lib/ClassFile/ClassFile.cpp:1.14 --- llvm-java/lib/ClassFile/ClassFile.cpp:1.13 Tue Jul 6 08:31:34 2004 +++ llvm-java/lib/ClassFile/ClassFile.cpp Thu Jul 8 19:00:26 2004 @@ -186,7 +186,7 @@ return filename; } - throw ClassFileSemanticError("Class " + classname + " not found"); + throw ClassNotFoundException("Class " + classname + " not found"); } const ClassFile* ClassFile::getClassFile(const std::string& classname) @@ -221,6 +221,17 @@ readFields(fields_, cPool_, is); readMethods(methods_, cPool_, is); readAttributes(attributes_, cPool_, is); + for (Methods::const_iterator + i = methods_.begin(), e = methods_.end(); i != e; ++i) + n2mMap_.insert( + std::make_pair( + (*i)->getName()->str() + (*i)->getDescriptor()->str(), *i)); +} + +const Method* ClassFile::getMethod(const std::string& nameAndDescr) const +{ + Name2MethodMap::const_iterator it = n2mMap_.find(nameAndDescr); + return it == n2mMap_.end() ? NULL : it->second; } ClassFile::~ClassFile() @@ -290,6 +301,20 @@ } //===----------------------------------------------------------------------===// +// ClassNotFoundException implementation +ClassNotFoundException::~ClassNotFoundException() throw() +{ + +} + +//===----------------------------------------------------------------------===// +// InvocationTargetException implementation +InvocationTargetException::~InvocationTargetException() throw() +{ + +} + +//===----------------------------------------------------------------------===// // Constant implementation Constant* Constant::readConstant(const ConstantPool& cp, std::istream& is) From alkis at cs.uiuc.edu Thu Jul 8 19:01:06 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu Jul 8 19:01:06 2004 Subject: [llvm-commits] CVS: llvm-java/include/llvm/Java/ClassFile.h Message-ID: <200407090000.TAA03671@zion.cs.uiuc.edu> Changes in directory llvm-java/include/llvm/Java: ClassFile.h updated: 1.13 -> 1.14 --- Log message: Add map from name+descriptor to method for easy method lookup. --- Diffs of the changes: (+22 -0) Index: llvm-java/include/llvm/Java/ClassFile.h diff -u llvm-java/include/llvm/Java/ClassFile.h:1.13 llvm-java/include/llvm/Java/ClassFile.h:1.14 --- llvm-java/include/llvm/Java/ClassFile.h:1.13 Tue Jul 6 08:31:35 2004 +++ llvm-java/include/llvm/Java/ClassFile.h Thu Jul 8 19:00:26 2004 @@ -16,6 +16,7 @@ #define LLVM_JAVA_CLASSFILE_H #include +#include #include #include @@ -65,6 +66,8 @@ static std::vector getClassPath(); static std::string getFileForClass(const std::string& classname); + typedef std::map Name2MethodMap; + public: static const ClassFile* getClassFile(const std::string& classname); @@ -92,6 +95,8 @@ const Attributes& getAttributes() const { return attributes_; } + const Method* getMethod(const std::string& nameAndDescr) const; + std::ostream& dump(std::ostream& os) const; private: @@ -105,6 +110,7 @@ Fields fields_; Methods methods_; Attributes attributes_; + Name2MethodMap n2mMap_; ClassFile(std::istream& is); }; @@ -453,6 +459,22 @@ virtual const char* what() const throw() { return msg_.c_str(); } }; + class ClassNotFoundException : public std::exception { + std::string msg_; + public: + explicit ClassNotFoundException(const std::string& msg) : msg_(msg) { } + virtual ~ClassNotFoundException() throw(); + virtual const char* what() const throw() { return msg_.c_str(); } + }; + + class InvocationTargetException : public std::exception { + std::string msg_; + public: + explicit InvocationTargetException(const std::string& msg) : msg_(msg) { } + virtual ~InvocationTargetException() throw(); + virtual const char* what() const throw() { return msg_.c_str(); } + }; + } } // namespace llvm::Java #endif//LLVM_JAVA_CLASSFILE_H From alkis at cs.uiuc.edu Thu Jul 8 19:04:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu Jul 8 19:04:01 2004 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200407090003.TAA03756@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.48 -> 1.49 --- Log message: Do not compile everything in a class. Compile main of the given class and then all methods called from that and so on until all methods are compiled. --- Diffs of the changes: (+48 -12) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.48 llvm-java/lib/Compiler/Compiler.cpp:1.49 --- llvm-java/lib/Compiler/Compiler.cpp:1.48 Tue Jul 6 08:21:40 2004 +++ llvm-java/lib/Compiler/Compiler.cpp Thu Jul 8 19:03:36 2004 @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -122,6 +123,8 @@ Locals locals_; BC2BBMap bc2bbMap_; BasicBlock* prologue_; + typedef SetVector FunctionSet; + FunctionSet toCompileFunctions_; private: BasicBlock* getBBAt(unsigned bcI) { return bc2bbMap_[bcI]; } @@ -211,11 +214,11 @@ return locals_[index]; } - public: - void compileMethod(Module& module, - const ClassFile& cf, - const Method& method) { - DEBUG(std::cerr << "compiling method: " + void compileMethodOnly(Module& module, + const ClassFile& cf, + const Method& method) { + + DEBUG(std::cerr << "Compiling method: " << method.getName()->str() << '\n'); module_ = &module; @@ -261,6 +264,42 @@ } } + public: + void compileMethod(Module& module, + const ClassFile& cf, + const Method& method) { + compileMethodOnly(module, cf, method); + bool done; + do { + done = true; + for (FunctionSet::iterator + i = toCompileFunctions_.begin(), + e = toCompileFunctions_.end(); + i != e; ++i) { + Function* f = *i; + if (f->isExternal()) { + done = false; + compileMethod(module, f->getName()); + } + } + } while (!done); + } + + void compileMethod(Module& module, const std::string& classMethodDesc) { + unsigned slash = classMethodDesc.find('/'); + std::string className = classMethodDesc.substr(0, slash); + std::string methodNameAndDescr = classMethodDesc.substr(slash+1); + + const ClassFile* classfile = ClassFile::getClassFile(className); + const Method* method = classfile->getMethod(methodNameAndDescr); + if (!method) + throw InvocationTargetException( + "Method " + methodNameAndDescr + + " not found in class " + className); + + compileMethod(module, *classfile, *method); + } + void do_aconst_null(unsigned bcI) { opStack_.push(llvm::Constant::getNullValue( PointerType::get(getType(REFERENCE)))); @@ -646,7 +685,7 @@ } void do_invokespecial(unsigned bcI, unsigned index) { - DEBUG(std::cerr << "ignoring INVOKESPECIAL\n"); + assert(0 && "not implemented"); } void do_invokestatic(unsigned bcI, unsigned index) { @@ -715,11 +754,8 @@ void Compiler::compile(Module& m, const ClassFile& cf) { - DEBUG(std::cerr << "compiling class: " - << cf.getThisClass()->getName()->str() << '\n'); + const std::string className = cf.getThisClass()->getName()->str(); + DEBUG(std::cerr << "Compiling class: " << className << '\n'); - const Java::Methods& methods = cf.getMethods(); - for (Java::Methods::const_iterator - i = methods.begin(), e = methods.end(); i != e; ++i) - compilerImpl_->compileMethod(m, cf, **i); + compilerImpl_->compileMethod(m, className + "/main([Ljava/lang/String;)I"); } From alkis at cs.uiuc.edu Thu Jul 8 19:07:00 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu Jul 8 19:07:00 2004 Subject: [llvm-commits] CVS: llvm-java/include/llvm/Java/Compiler.h Message-ID: <200407090006.TAA03798@zion.cs.uiuc.edu> Changes in directory llvm-java/include/llvm/Java: Compiler.h updated: 1.6 -> 1.7 --- Log message: Change Compiler interface so that only the classname of the class with the main() method is required. --- Diffs of the changes: (+1 -1) Index: llvm-java/include/llvm/Java/Compiler.h diff -u llvm-java/include/llvm/Java/Compiler.h:1.6 llvm-java/include/llvm/Java/Compiler.h:1.7 --- llvm-java/include/llvm/Java/Compiler.h:1.6 Fri Jul 2 05:44:49 2004 +++ llvm-java/include/llvm/Java/Compiler.h Thu Jul 8 19:06:30 2004 @@ -27,7 +27,7 @@ Compiler(); ~Compiler(); - void compile(Module& m, const ClassFile& cf); + void compile(Module& m, const std::string& className); private: // do not implement From alkis at cs.uiuc.edu Thu Jul 8 19:07:06 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu Jul 8 19:07:06 2004 Subject: [llvm-commits] CVS: llvm-java/tools/class2llvm/class2llvm.cpp Message-ID: <200407090006.TAA03784@zion.cs.uiuc.edu> Changes in directory llvm-java/tools/class2llvm: class2llvm.cpp updated: 1.9 -> 1.10 --- Log message: Change Compiler interface so that only the classname of the class with the main() method is required. --- Diffs of the changes: (+1 -3) Index: llvm-java/tools/class2llvm/class2llvm.cpp diff -u llvm-java/tools/class2llvm/class2llvm.cpp:1.9 llvm-java/tools/class2llvm/class2llvm.cpp:1.10 --- llvm-java/tools/class2llvm/class2llvm.cpp:1.9 Thu Jul 8 12:42:34 2004 +++ llvm-java/tools/class2llvm/class2llvm.cpp Thu Jul 8 19:06:30 2004 @@ -34,12 +34,10 @@ "classfile to llvm utility"); try { - const Java::ClassFile* cf(Java::ClassFile::getClassFile(InputClass)); - Java::Compiler compiler; Module module(InputClass); - compiler.compile(module, *cf); + compiler.compile(module, InputClass); PassManager passes; passes.add(new PrintModulePass(&std::cout)); From alkis at cs.uiuc.edu Thu Jul 8 19:08:04 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu Jul 8 19:08:04 2004 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200407090006.TAA03791@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.49 -> 1.50 --- Log message: Change Compiler interface so that only the classname of the class with the main() method is required. --- Diffs of the changes: (+1 -2) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.49 llvm-java/lib/Compiler/Compiler.cpp:1.50 --- llvm-java/lib/Compiler/Compiler.cpp:1.49 Thu Jul 8 19:03:36 2004 +++ llvm-java/lib/Compiler/Compiler.cpp Thu Jul 8 19:06:30 2004 @@ -752,9 +752,8 @@ delete compilerImpl_; } -void Compiler::compile(Module& m, const ClassFile& cf) +void Compiler::compile(Module& m, const std::string& className) { - const std::string className = cf.getThisClass()->getName()->str(); DEBUG(std::cerr << "Compiling class: " << className << '\n'); compilerImpl_->compileMethod(m, className + "/main([Ljava/lang/String;)I"); From alkis at cs.uiuc.edu Thu Jul 8 19:18:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu Jul 8 19:18:01 2004 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200407090017.TAA03882@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.50 -> 1.51 --- Log message: Fix bug. FunctionSet iterators are invalidated when compileMethod() inserts more Function*'s in the FunctionSet. Use indices to the vector instead. --- Diffs of the changes: (+2 -5) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.50 llvm-java/lib/Compiler/Compiler.cpp:1.51 --- llvm-java/lib/Compiler/Compiler.cpp:1.50 Thu Jul 8 19:06:30 2004 +++ llvm-java/lib/Compiler/Compiler.cpp Thu Jul 8 19:17:28 2004 @@ -272,11 +272,8 @@ bool done; do { done = true; - for (FunctionSet::iterator - i = toCompileFunctions_.begin(), - e = toCompileFunctions_.end(); - i != e; ++i) { - Function* f = *i; + for (unsigned i = 0; i != toCompileFunctions_.size(); ++i) { + Function* f = toCompileFunctions_[i]; if (f->isExternal()) { done = false; compileMethod(module, f->getName()); From alkis at cs.uiuc.edu Thu Jul 8 20:28:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Thu Jul 8 20:28:01 2004 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200407090126.UAA04143@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.51 -> 1.52 --- Log message: Simplify compilation logic. --- Diffs of the changes: (+6 -12) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.51 llvm-java/lib/Compiler/Compiler.cpp:1.52 --- llvm-java/lib/Compiler/Compiler.cpp:1.51 Thu Jul 8 19:17:28 2004 +++ llvm-java/lib/Compiler/Compiler.cpp Thu Jul 8 20:26:48 2004 @@ -269,19 +269,13 @@ const ClassFile& cf, const Method& method) { compileMethodOnly(module, cf, method); - bool done; - do { - done = true; - for (unsigned i = 0; i != toCompileFunctions_.size(); ++i) { - Function* f = toCompileFunctions_[i]; - if (f->isExternal()) { - done = false; - compileMethod(module, f->getName()); - } - } - } while (!done); - } + for (unsigned i = 0; i != toCompileFunctions_.size(); ++i) { + Function* f = toCompileFunctions_[i]; + compileMethod(module, f->getName()); + } + } += void compileMethod(Module& module, const std::string& classMethodDesc) { unsigned slash = classMethodDesc.find('/'); std::string className = classMethodDesc.substr(0, slash); From gaeke at cs.uiuc.edu Thu Jul 8 22:25:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Thu Jul 8 22:25:01 2004 Subject: [llvm-commits] CVS: llvm-www/demo/index.cgi Message-ID: <200407090324.WAA04569@zion.cs.uiuc.edu> Changes in directory llvm-www/demo: index.cgi updated: 1.25 -> 1.26 --- Log message: Fix typo --- Diffs of the changes: (+2 -2) Index: llvm-www/demo/index.cgi diff -u llvm-www/demo/index.cgi:1.25 llvm-www/demo/index.cgi:1.26 --- llvm-www/demo/index.cgi:1.25 Thu Jul 8 18:59:02 2004 +++ llvm-www/demo/index.cgi Thu Jul 8 22:24:32 2004 @@ -5,7 +5,7 @@ # doing remote web JO99C compilations. (It could still be used for that # purpose, though the two scripts have diverged somewhat.) # -# Last modified $Date: 2004/07/08 23:59:02 $ +# Last modified $Date: 2004/07/09 03:24:32 $ # use CGI; @@ -185,7 +185,7 @@ print "
      Type "; print -"

      Would you believe the cat even has a stopwatch? Click here to get detailed compilation statistic and timings from each pass.

        ", +"

        Would you believe the cat even has a stopwatch? Click here to get detailed compilation statistics and timings from each pass.

          ", $c->checkbox( -name => 'showstats', -label => 'Show detailed statistics' From lattner at cs.uiuc.edu Fri Jul 9 00:05:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Jul 9 00:05:03 2004 Subject: [llvm-commits] CVS: llvm/docs/GarbageCollection.html Message-ID: <200407090504.AAA25974@apoc.cs.uiuc.edu> Changes in directory llvm/docs: GarbageCollection.html updated: 1.5 -> 1.6 --- Log message: Fix Validation bugs --- Diffs of the changes: (+8 -3) Index: llvm/docs/GarbageCollection.html diff -u llvm/docs/GarbageCollection.html:1.5 llvm/docs/GarbageCollection.html:1.6 --- llvm/docs/GarbageCollection.html:1.5 Tue Jun 8 22:59:05 2004 +++ llvm/docs/GarbageCollection.html Fri Jul 9 00:03:54 2004 @@ -36,6 +36,7 @@
        • GC implementations available
        • +
          +

          Garbage collector implementations make use of call-back functions that are implemented by other parts of the LLVM system. +

          +
          @@ -460,7 +465,7 @@
          @@ -520,7 +525,7 @@ Chris Lattner
          LLVM Compiler Infrastructure
          - Last modified: $Date: 2004/06/09 03:59:05 $ + Last modified: $Date: 2004/07/09 05:03:54 $ From lattner at cs.uiuc.edu Fri Jul 9 00:07:03 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Jul 9 00:07:03 2004 Subject: [llvm-commits] CVS: llvm/docs/index.html Message-ID: <200407090505.AAA26006@apoc.cs.uiuc.edu> Changes in directory llvm/docs: index.html updated: 1.19 -> 1.20 --- Log message: Too much of a title for it's own good --- Diffs of the changes: (+3 -4) Index: llvm/docs/index.html diff -u llvm/docs/index.html:1.19 llvm/docs/index.html:1.20 --- llvm/docs/index.html:1.19 Thu Jul 1 12:20:53 2004 +++ llvm/docs/index.html Fri Jul 9 00:05:39 2004 @@ -2,12 +2,12 @@ "http://www.w3.org/TR/html4/strict.dtd"> - The LLVM Compiler Infrastructure documentation + Documentation for the LLVM System -
          The LLVM Compiler Infrastructure Documentation
          +
          Documentation for the LLVM System
            @@ -179,9 +179,8 @@ Valid HTML 4.01! - John Criswell
            LLVM Compiler Infrastructure
            - Last modified: $Date: 2004/07/01 17:20:53 $ + Last modified: $Date: 2004/07/09 05:05:39 $ From gaeke at cs.uiuc.edu Fri Jul 9 01:15:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Jul 9 01:15:01 2004 Subject: [llvm-commits] CVS: reopt/test/TTFTestHarness.pl Message-ID: <200407090614.BAA14873@kain.cs.uiuc.edu> Changes in directory reopt/test: TTFTestHarness.pl added (r1.1) --- Log message: So that I don't inadvertently blow this away, I'm checking it in. --- Diffs of the changes: (+80 -0) Index: reopt/test/TTFTestHarness.pl diff -c /dev/null reopt/test/TTFTestHarness.pl:1.1 *** /dev/null Fri Jul 9 01:14:42 2004 --- reopt/test/TTFTestHarness.pl Fri Jul 9 01:14:32 2004 *************** *** 0 **** --- 1,80 ---- + #!/usr/bin/perl + + $TTFTEST = "../Debug/ttftest"; + die "can't find ttftest" unless -x $TTFTEST; + + sub assembleBytecode { + my ($input, $output) = @_; + if (system ("llvm-as -f -o=$output $input $SQUELCH") == 0) { + if (-f $output) { + return 1; # ok + } + } + return 0; # fail + } + + sub runTest { + my ($trace, $bytecode) = @_; + print " $trace..."; + my $rc = system ("$TTFTEST -trace=$trace -bc=$bytecode $SQUELCH"); + if ($rc == 0) { + print "ok\n"; + return 0; + } else { + print "Fail\n"; + return 1; + } + } + + sub runTestsForModule { + my ($module) = @_; + my $base = $module; + if ($base =~ /\.ll$/) { + $base =~ s/\.ll$//; + } elsif ($base =~ /\.bc$/) { + $base =~ s/\.bc$//; + } else { + die "base is $base ?"; + } + my $bytecode = "${base}.bc"; + if (! -f $bytecode) { + assembleBytecode ($module, $bytecode); + if (! -f $bytecode) { + warn "Couldn't assemble $module\n"; + return 1; + } + } + print "${module}...\n"; + my $fail = 0; + foreach my $trace (<${base}*trace*.txt>) { + $fail += runTest ($trace, $bytecode); + } + print "$fail tests failed for $module\n"; + if ($module =~ /\.ll$/) { + unlink ($bytecode); + } + print "\n"; + return $fail; + } + + $| = 1; + if ($ARGV[0] eq '-v') { + $VERBOSE = 1; + $SQUELCH = ""; + shift @ARGV; + } else { + $VERBOSE = 0; + $SQUELCH = " > /dev/null 2>&1"; + } + my @tests = @ARGV; + if ($#tests == -1) { + #@tests = <*.ll>; + @tests = <*.bc>; + } + my ($ntests, $fail) = (0, 0); + foreach my $test (@tests) { + $fail += runTestsForModule ($test); + $ntests++; + } + print "$fail tests failed out of $ntests modules total\n"; + exit ($fail != 0); From lattner at cs.uiuc.edu Fri Jul 9 02:00:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Jul 9 02:00:02 2004 Subject: [llvm-commits] CVS: llvm/docs/ReleaseNotes.html Message-ID: <200407090658.BAA26345@apoc.cs.uiuc.edu> Changes in directory llvm/docs: ReleaseNotes.html updated: 1.212 -> 1.213 --- Log message: No really, he did finish! --- Diffs of the changes: (+2 -2) Index: llvm/docs/ReleaseNotes.html diff -u llvm/docs/ReleaseNotes.html:1.212 llvm/docs/ReleaseNotes.html:1.213 --- llvm/docs/ReleaseNotes.html:1.212 Wed Jul 7 16:06:28 2004 +++ llvm/docs/ReleaseNotes.html Fri Jul 9 01:58:43 2004 @@ -123,7 +123,7 @@ (values are not resolved from slot numbers). It should only be of interest to (a) those who are working to improve the bytecode format and (b) those who really want to understand or document the details of the bytecode format. -
          • The LLVM Bytecode file format is now being +
          • The LLVM Bytecode file format is now documented.
          • LLVM now provides an llvm.isunordered intrinsic for efficient @@ -750,7 +750,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!" /> The LLVM Compiler Infrastructure
            - Last modified: $Date: 2004/07/07 21:06:28 $ + Last modified: $Date: 2004/07/09 06:58:43 $ From alkis at cs.uiuc.edu Fri Jul 9 05:49:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Jul 9 05:49:01 2004 Subject: [llvm-commits] CVS: llvm-java/lib/Compiler/Compiler.cpp Message-ID: <200407091048.FAA31806@zion.cs.uiuc.edu> Changes in directory llvm-java/lib/Compiler: Compiler.cpp updated: 1.52 -> 1.53 --- Log message: I wonder how this ever compiled. --- Diffs of the changes: (+1 -1) Index: llvm-java/lib/Compiler/Compiler.cpp diff -u llvm-java/lib/Compiler/Compiler.cpp:1.52 llvm-java/lib/Compiler/Compiler.cpp:1.53 --- llvm-java/lib/Compiler/Compiler.cpp:1.52 Thu Jul 8 20:26:48 2004 +++ llvm-java/lib/Compiler/Compiler.cpp Fri Jul 9 05:48:38 2004 @@ -275,7 +275,7 @@ compileMethod(module, f->getName()); } } -= + void compileMethod(Module& module, const std::string& classMethodDesc) { unsigned slash = classMethodDesc.find('/'); std::string className = classMethodDesc.substr(0, slash); From alkis at cs.uiuc.edu Fri Jul 9 06:11:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Jul 9 06:11:01 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp Message-ID: <200407091110.GAA00826@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.86 -> 1.87 --- Log message: Improve code comments. --- Diffs of the changes: (+11 -5) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.86 llvm/lib/CodeGen/LiveIntervals.cpp:1.87 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.86 Tue Jul 6 21:03:12 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Fri Jul 9 06:10:00 2004 @@ -286,9 +286,9 @@ DEBUG(std::cerr << "\t\tregister: "; printRegName(interval.reg)); LiveVariables::VarInfo& vi = lv_->getVarInfo(interval.reg); - // iterate over all of the blocks that the variable is completely - // live in, adding them to the live interval. obviously we only - // need to do this once. + // Iterate over all of the blocks that the variable is completely + // live in, adding [insrtIndex(begin), instrIndex(end)+4) to the + // live interval. Obviously we only need to do this once. if (interval.empty()) { for (unsigned i = 0, e = vi.AliveBlocks.size(); i != e; ++i) { if (vi.AliveBlocks[i]) { @@ -337,6 +337,8 @@ MachineBasicBlock::iterator mi, LiveInterval& interval) { + // A physical register cannot be live across basic block, so its + // lifetime must end somewhere in its defining basic block. DEBUG(std::cerr << "\t\tregister: "; printRegName(interval.reg)); typedef LiveVariables::killed_iterator KillIter; @@ -345,7 +347,9 @@ unsigned start = getDefIndex(baseIndex); unsigned end = start; - // a variable can be dead by the instruction defining it + // If it is not used after definition, it is considered dead at + // the instruction defining it. Hence its interval is: + // [defSlot(def), defSlot(def)+1) for (KillIter ki = lv_->dead_begin(mi), ke = lv_->dead_end(mi); ki != ke; ++ki) { if (interval.reg == ki->second) { @@ -355,7 +359,9 @@ } } - // a variable can only be killed by subsequent instructions + // If it is not dead on definition, it must be killed by a + // subsequent instruction. Hence its interval is: + // [defSlot(def), useSlot(def)+1) do { ++mi; baseIndex += InstrSlots::NUM; From alkis at cs.uiuc.edu Fri Jul 9 06:26:01 2004 From: alkis at cs.uiuc.edu (Alkis Evlogimenos) Date: Fri Jul 9 06:26:01 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveIntervals.cpp Message-ID: <200407091125.GAA02382@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveIntervals.cpp updated: 1.87 -> 1.88 --- Log message: Fix typo. --- Diffs of the changes: (+1 -1) Index: llvm/lib/CodeGen/LiveIntervals.cpp diff -u llvm/lib/CodeGen/LiveIntervals.cpp:1.87 llvm/lib/CodeGen/LiveIntervals.cpp:1.88 --- llvm/lib/CodeGen/LiveIntervals.cpp:1.87 Fri Jul 9 06:10:00 2004 +++ llvm/lib/CodeGen/LiveIntervals.cpp Fri Jul 9 06:25:27 2004 @@ -361,7 +361,7 @@ // If it is not dead on definition, it must be killed by a // subsequent instruction. Hence its interval is: - // [defSlot(def), useSlot(def)+1) + // [defSlot(def), useSlot(kill)+1) do { ++mi; baseIndex += InstrSlots::NUM; From brukman at cs.uiuc.edu Fri Jul 9 09:46:01 2004 From: brukman at cs.uiuc.edu (Misha Brukman) Date: Fri Jul 9 09:46:01 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/MachineInstr.cpp Message-ID: <200407091445.JAA12842@zion.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: MachineInstr.cpp updated: 1.103 -> 1.104 --- Log message: * Doxygenify comments * Fix spacing, grammar in comment * Make code layout consistent * Wrap code at 80 cols * Delete spurious blank lines No functional changes. --- Diffs of the changes: (+95 -103) Index: llvm/lib/CodeGen/MachineInstr.cpp diff -u llvm/lib/CodeGen/MachineInstr.cpp:1.103 llvm/lib/CodeGen/MachineInstr.cpp:1.104 --- llvm/lib/CodeGen/MachineInstr.cpp:1.103 Sun Jul 4 07:19:56 2004 +++ llvm/lib/CodeGen/MachineInstr.cpp Fri Jul 9 09:45:17 2004 @@ -71,32 +71,31 @@ MBB->push_back(this); // Add instruction to end of basic block! } -///MachineInstr ctor - Copies MachineInstr arg exactly +/// MachineInstr ctor - Copies MachineInstr arg exactly +/// MachineInstr::MachineInstr(const MachineInstr &MI) { Opcode = MI.getOpcode(); numImplicitRefs = MI.getNumImplicitRefs(); operands.reserve(MI.getNumOperands()); - //Add operands - for(unsigned i=0; i < MI.getNumOperands(); ++i) + // Add operands + for (unsigned i = 0; i < MI.getNumOperands(); ++i) operands.push_back(MachineOperand(MI.getOperand(i))); - //Set parent, next, and prev to null + // Set parent, next, and prev to null parent = 0; prev = 0; next = 0; - } -MachineInstr::~MachineInstr() -{ +MachineInstr::~MachineInstr() { LeakDetector::removeGarbageObject(this); } -///clone - Create a copy of 'this' instruction that is identical in -///all ways except the following: The instruction has no parent The -///instruction has no name +/// clone - Create a copy of 'this' instruction that is identical in all ways +/// except the following: the new instruction has no parent and it has no name +/// MachineInstr* MachineInstr::clone() const { return new MachineInstr(*this); } @@ -120,7 +119,6 @@ Opcode = opcode; operands.clear(); operands.resize(numOperands, MachineOperand()); - } void MachineInstr::SetMachineOperandVal(unsigned i, @@ -189,26 +187,25 @@ if (!defsOnly || notDefsAndUses && (O.isDef() && !O.isUse()) || !notDefsAndUses && O.isDef()) - { - O.getMachineOperand().contents.value = newVal; - ++numSubst; - } - else + { + O.getMachineOperand().contents.value = newVal; + ++numSubst; + } else someArgsWereIgnored = true; // Substitute implicit refs - for (unsigned i=0, N=getNumImplicitRefs(); i < N; ++i) - if (getImplicitRef(i) == oldVal) + for (unsigned i = 0, N = getNumImplicitRefs(); i < N; ++i) + if (getImplicitRef(i) == oldVal) { + MachineOperand Op = getImplicitOp(i); if (!defsOnly || - notDefsAndUses && (getImplicitOp(i).isDef() && !getImplicitOp(i).isUse()) || - !notDefsAndUses && getImplicitOp(i).isDef()) - { - getImplicitOp(i).contents.value = newVal; - ++numSubst; - } - else + notDefsAndUses && (Op.isDef() && !Op.isUse()) || + !notDefsAndUses && Op.isDef()) + { + Op.contents.value = newVal; + ++numSubst; + } else someArgsWereIgnored = true; - + } return numSubst; } @@ -218,9 +215,9 @@ static inline std::ostream& OutputValue(std::ostream &os, const Value* val) { os << "(val "; - os << (void*) val; // print address always + os << (void*) val; // print address always if (val && val->hasName()) - os << " " << val->getName(); // print name also, if available + os << " " << val->getName(); // print name also, if available os << ")"; return os; } @@ -238,12 +235,9 @@ static void print(const MachineOperand &MO, std::ostream &OS, const TargetMachine *TM) { - - const MRegisterInfo *MRI = 0; - - if(TM) - MRI = TM->getRegisterInfo(); + const MRegisterInfo *MRI = 0; + if (TM) MRI = TM->getRegisterInfo(); bool CloseParen = true; if (MO.isHiBits32()) @@ -331,9 +325,9 @@ ++StartOp; // Don't print this operand again! } - //Must check if Target machine is not null because machine BB could not - //be attached to a Machine function yet - if(TM) + // Must check if Target machine is not null because machine BB could not + // be attached to a Machine function yet + if (TM) OS << TM->getInstrInfo()->getName(getOpcode()); for (unsigned i = StartOp, e = getNumOperands(); i != e; ++i) { @@ -353,14 +347,14 @@ // code for printing implicit references if (getNumImplicitRefs()) { OS << "\tImplicitRefs: "; - for(unsigned i = 0, e = getNumImplicitRefs(); i != e; ++i) { + for (unsigned i = 0, e = getNumImplicitRefs(); i != e; ++i) { OS << "\t"; OutputValue(OS, getImplicitRef(i)); if (getImplicitOp(i).isDef()) - if (getImplicitOp(i).isUse()) - OS << ""; - else - OS << ""; + if (getImplicitOp(i).isUse()) + OS << ""; + else + OS << ""; } } @@ -373,7 +367,7 @@ // info for the instruction. if (const MachineBasicBlock *MBB = MI.getParent()) { const MachineFunction *MF = MBB->getParent(); - if(MF) + if (MF) MI.print(os, &MF->getTarget()); else MI.print(os, 0); @@ -384,7 +378,7 @@ // and such. os << TargetInstrDescriptors[MI.getOpcode()].Name; - for (unsigned i=0, N=MI.getNumOperands(); i < N; i++) { + for (unsigned i = 0, N = MI.getNumOperands(); i < N; i++) { os << "\t" << MI.getOperand(i); if (MI.getOperand(i).isDef()) if (MI.getOperand(i).isUse()) @@ -397,7 +391,7 @@ unsigned NumOfImpRefs = MI.getNumImplicitRefs(); if (NumOfImpRefs > 0) { os << "\tImplicit: "; - for (unsigned z=0; z < NumOfImpRefs; z++) { + for (unsigned z = 0; z < NumOfImpRefs; z++) { OutputValue(os, MI.getImplicitRef(z)); if (MI.getImplicitOp(z).isDef()) if (MI.getImplicitOp(z).isUse()) @@ -421,68 +415,66 @@ else if (MO.isLoBits64()) OS << "%hm("; - switch (MO.getType()) - { - case MachineOperand::MO_VirtualRegister: - if (MO.hasAllocatedReg()) - OutputReg(OS, MO.getReg()); + switch (MO.getType()) { + case MachineOperand::MO_VirtualRegister: + if (MO.hasAllocatedReg()) + OutputReg(OS, MO.getReg()); - if (MO.getVRegValue()) { - if (MO.hasAllocatedReg()) OS << "=="; - OS << "%vreg"; - OutputValue(OS, MO.getVRegValue()); - } - break; - case MachineOperand::MO_CCRegister: - OS << "%ccreg"; + if (MO.getVRegValue()) { + if (MO.hasAllocatedReg()) OS << "=="; + OS << "%vreg"; OutputValue(OS, MO.getVRegValue()); - if (MO.hasAllocatedReg()) { - OS << "=="; - OutputReg(OS, MO.getReg()); - } - break; - case MachineOperand::MO_MachineRegister: - OutputReg(OS, MO.getMachineRegNum()); - break; - case MachineOperand::MO_SignExtendedImmed: - OS << (long)MO.getImmedValue(); - break; - case MachineOperand::MO_UnextendedImmed: - OS << (long)MO.getImmedValue(); - break; - case MachineOperand::MO_PCRelativeDisp: - { - const Value* opVal = MO.getVRegValue(); - bool isLabel = isa(opVal) || isa(opVal); - OS << "%disp(" << (isLabel? "label " : "addr-of-val "); - if (opVal->hasName()) - OS << opVal->getName(); - else - OS << (const void*) opVal; - OS << ")"; - break; - } - case MachineOperand::MO_MachineBasicBlock: - OS << "getBasicBlock())->getName() - << "@" << (void*)MO.getMachineBasicBlock() << ">"; - break; - case MachineOperand::MO_FrameIndex: - OS << ""; - break; - case MachineOperand::MO_ConstantPoolIndex: - OS << ""; - break; - case MachineOperand::MO_GlobalAddress: - OS << "getName() << ">"; - break; - case MachineOperand::MO_ExternalSymbol: - OS << ""; - break; - default: - assert(0 && "Unrecognized operand type"); - break; } + break; + case MachineOperand::MO_CCRegister: + OS << "%ccreg"; + OutputValue(OS, MO.getVRegValue()); + if (MO.hasAllocatedReg()) { + OS << "=="; + OutputReg(OS, MO.getReg()); + } + break; + case MachineOperand::MO_MachineRegister: + OutputReg(OS, MO.getMachineRegNum()); + break; + case MachineOperand::MO_SignExtendedImmed: + OS << (long)MO.getImmedValue(); + break; + case MachineOperand::MO_UnextendedImmed: + OS << (long)MO.getImmedValue(); + break; + case MachineOperand::MO_PCRelativeDisp: { + const Value* opVal = MO.getVRegValue(); + bool isLabel = isa(opVal) || isa(opVal); + OS << "%disp(" << (isLabel? "label " : "addr-of-val "); + if (opVal->hasName()) + OS << opVal->getName(); + else + OS << (const void*) opVal; + OS << ")"; + break; + } + case MachineOperand::MO_MachineBasicBlock: + OS << "getBasicBlock())->getName() + << "@" << (void*)MO.getMachineBasicBlock() << ">"; + break; + case MachineOperand::MO_FrameIndex: + OS << ""; + break; + case MachineOperand::MO_ConstantPoolIndex: + OS << ""; + break; + case MachineOperand::MO_GlobalAddress: + OS << "getName() << ">"; + break; + case MachineOperand::MO_ExternalSymbol: + OS << ""; + break; + default: + assert(0 && "Unrecognized operand type"); + break; + } if (MO.isHiBits32() || MO.isLoBits32() || MO.isHiBits64() || MO.isLoBits64()) OS << ")"; From lattner at cs.uiuc.edu Fri Jul 9 11:45:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Jul 9 11:45:01 2004 Subject: [llvm-commits] CVS: llvm/lib/CodeGen/LiveVariables.cpp Message-ID: <200407091644.LAA08474@apoc.cs.uiuc.edu> Changes in directory llvm/lib/CodeGen: LiveVariables.cpp updated: 1.36 -> 1.37 --- Log message: Add checks to ensure that there are no unreachable blocks in the function --- Diffs of the changes: (+8 -0) Index: llvm/lib/CodeGen/LiveVariables.cpp diff -u llvm/lib/CodeGen/LiveVariables.cpp:1.36 llvm/lib/CodeGen/LiveVariables.cpp:1.37 --- llvm/lib/CodeGen/LiveVariables.cpp:1.36 Thu Jul 1 01:15:32 2004 +++ llvm/lib/CodeGen/LiveVariables.cpp Fri Jul 9 11:44:37 2004 @@ -291,6 +291,14 @@ i + MRegisterInfo::FirstVirtualRegister)); } + // Check to make sure there are no unreachable blocks in the MC CFG for the + // function. If so, it is due to a bug in the instruction selector or some + // other part of the code generator if this happens. +#ifndef NDEBUG + for(MachineFunction::iterator i = MF.begin(), e = MF.end(); i != e; ++i) + assert(Visited.count(&*i) != 0 && "unreachable basic block found"); +#endif + return false; } From lattner at cs.uiuc.edu Fri Jul 9 11:45:09 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Jul 9 11:45:09 2004 Subject: [llvm-commits] CVS: llvm/lib/AsmParser/llvmAsmParser.y Message-ID: <200407091644.LAA07306@apoc.cs.uiuc.edu> Changes in directory llvm/lib/AsmParser: llvmAsmParser.y updated: 1.171 -> 1.172 --- Log message: Don't call Type::setName() --- Diffs of the changes: (+1 -1) Index: llvm/lib/AsmParser/llvmAsmParser.y diff -u llvm/lib/AsmParser/llvmAsmParser.y:1.171 llvm/lib/AsmParser/llvmAsmParser.y:1.172 --- llvm/lib/AsmParser/llvmAsmParser.y:1.171 Thu Jul 8 17:30:50 2004 +++ llvm/lib/AsmParser/llvmAsmParser.y Fri Jul 9 11:43:55 2004 @@ -610,7 +610,7 @@ } // Okay, its a newly named type. Set its name. - T->setName(Name,&ST); + if (!Name.empty()) ST.insert(Name, T); // If we're in function scope if (inFunctionScope()) { From lattner at cs.uiuc.edu Fri Jul 9 11:49:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Jul 9 11:49:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Type.h Message-ID: <200407091648.LAA14453@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Type.h updated: 1.51 -> 1.52 --- Log message: Remove unused method --- Diffs of the changes: (+0 -5) Index: llvm/include/llvm/Type.h diff -u llvm/include/llvm/Type.h:1.51 llvm/include/llvm/Type.h:1.52 --- llvm/include/llvm/Type.h:1.51 Thu Jul 8 17:31:37 2004 +++ llvm/include/llvm/Type.h Fri Jul 9 11:48:13 2004 @@ -126,11 +126,6 @@ /// @brief Debugging support: print to stderr virtual void dump() const; - /// setName - Associate the name with this type in the symbol table, but don't - /// set the local name to be equal specified name. - /// - virtual void setName(const std::string &Name, SymbolTable *ST = 0); - //===--------------------------------------------------------------------===// // Property accessors for dealing with types... Some of these virtual methods // are defined in private classes defined in Type.cpp for primitive types. From lattner at cs.uiuc.edu Fri Jul 9 11:49:07 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Jul 9 11:49:07 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Type.cpp Message-ID: <200407091648.LAA14068@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Type.cpp updated: 1.109 -> 1.110 --- Log message: Remove unused method --- Diffs of the changes: (+0 -5) Index: llvm/lib/VMCore/Type.cpp diff -u llvm/lib/VMCore/Type.cpp:1.109 llvm/lib/VMCore/Type.cpp:1.110 --- llvm/lib/VMCore/Type.cpp:1.109 Thu Jul 8 17:31:09 2004 +++ llvm/lib/VMCore/Type.cpp Fri Jul 9 11:47:54 2004 @@ -49,11 +49,6 @@ Abstract = false; } -void Type::setName(const std::string &Name, SymbolTable *ST) { - assert(ST && "Type::setName - Must provide symbol table argument!"); - if (!Name.empty()) ST->insert(Name, this); -} - const Type *Type::getPrimitiveType(TypeID IDNumber) { switch (IDNumber) { case VoidTyID : return VoidTy; From lattner at cs.uiuc.edu Fri Jul 9 12:04:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Fri Jul 9 12:04:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Type.h Message-ID: <200407091703.MAA05464@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: Type.h updated: 1.52 -> 1.53 --- Log message: Removed unneeded forward decl --- Diffs of the changes: (+0 -1) Index: llvm/include/llvm/Type.h diff -u llvm/include/llvm/Type.h:1.52 llvm/include/llvm/Type.h:1.53 --- llvm/include/llvm/Type.h:1.52 Fri Jul 9 11:48:13 2004 +++ llvm/include/llvm/Type.h Fri Jul 9 12:02:57 2004 @@ -48,7 +48,6 @@ class OpaqueType; class PointerType; class StructType; -class SymbolTable; struct Type { ///===-------------------------------------------------------------------===// From gaeke at cs.uiuc.edu Fri Jul 9 14:42:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Jul 9 14:42:01 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp ValueAllocState.cpp Message-ID: <200407091941.OAA19072@kain.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: UnpackTraceFunction.cpp updated: 1.92 -> 1.93 ValueAllocState.cpp updated: 1.5 -> 1.6 --- Log message: Key the Return Block for Trace Exit map on return instructions, not the basic blocks that they happen to be in, because it is possible for the CFG to change, and it seems to me more likely that a return instruction would end up in a different basic block than for it to be destroyed and replaced with a new one. getFunctionArg is history, having no more users. --- Diffs of the changes: (+10 -8) Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.92 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.93 --- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.92 Thu Jul 8 02:43:11 2004 +++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Fri Jul 9 14:41:27 2004 @@ -22,6 +22,7 @@ #include "llvm/Support/CFG.h" #include "llvm/Module.h" #include "llvm/iPHINode.h" +#include "llvm/iTerminators.h" #include "llvm/Assembly/Writer.h" #include "Support/StringExtras.h" // for utostr() #include "Support/Debug.h" @@ -407,10 +408,11 @@ MBB.clear (); // Find the BasicBlock in MatrixFn that this block's return instr. - // would have returned to, by consulting our mapping information. - // FIXME: Currently we key our mapping info on TraceFn basic blocks. - // This is fragile - we should use ReturnInsts instead, I think. - const BasicBlock *RBB = TF->ReturnBlockForTraceExit[MBB.getBasicBlock ()]; + // would have returned to, by consulting the mapping information + // generated by TraceFunctionBuilder. + const ReturnInst *RI = + cast (MBB.getBasicBlock ()->getTerminator ()); + const BasicBlock *RBB = TF->ReturnBlockForTraceExit[RI]; assert (RBB && "Can't find matrix fn BB address to return to from trace"); DEBUG (std::cerr << "rewriteEpilog: Return block for trace exit path is:\n" << *RBB << "\n"); @@ -538,8 +540,8 @@ // that are known to the SparcV9 backend. StaticStackSize = getStaticStackSize (MF); TotalStackSize = (StaticStackSize + 176 + 104 * 8); - DEBUG(std::cerr << "rewriteProlog: Stack sizes: static = " << StaticStackSize - << ", total = " << TotalStackSize << "\n"); + DEBUG(std::cerr << "UnpackTraceFunction: Stack sizes: static = " + << StaticStackSize << ", total = " << TotalStackSize << "\n"); // Rewrite function prolog, found in the entry MachineBasicBlock of MF rewriteProlog (MF, MF.front ()); @@ -547,7 +549,7 @@ // Rewrite function epilogs, found in every exit MachineBasicBlock of MF for (MachineFunction::iterator I = MF.begin (), E = MF.end (); I != E; ++I) { MachineBasicBlock &MBB = *I; - if (const MachineInstr *RI = containsReturnInstr (MBB)) + if (containsReturnInstr (MBB)) rewriteEpilog (MF, MBB); } Index: reopt/lib/LightWtProfiling/ValueAllocState.cpp diff -u reopt/lib/LightWtProfiling/ValueAllocState.cpp:1.5 reopt/lib/LightWtProfiling/ValueAllocState.cpp:1.6 --- reopt/lib/LightWtProfiling/ValueAllocState.cpp:1.5 Thu Jul 8 02:43:11 2004 +++ reopt/lib/LightWtProfiling/ValueAllocState.cpp Fri Jul 9 14:41:27 2004 @@ -91,7 +91,7 @@ static void findTraceBoundaryBlocks (TraceFunction *TF) { TraceBoundaryBlocks.clear (); TraceBoundaryBlocks.insert (TF->T.getEntryBasicBlock ()); - for (BasicBlockMap::iterator i = TF->ReturnBlockForTraceExit.begin (), + for (ReturnBlockMap::iterator i = TF->ReturnBlockForTraceExit.begin (), e = TF->ReturnBlockForTraceExit.end (); i != e; ++i) { TraceBoundaryBlocks.insert (i->second); } From gaeke at cs.uiuc.edu Fri Jul 9 14:42:09 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Jul 9 14:42:09 2004 Subject: [llvm-commits] CVS: reopt/include/reopt/TraceToFunction.h Message-ID: <200407091941.OAA19061@kain.cs.uiuc.edu> Changes in directory reopt/include/reopt: TraceToFunction.h updated: 1.19 -> 1.20 --- Log message: Key the Return Block for Trace Exit map on return instructions, not the basic blocks that they happen to be in, because it is possible for the CFG to change, and it seems to me more likely that a return instruction would end up in a different basic block than for it to be destroyed and replaced with a new one. getFunctionArg is history, having no more users. --- Diffs of the changes: (+5 -11) Index: reopt/include/reopt/TraceToFunction.h diff -u reopt/include/reopt/TraceToFunction.h:1.19 reopt/include/reopt/TraceToFunction.h:1.20 --- reopt/include/reopt/TraceToFunction.h:1.19 Wed Jul 7 22:19:57 2004 +++ reopt/include/reopt/TraceToFunction.h Fri Jul 9 14:41:27 2004 @@ -15,20 +15,14 @@ namespace llvm { +class ReturnInst; + typedef std::set LiveVariableSet; typedef std::vector LiveVariableVector; -typedef std::map BasicBlockMap; +typedef std::map ReturnBlockMap; typedef std::map ValueMap; typedef std::map ValueToIntMap; -/// getFunctionArg - Return a pointer to F's ARGNOth argument. -/// -static inline Argument *getFunctionArg (Function *F, unsigned argno) { - Function::aiterator ai = F->abegin (); - while (argno) { ++ai; --argno; } - return &*ai; -} - // This class encapsulates all the TraceToFunction algorithm's saved baggage. // You can't have a TraceFunction without a Trace, but you might be able to // get away with using a Trace instead of this class in new code. @@ -65,10 +59,10 @@ /// static TraceFunction *get (Trace &T); - /// Map of basic blocks containing return instructions in TraceFn --> + /// Map of return instructions in TraceFn --> /// basic blocks that they are supposed to return to in MatrixFn. /// - BasicBlockMap ReturnBlockForTraceExit; + ReturnBlockMap ReturnBlockForTraceExit; /// Map of original values in MatrixFn --> clones in TraceFn. /// From gaeke at cs.uiuc.edu Fri Jul 9 14:43:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Jul 9 14:43:01 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceToFunction/TraceToFunction.cpp Message-ID: <200407091941.OAA19077@kain.cs.uiuc.edu> Changes in directory reopt/lib/TraceToFunction: TraceToFunction.cpp updated: 1.74 -> 1.75 --- Log message: Key the Return Block for Trace Exit map on return instructions, not the basic blocks that they happen to be in, because it is possible for the CFG to change, and it seems to me more likely that a return instruction would end up in a different basic block than for it to be destroyed and replaced with a new one. getFunctionArg is history, having no more users. --- Diffs of the changes: (+7 -7) Index: reopt/lib/TraceToFunction/TraceToFunction.cpp diff -u reopt/lib/TraceToFunction/TraceToFunction.cpp:1.74 reopt/lib/TraceToFunction/TraceToFunction.cpp:1.75 --- reopt/lib/TraceToFunction/TraceToFunction.cpp:1.74 Thu Jul 8 14:25:06 2004 +++ reopt/lib/TraceToFunction/TraceToFunction.cpp Fri Jul 9 14:41:27 2004 @@ -716,9 +716,6 @@ BasicBlock *FB = new BasicBlock (name, F); // Remember to change BI's clone's destination to FB. newSuccessor = FB; - // Remember that FB's "return" instruction would involve a - // return to the off-trace successor we just found. - TF->ReturnBlockForTraceExit[FB] = successor; // Add the getelementptr/store instruction pairs here that // correspond to each live-out variable. for (LiveVariableVector::iterator SI = So.begin (), SE = So.end (); @@ -729,9 +726,12 @@ (new StoreInst (O2CMap[*SI], TF->LiveOutToArgMap[*SI])); // Make FB contain a return instruction that returns the // number of the taken exit-branch. Add it to the end of FB: - FB->getInstList ().push_back - (new ReturnInst (ConstantUInt::get (Type::UIntTy, - BranchNumber[BI]))); + ReturnInst *RI = new ReturnInst (ConstantUInt::get (Type::UIntTy, + BranchNumber[BI])); + FB->getInstList ().push_back (RI); + // Remember that FB's "return" instruction would involve a + // return to the off-trace successor we just found. + TF->ReturnBlockForTraceExit[RI] = successor; } else { // This is a non-trace-exiting destination of branch BI. Fix up // its clone's destination to point to its successor's clone. @@ -744,7 +744,7 @@ << " of trace-exiting branch instruction:\n" << *BIinF << " from " << BIinF->getSuccessor(i)->getName () << " to " << newSuccessor->getName () << "\n"); - BIinF->setSuccessor (i, newSuccessor); + BIinF->setSuccessor (i, newSuccessor); } } From gaeke at cs.uiuc.edu Fri Jul 9 15:56:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Jul 9 15:56:01 2004 Subject: [llvm-commits] CVS: reopt/include/reopt/UnpackTraceFunction.h Message-ID: <200407092055.PAA19990@kain.cs.uiuc.edu> Changes in directory reopt/include/reopt: UnpackTraceFunction.h updated: 1.10 -> 1.11 --- Log message: Make some decls shorter by removing excess whitespace. Add decl. of eliminatePhiAtTraceExit. --- Diffs of the changes: (+6 -5) Index: reopt/include/reopt/UnpackTraceFunction.h diff -u reopt/include/reopt/UnpackTraceFunction.h:1.10 reopt/include/reopt/UnpackTraceFunction.h:1.11 --- reopt/include/reopt/UnpackTraceFunction.h:1.10 Fri Jun 25 01:23:53 2004 +++ reopt/include/reopt/UnpackTraceFunction.h Fri Jul 9 15:55:34 2004 @@ -18,6 +18,7 @@ class TraceFunction; class AllocInfo; class Type; +class PHINode; /// This pass inserts copies in two places in the machine /// code for TF->TraceFn: first, at the entry basic block to copy the values in @@ -52,20 +53,20 @@ std::string RegStr (const unsigned R) const; void PrintAI (const AllocInfo &AI) const; - void PrintValueAIs (const std::string &ValueName, - const AllocInfo &MatrixAI, + void PrintValueAIs (const std::string &ValueName, const AllocInfo &MatrixAI, const AllocInfo &TraceAI) const; void rewriteProlog (MachineFunction &MF, MachineBasicBlock &MBB); - void copyConstantToRegister (MachineFunction &MF, - Constant *C, unsigned Reg, + void copyConstantToRegister (MachineFunction &MF, Constant *C, unsigned Reg, unsigned SpareReg, std::vector &mvec); void addLiveOutCopy (MachineFunction &MF, MachineBasicBlock &MBB, const AllocInfo &Source, const AllocInfo &Target, Value *liveOutValue, Value *liveOutTraceValue); + void eliminatePhiAtTraceExit (MachineFunction &MF, MachineBasicBlock &MBB, + const PHINode *PN); void rewriteEpilog (MachineFunction &MF, MachineBasicBlock &MBB); - + public: UnpackTraceFunction (TargetMachine *TM_) : TM (TM_), TF (0) { } void setTraceFunction (TraceFunction *TF_) { TF = TF_; } From gaeke at cs.uiuc.edu Fri Jul 9 15:57:00 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Fri Jul 9 15:57:00 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Message-ID: <200407092055.PAA19997@kain.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: UnpackTraceFunction.cpp updated: 1.93 -> 1.94 --- Log message: Add comment for addLiveOutCopy, along with when it is appropriate to call it. Refactor trace exit phi elimination code into new eliminatePhiAtTraceExit method. Wrap some long lines. Other minor comment edits. --- Diffs of the changes: (+68 -43) Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.93 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.94 --- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.93 Fri Jul 9 14:41:27 2004 +++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Fri Jul 9 15:55:35 2004 @@ -334,6 +334,10 @@ std::cerr << "copyConstantToRegister Output: " << **i << "\n"); } +/// addLiveOutCopy - Add a copy of the Value which is liveOutValue in the +/// MatrixFn and liveOutTraceValue in the TraceFn, from Source to Target, +/// at the end of MF's basic block MBB. +/// void UnpackTraceFunction::addLiveOutCopy (MachineFunction &MF, MachineBasicBlock &MBB, const AllocInfo &Source, const AllocInfo &Target, Value *liveOutValue, Value *liveOutTraceValue) { @@ -396,6 +400,53 @@ MBB.push_back (*vi); } +/// eliminatePhiAtTraceExit - Perform Phi elimination along trace exit edges. +/// +void UnpackTraceFunction::eliminatePhiAtTraceExit (MachineFunction &MF, + MachineBasicBlock &MBB, + const PHINode *PN) { + for (unsigned i = 0, e = PN->getNumIncomingValues (); i != e; ++i) { + // If PN has a source S from the source of the trace exit (MBB's + // predecessor), then we have to copy S's incoming value into its PhiCp + // register. + const BasicBlock *Src = PN->getIncomingBlock (i); + if (TF->T.contains (Src)) { + BasicBlock *SrcTTF = cast (TF->getCorrespondingValue (Src)); + DEBUG (std::cerr << "rewriteEpilog: considering Phi node " + << PN->getName () + << ", found on-trace source #" << i << " (" << Src->getName () + << ", corresponding to " << SrcTTF->getName () << " on trace)\n" + << *PN << "\n"); + const BasicBlock *TraceExitingBB = *pred_begin(MBB.getBasicBlock ()); + DEBUG (std::cerr << "rewriteEpilog: trace exiting BB for this block is " + << TraceExitingBB->getName () << "\n"); + if (TraceExitingBB == SrcTTF) { + Value *V = PN->getIncomingValue (i); + DEBUG (std::cerr << "rewriteEpilog: found match: trace exiting BB is " + << "phi source; phi's incoming value from " << Src->getName () + << " is " << V->getName () << "\n"); + std::pair outgoingValueAI = + GetValueAllocState (TF, V, false); + std::pair phiCpAI = // we want the PhiCp node + GetValueAllocState (TF, const_cast (PN), true); + DEBUG (std::cerr << "rewriteEpilog: Outgoing value is in "; + PrintAI (outgoingValueAI.second); + std::cerr << " in TraceFn, and " << PN->getName() + << "'s PhiCp node is in "; + PrintAI (phiCpAI.first); + std::cerr << " in MatrixFn\n"); + + AllocInfo &Target = phiCpAI.first, &Source = outgoingValueAI.second; + DEBUG (std::cerr << "rewriteEpilog: copying live-out phi value: "; + PrintValueAIs(V->getName(), Target, Source)); + addLiveOutCopy (MF, MBB, Source, Target, V, + TF->getCorrespondingValue (V, false)); + } + } + DEBUG (std::cerr << "\n"); + } +} + void UnpackTraceFunction::rewriteEpilog (MachineFunction &MF, MachineBasicBlock &MBB) { const SparcV9RegInfo &TRI = *TM->getRegInfo (); @@ -417,45 +468,13 @@ DEBUG (std::cerr << "rewriteEpilog: Return block for trace exit path is:\n" << *RBB << "\n"); - // Perform Phi elimination along trace exit edges. + // If there are Phi nodes in the target of the trace-exiting branch, we must + // eliminate them by inserting copies now. for (BasicBlock::const_iterator Inst = RBB->begin (); const PHINode *PN = dyn_cast (Inst); ++Inst) - for (unsigned i = 0, e = PN->getNumIncomingValues (); i != e; ++i) { - // If PN has a source S from the source of the trace exit (MBB's predecessor), - // then we have to copy S's incoming value into its PhiCp register. - const BasicBlock *Src = PN->getIncomingBlock (i); - if (TF->T.contains (Src)) { - BasicBlock *SrcTTF = cast (TF->getCorrespondingValue (Src)); - DEBUG (std::cerr << "rewriteEpilog: considering Phi node " << PN->getName () - << ", found on-trace source #" << i << " (" << Src->getName () - << ", corresponding to " << SrcTTF->getName () << " on trace)\n" - << *PN << "\n"); - const BasicBlock *TraceExitingBB = *pred_begin(MBB.getBasicBlock ()); - DEBUG (std::cerr << "rewriteEpilog: trace exiting BB for this block is " - << TraceExitingBB->getName () << "\n"); - if (TraceExitingBB == SrcTTF) { - Value *V = PN->getIncomingValue (i); - DEBUG (std::cerr << "rewriteEpilog: found match: trace exiting BB is " - << "phi source; phi's incoming value from " << Src->getName () - << " is " << V->getName () << "\n"); - std::pair outgoingValueAI = GetValueAllocState (TF, V, false); - std::pair phiCpAI = - GetValueAllocState (TF, const_cast (PN), true); // we want the PhiCp node - DEBUG (std::cerr << "rewriteEpilog: Outgoing value is in "; - PrintAI (outgoingValueAI.second); - std::cerr << " in TraceFn, and " << PN->getName() << "'s PhiCp node is in "; - PrintAI (phiCpAI.first); - std::cerr << " in MatrixFn\n"); - - AllocInfo &Target = phiCpAI.first, &Source = outgoingValueAI.second; - DEBUG (std::cerr << "rewriteEpilog: copying live-out phi value: "; - PrintValueAIs(V->getName(), Target, Source)); - addLiveOutCopy (MF, MBB, Source, Target, V, TF->getCorrespondingValue (V, false)); - } - } - DEBUG (std::cerr << "\n"); - } - + eliminatePhiAtTraceExit (MF, MBB, PN); +//===----------------------------------------------------------------------===// + // Insert stores from each live-out variable's reg. in the trace // to its stack slot in the trace function, from which it will be // reloaded below into a register. @@ -469,10 +488,13 @@ AllocInfo &Target = ai.first, &Source = ai.second; DEBUG (std::cerr << "rewriteEpilog: copying live-out value: "; PrintValueAIs(V->getName(), Target, Source)); - addLiveOutCopy (MF, MBB, Source, Target, V, TF->getCorrespondingValue (V, false)); + addLiveOutCopy (MF, MBB, Source, Target, V, + TF->getCorrespondingValue (V, false)); } - // Restore old FP. + // Restore old FP. Warning! After this point, addLiveOutCopy won't work + // anymore, because it depends on being able to access TraceFn's frame + // pointer in %fp. mvec.clear (); TRI.cpMem2RegMI (mvec, sp, stackOffsetForReg (fp), fp, TRI.getRegType(fp), g2); @@ -482,14 +504,15 @@ RegsToSave.erase (fp); // Get the set of registers used in this function which we saved in - // rewriteProlog, earlier, and restore all used registers from stack + // findRegsToSave, earlier, and restore all used registers from stack // except SP. for (std::set::iterator i = RegsToSave.begin (), e = RegsToSave.end (); i != e; ++i) { mvec.clear (); unsigned R = *i; DEBUG (std::cerr << "rewriteEpilog: Reloading " << RegStr (R) << "\n"); - TRI.cpMem2RegMI (mvec, sp, stackOffsetForReg (R), R, TRI.getRegType (R), g2); + TRI.cpMem2RegMI (mvec, sp, stackOffsetForReg (R), R, TRI.getRegType (R), + g2); for (std::vector::iterator vi = mvec.begin (), ve = mvec.end (); vi != ve; ++vi) MBB.push_back (*vi); @@ -500,8 +523,10 @@ .addMReg (sp, MachineOperand::Def); // Let ReturnAddress be the address in memory of the compiled - // code for RBB. We find this by consulting our mapping information. - std::pair BlockAddrs = getBasicBlockInfo(const_cast (RBB)); + // code for RBB. We find this by consulting the mapping information + // generated by llc. + std::pair BlockAddrs = + getBasicBlockInfo(const_cast (RBB)); uint64_t ReturnAddress = BlockAddrs.first; DEBUG(std::cerr << "rewriteEpilog: Mapping info says addresses are: return address =" From llvm at cs.uiuc.edu Fri Jul 9 16:15:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Fri Jul 9 16:15:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp Message-ID: <200407092114.QAA15094@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.cpp updated: 1.110 -> 1.111 --- Log message: Fix a backwards compatibility bug found by Tanya. In version 1.2, the global type plane starts with a length and the TypeTyID value to identify the type plane has having type definitions. This doesn't happen in 1.3 because the types are read from a known position in the file. However, the TypeTyID must be read in (and ignored) if its a 1.2 bytecode file. --- Diffs of the changes: (+5 -0) Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.110 llvm/lib/Bytecode/Reader/Reader.cpp:1.111 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.110 Sun Jul 4 19:57:50 2004 +++ llvm/lib/Bytecode/Reader/Reader.cpp Fri Jul 9 16:13:53 2004 @@ -1641,6 +1641,11 @@ void BytecodeReader::ParseGlobalTypes() { // Read the number of types unsigned NumEntries = read_vbr_uint(); + + // Ignore the type plane identifier for types if the bc file is pre 1.3 + if (hasTypeDerivedFromValue) + read_vbr_uint(); + ParseTypeConstants(ModuleTypes, NumEntries); } From llvm at cs.uiuc.edu Fri Jul 9 17:33:16 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Fri Jul 9 17:33:16 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.h Reader.cpp Message-ID: <200407092221.RAA15600@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.h updated: 1.4 -> 1.5 Reader.cpp updated: 1.111 -> 1.112 --- Log message: Error Handling Cleanup: - get rid of PARSE_ERROR macro - add error(std::string) function - use error(std::string) for all errors - make input dependent asserts call error(std::string) instead - ensure asserts are only for logic bugs, not input discrepancies. --- Diffs of the changes: (+129 -121) Index: llvm/lib/Bytecode/Reader/Reader.h diff -u llvm/lib/Bytecode/Reader/Reader.h:1.4 llvm/lib/Bytecode/Reader/Reader.h:1.5 --- llvm/lib/Bytecode/Reader/Reader.h:1.4 Mon Jul 5 20:30:36 2004 +++ llvm/lib/Bytecode/Reader/Reader.h Fri Jul 9 17:21:33 2004 @@ -405,6 +405,8 @@ } } + inline void error(std::string errmsg); + BytecodeReader(const BytecodeReader &); // DO NOT IMPLEMENT void operator=(const BytecodeReader &); // DO NOT IMPLEMENT Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.111 llvm/lib/Bytecode/Reader/Reader.cpp:1.112 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.111 Fri Jul 9 16:13:53 2004 +++ llvm/lib/Bytecode/Reader/Reader.cpp Fri Jul 9 17:21:33 2004 @@ -29,13 +29,6 @@ using namespace llvm; -/// A convenience macro for handling parsing errors. -#define PARSE_ERROR(inserters) { \ - std::ostringstream errormsg; \ - errormsg << inserters; \ - throw std::string(errormsg.str()); \ - } - /// @brief A class for maintaining the slot number definition /// as a placeholder for the actual definition. template @@ -55,6 +48,16 @@ typedef PlaceholderDef ConstPHolder; +// Provide some details on error +inline void BytecodeReader::error(std::string err) { + err += " (Vers=" ; + err += itostr(RevisionNum) ; + err += ", Pos=" ; + err += itostr(At-MemStart); + err += ")"; + throw err; +} + //===----------------------------------------------------------------------===// // Bytecode Reading Methods //===----------------------------------------------------------------------===// @@ -67,7 +70,7 @@ /// Throw an error if we've read past the end of the current block inline void BytecodeReader::checkPastBlockEnd(const char * block_name) { if ( At > BlockEnd ) - PARSE_ERROR("Attempt to read past the end of " << block_name << " block."); + error(std::string("Attempt to read past the end of ") + block_name + " block."); } /// Align the buffer position to a 32 bit boundary @@ -77,13 +80,13 @@ if ( At > Save ) if (Handler) Handler->handleAlignment( At - Save ); if (At > BlockEnd) - throw std::string("Ran out of data while aligning!"); + error("Ran out of data while aligning!"); } /// Read a whole unsigned integer inline unsigned BytecodeReader::read_uint() { if (At+4 > BlockEnd) - throw std::string("Ran out of data reading uint!"); + error("Ran out of data reading uint!"); At += 4; return At[-4] | (At[-3] << 8) | (At[-2] << 16) | (At[-1] << 24); } @@ -96,7 +99,7 @@ do { if (At == BlockEnd) - throw std::string("Ran out of data reading vbr_uint!"); + error("Ran out of data reading vbr_uint!"); Result |= (unsigned)((*At++) & 0x7F) << Shift; Shift += 7; } while (At[-1] & 0x80); @@ -112,7 +115,7 @@ do { if (At == BlockEnd) - throw std::string("Ran out of data reading vbr_uint64!"); + error("Ran out of data reading vbr_uint64!"); Result |= (uint64_t)((*At++) & 0x7F) << Shift; Shift += 7; } while (At[-1] & 0x80); @@ -139,7 +142,7 @@ const unsigned char *OldAt = At; At += Size; if (At > BlockEnd) // Size invalid? - throw std::string("Ran out of data reading a string!"); + error("Ran out of data reading a string!"); return std::string((char*)OldAt, Size); } @@ -148,7 +151,7 @@ unsigned char *Start = (unsigned char *)Ptr; unsigned Amount = (unsigned char *)End - Start; if (At+Amount > BlockEnd) - throw std::string("Ran out of data!"); + error("Ran out of data!"); std::copy(At, At+Amount, Start); At += Amount; } @@ -159,7 +162,7 @@ Size = read_uint(); BlockStart = At; if ( At + Size > BlockEnd ) - throw std::string("Attempt to size a block past end of memory"); + error("Attempt to size a block past end of memory"); BlockEnd = At + Size; if (Handler) Handler->handleBlock( Type, BlockStart, Size ); } @@ -225,7 +228,7 @@ if (!CompactionTypes.empty()) { if (ID >= CompactionTypes.size()) - throw std::string("Type ID out of range for compaction table!"); + error("Type ID out of range for compaction table!"); return CompactionTypes[ID]; } @@ -238,7 +241,7 @@ if (ID < FunctionTypes.size()) return FunctionTypes[ID].get(); - throw std::string("Illegal type reference!"); + error("Illegal type reference!"); return Type::VoidTy; } @@ -246,18 +249,18 @@ /// is both sanitized and not the "type type" of pre-1.3 bytecode. /// @see sanitizeTypeId inline const Type* BytecodeReader::getSanitizedType(unsigned& ID) { - bool isTypeType = sanitizeTypeId(ID); - assert(!isTypeType && "Invalid type id occurred"); + if ( sanitizeTypeId(ID) ) + error("Invalid type id encountered"); return getType(ID); } /// This method just saves some coding. It uses read_typeid to read -/// in a sanitized type id, asserts that its not the type type, and +/// in a sanitized type id, errors that its not the type type, and /// then calls getType to return the type value. inline const Type* BytecodeReader::readSanitizedType() { unsigned ID; - bool isTypeType = read_typeid(ID); - assert(!isTypeType && "Invalid type id occurred"); + if ( read_typeid(ID) ) + error( "Invalid type id encountered"); return getType(ID); } @@ -273,7 +276,7 @@ find(CompactionTypes.begin(), CompactionTypes.end(), Ty); if (I == CompactionTypes.end()) - throw std::string("Couldn't find type specified in compaction table!"); + error("Couldn't find type specified in compaction table!"); return Type::FirstDerivedTyID + (&*I - &CompactionTypes[0]); } @@ -287,7 +290,7 @@ // Check the module level types now... I = find(ModuleTypes.begin(), ModuleTypes.end(), Ty); if (I == ModuleTypes.end()) - throw std::string("Didn't find type in ModuleTypes."); + error("Didn't find type in ModuleTypes."); return Type::FirstDerivedTyID + (&*I - &ModuleTypes[0]); } @@ -297,12 +300,13 @@ const Type *BytecodeReader::getGlobalTableType(unsigned Slot) { if (Slot < Type::FirstDerivedTyID) { const Type *Ty = Type::getPrimitiveType((Type::TypeID)Slot); - assert(Ty && "Not a primitive type ID?"); + if ( ! Ty ) + error("Not a primitive type ID?"); return Ty; } Slot -= Type::FirstDerivedTyID; if (Slot >= ModuleTypes.size()) - throw std::string("Illegal compaction table type reference!"); + error("Illegal compaction table type reference!"); return ModuleTypes[Slot]; } @@ -314,7 +318,7 @@ TypeListTy::iterator I = find(ModuleTypes.begin(), ModuleTypes.end(), Ty); if (I == ModuleTypes.end()) - throw std::string("Didn't find type in ModuleTypes."); + error("Didn't find type in ModuleTypes."); return Type::FirstDerivedTyID + (&*I - &ModuleTypes[0]); } @@ -389,10 +393,11 @@ if (TyID >= ModuleValues.size() || ModuleValues[TyID] == 0 || SlotNo >= ModuleValues[TyID]->size()) { - PARSE_ERROR("Corrupt compaction table entry!" - << TyID << ", " << SlotNo << ": " << ModuleValues.size() << ", " - << (void*)ModuleValues[TyID] << ", " - << ModuleValues[TyID]->size() << "\n"); + error("Corrupt compaction table entry!" + + utostr(TyID) + ", " + utostr(SlotNo) + ": " + + utostr(ModuleValues.size()) + ", " + + utohexstr(int((void*)ModuleValues[TyID])) + ", " + + utostr(ModuleValues[TyID]->size()) ); } return ModuleValues[TyID]->getOperand(SlotNo); } @@ -411,7 +416,7 @@ // to infest bytecode files. return ConstantPointerRef::get(GV); else - throw std::string("Reference of a value is expected to be a constant!"); + error("Reference of a value is expected to be a constant!"); const Type *Ty = getType(TypeSlot); std::pair Key(Ty, Slot); @@ -534,7 +539,7 @@ Oprnds.resize(NumOprnds); if (NumOprnds == 0) - throw std::string("Zero-argument instruction found; this is invalid."); + error("Zero-argument instruction found; this is invalid."); for (unsigned i = 0; i != NumOprnds; ++i) Oprnds[i] = read_vbr_uint(); @@ -560,7 +565,7 @@ switch (Opcode) { default: if (Result == 0) - throw std::string("Illegal instruction read!"); + error("Illegal instruction read!"); break; case Instruction::VAArg: Result = new VAArgInst(getValue(iType, Oprnds[0]), @@ -581,7 +586,7 @@ break; case Instruction::PHI: { if (Oprnds.size() == 0 || (Oprnds.size() & 1)) - throw std::string("Invalid phi node encountered!"); + error("Invalid phi node encountered!"); PHINode *PN = new PHINode(InstTy); PN->op_reserve(Oprnds.size()); @@ -603,7 +608,7 @@ else if (Oprnds.size() == 1) Result = new ReturnInst(getValue(iType, Oprnds[0])); else - throw std::string("Unrecognized instruction!"); + error("Unrecognized instruction!"); break; case Instruction::Br: @@ -613,11 +618,11 @@ Result = new BranchInst(getBasicBlock(Oprnds[0]), getBasicBlock(Oprnds[1]), getValue(Type::BoolTyID , Oprnds[2])); else - throw std::string("Invalid number of operands for a 'br' instruction!"); + error("Invalid number of operands for a 'br' instruction!"); break; case Instruction::Switch: { if (Oprnds.size() & 1) - throw std::string("Switch statement with odd number of arguments!"); + error("Switch statement with odd number of arguments!"); SwitchInst *I = new SwitchInst(getValue(iType, Oprnds[0]), getBasicBlock(Oprnds[1])); @@ -630,15 +635,15 @@ case Instruction::Call: { if (Oprnds.size() == 0) - throw std::string("Invalid call instruction encountered!"); + error("Invalid call instruction encountered!"); Value *F = getValue(iType, Oprnds[0]); // Check to make sure we have a pointer to function type const PointerType *PTy = dyn_cast(F->getType()); - if (PTy == 0) throw std::string("Call to non function pointer value!"); + if (PTy == 0) error("Call to non function pointer value!"); const FunctionType *FTy = dyn_cast(PTy->getElementType()); - if (FTy == 0) throw std::string("Call to non function pointer value!"); + if (FTy == 0) error("Call to non function pointer value!"); std::vector Params; if (!FTy->isVarArg()) { @@ -646,17 +651,17 @@ for (unsigned i = 1, e = Oprnds.size(); i != e; ++i) { if (It == FTy->param_end()) - throw std::string("Invalid call instruction!"); + error("Invalid call instruction!"); Params.push_back(getValue(getTypeSlot(*It++), Oprnds[i])); } if (It != FTy->param_end()) - throw std::string("Invalid call instruction!"); + error("Invalid call instruction!"); } else { Oprnds.erase(Oprnds.begin(), Oprnds.begin()+1); unsigned FirstVariableOperand; if (Oprnds.size() < FTy->getNumParams()) - throw std::string("Call instruction missing operands!"); + error("Call instruction missing operands!"); // Read all of the fixed arguments for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) @@ -665,7 +670,7 @@ FirstVariableOperand = FTy->getNumParams(); if ((Oprnds.size()-FirstVariableOperand) & 1) // Must be pairs of type/value - throw std::string("Invalid call instruction!"); + error("Invalid call instruction!"); for (unsigned i = FirstVariableOperand, e = Oprnds.size(); i != e; i += 2) @@ -677,16 +682,16 @@ } case Instruction::Invoke: { if (Oprnds.size() < 3) - throw std::string("Invalid invoke instruction!"); + error("Invalid invoke instruction!"); Value *F = getValue(iType, Oprnds[0]); // Check to make sure we have a pointer to function type const PointerType *PTy = dyn_cast(F->getType()); if (PTy == 0) - throw std::string("Invoke to non function pointer value!"); + error("Invoke to non function pointer value!"); const FunctionType *FTy = dyn_cast(PTy->getElementType()); if (FTy == 0) - throw std::string("Invoke to non function pointer value!"); + error("Invoke to non function pointer value!"); std::vector Params; BasicBlock *Normal, *Except; @@ -698,11 +703,11 @@ FunctionType::param_iterator It = FTy->param_begin(); for (unsigned i = 3, e = Oprnds.size(); i != e; ++i) { if (It == FTy->param_end()) - throw std::string("Invalid invoke instruction!"); + error("Invalid invoke instruction!"); Params.push_back(getValue(getTypeSlot(*It++), Oprnds[i])); } if (It != FTy->param_end()) - throw std::string("Invalid invoke instruction!"); + error("Invalid invoke instruction!"); } else { Oprnds.erase(Oprnds.begin(), Oprnds.begin()+1); @@ -715,7 +720,7 @@ Oprnds[i])); if (Oprnds.size()-FirstVariableArgument & 1) // Must be type/value pairs - throw std::string("Invalid invoke instruction!"); + error("Invalid invoke instruction!"); for (unsigned i = FirstVariableArgument; i < Oprnds.size(); i += 2) Params.push_back(getValue(Oprnds[i], Oprnds[i+1])); @@ -726,9 +731,9 @@ } case Instruction::Malloc: if (Oprnds.size() > 2) - throw std::string("Invalid malloc instruction!"); + error("Invalid malloc instruction!"); if (!isa(InstTy)) - throw std::string("Invalid malloc instruction!"); + error("Invalid malloc instruction!"); Result = new MallocInst(cast(InstTy)->getElementType(), Oprnds.size() ? getValue(Type::UIntTyID, @@ -737,9 +742,9 @@ case Instruction::Alloca: if (Oprnds.size() > 2) - throw std::string("Invalid alloca instruction!"); + error("Invalid alloca instruction!"); if (!isa(InstTy)) - throw std::string("Invalid alloca instruction!"); + error("Invalid alloca instruction!"); Result = new AllocaInst(cast(InstTy)->getElementType(), Oprnds.size() ? getValue(Type::UIntTyID, @@ -747,12 +752,12 @@ break; case Instruction::Free: if (!isa(InstTy)) - throw std::string("Invalid free instruction!"); + error("Invalid free instruction!"); Result = new FreeInst(getValue(iType, Oprnds[0])); break; case Instruction::GetElementPtr: { if (Oprnds.size() == 0 || !isa(InstTy)) - throw std::string("Invalid getelementptr instruction!"); + error("Invalid getelementptr instruction!"); std::vector Idx; @@ -760,7 +765,7 @@ for (unsigned i = 1, e = Oprnds.size(); i != e; ++i) { const CompositeType *TopTy = dyn_cast_or_null(NextTy); if (!TopTy) - throw std::string("Invalid getelementptr instruction!"); + error("Invalid getelementptr instruction!"); unsigned ValIdx = Oprnds[i]; unsigned IdxTy = 0; @@ -801,14 +806,14 @@ case 62: // volatile load case Instruction::Load: if (Oprnds.size() != 1 || !isa(InstTy)) - throw std::string("Invalid load instruction!"); + error("Invalid load instruction!"); Result = new LoadInst(getValue(iType, Oprnds[0]), "", Opcode == 62); break; case 63: // volatile store case Instruction::Store: { if (!isa(InstTy) || Oprnds.size() != 2) - throw std::string("Invalid store instruction!"); + error("Invalid store instruction!"); Value *Ptr = getValue(iType, Oprnds[1]); const Type *ValTy = cast(Ptr->getType())->getElementType(); @@ -818,7 +823,7 @@ } case Instruction::Unwind: if (Oprnds.size() != 0) - throw std::string("Invalid unwind instruction!"); + error("Invalid unwind instruction!"); Result = new UnwindInst(); break; } // end switch(Opcode) @@ -902,7 +907,7 @@ ParseInstruction(Args, BB); if (!BB->getTerminator()) - throw std::string("Non-terminated basic block found!"); + error("Non-terminated basic block found!"); if (Handler) Handler->handleBasicBlockEnd( BlockNo-1 ); } @@ -958,7 +963,7 @@ if ( isTypeType ) { const Type* T = getType(slot); if ( T == 0 ) - PARSE_ERROR("Failed type look-up for name '" << Name << "'"); + error("Failed type look-up for name '" + Name + "'"); ST->insert(Name, T); continue; // code below must be short circuited } else { @@ -970,7 +975,7 @@ V = getValue(Typ, slot, false); // Find mapping... } if (V == 0) - PARSE_ERROR("Failed value look-up for name '" << Name << "'"); + error("Failed value look-up for name '" + Name + "'"); V->setName(Name, ST); } } @@ -983,8 +988,8 @@ void BytecodeReader::ParseCompactionTypes( unsigned NumEntries ) { for (unsigned i = 0; i != NumEntries; ++i) { unsigned TypeSlot = 0; - bool isTypeType = read_typeid(TypeSlot); - assert(!isTypeType && "Invalid type in compaction table: type type"); + if ( read_typeid(TypeSlot) ) + error("Invalid type in compaction table: type type"); const Type *Typ = getGlobalTableType(TypeSlot); CompactionTypes.push_back(Typ); if (Handler) Handler->handleCompactionTableType( i, TypeSlot, Typ ); @@ -1028,7 +1033,7 @@ CompactionValues.resize(Ty+1); if (!CompactionValues[Ty].empty()) - throw std::string("Compaction table plane contains multiple entries!"); + error("Compaction table plane contains multiple entries!"); if (Handler) Handler->handleCompactionTablePlane( Ty, NumEntries ); @@ -1049,8 +1054,8 @@ // Parse a single type constant. const Type *BytecodeReader::ParseTypeConstant() { unsigned PrimType = 0; - bool isTypeType = read_typeid(PrimType); - assert(!isTypeType && "Invalid type (type type) in type constants!"); + if ( read_typeid(PrimType) ) + error("Invalid type (type type) in type constants!"); const Type *Result = 0; if ((Result = Type::getPrimitiveType((Type::TypeID)PrimType))) @@ -1081,12 +1086,13 @@ case Type::StructTyID: { std::vector Elements; unsigned Typ = 0; - bool isTypeType = read_typeid(Typ); - assert(!isTypeType && "Invalid element type (type type) for structure!"); + if ( read_typeid(Typ) ) + error("Invalid element type (type type) for structure!"); + while (Typ) { // List is terminated by void/0 typeid Elements.push_back(getType(Typ)); - bool isTypeType = read_typeid(Typ); - assert(!isTypeType && "Invalid element type (type type) for structure!"); + if ( read_typeid(Typ) ) + error("Invalid element type (type type) for structure!"); } Result = StructType::get(Elements); @@ -1103,8 +1109,7 @@ } default: - PARSE_ERROR("Don't know how to deserialize primitive type" - << PrimType << "\n"); + error("Don't know how to deserialize primitive type " + utostr(PrimType)); break; } if (Handler) Handler->handleType( Result ); @@ -1136,7 +1141,7 @@ const Type* NewTy = ParseTypeConstant(); const Type* OldTy = Tab[i].get(); if (NewTy == 0) - throw std::string("Couldn't parse type!"); + error("Couldn't parse type!"); // Don't directly push the new type on the Tab. Instead we want to replace // the opaque type we previously inserted with the new concrete value. This @@ -1171,8 +1176,8 @@ for (unsigned i = 0; i != isExprNumArgs; ++i) { unsigned ArgValSlot = read_vbr_uint(); unsigned ArgTypeSlot = 0; - bool isTypeType = read_typeid(ArgTypeSlot); - assert(!isTypeType && "Invalid argument type (type type) for constant value"); + if ( read_typeid(ArgTypeSlot) ) + error("Invalid argument type (type type) for constant value"); // Get the arg value from its slot if it exists, otherwise a placeholder ArgVec.push_back(getConstantValue(ArgTypeSlot, ArgValSlot)); @@ -1195,7 +1200,7 @@ for (unsigned i = 0; GTI != E; ++GTI, ++i) if (isa(*GTI)) { if (IdxList[i]->getType() != Type::UByteTy) - throw std::string("Invalid index for getelementptr!"); + error("Invalid index for getelementptr!"); IdxList[i] = ConstantExpr::getCast(IdxList[i], Type::UIntTy); } } @@ -1222,7 +1227,7 @@ case Type::BoolTyID: { unsigned Val = read_vbr_uint(); if (Val != 0 && Val != 1) - throw std::string("Invalid boolean value read."); + error("Invalid boolean value read."); Constant* Result = ConstantBool::get(Val == 1); if (Handler) Handler->handleConstantValue(Result); return Result; @@ -1233,7 +1238,7 @@ case Type::UIntTyID: { unsigned Val = read_vbr_uint(); if (!ConstantUInt::isValueValidForType(Ty, Val)) - throw std::string("Invalid unsigned byte/short/int read."); + error("Invalid unsigned byte/short/int read."); Constant* Result = ConstantUInt::get(Ty, Val); if (Handler) Handler->handleConstantValue(Result); return Result; @@ -1251,7 +1256,7 @@ case Type::LongTyID: int64_t Val = read_vbr_int64(); if (!ConstantSInt::isValueValidForType(Ty, Val)) - throw std::string("Invalid signed byte/short/int/long read."); + error("Invalid signed byte/short/int/long read."); Constant* Result = ConstantSInt::get(Ty, Val); if (Handler) Handler->handleConstantValue(Result); return Result; @@ -1310,9 +1315,9 @@ GlobalValue *GV; if (Val) { if (!(GV = dyn_cast(Val))) - throw std::string("Value of ConstantPointerRef not in ValueTable!"); + error("Value of ConstantPointerRef not in ValueTable!"); } else { - throw std::string("Forward references are not allowed here."); + error("Forward references are not allowed here."); } Constant* Result = ConstantPointerRef::get(GV); @@ -1321,10 +1326,11 @@ } default: - PARSE_ERROR("Don't know how to deserialize constant value of type '"+ + error("Don't know how to deserialize constant value of type '" + Ty->getDescription()); break; } + return 0; } /// Resolve references for constants. This function resolves the forward @@ -1346,16 +1352,16 @@ void BytecodeReader::ParseStringConstants(unsigned NumEntries, ValueTable &Tab){ for (; NumEntries; --NumEntries) { unsigned Typ = 0; - bool isTypeType = read_typeid(Typ); - assert(!isTypeType && "Invalid type (type type) for string constant"); + if ( read_typeid(Typ) ) + error("Invalid type (type type) for string constant"); const Type *Ty = getType(Typ); if (!isa(Ty)) - throw std::string("String constant data invalid!"); + error("String constant data invalid!"); const ArrayType *ATy = cast(Ty); if (ATy->getElementType() != Type::SByteTy && ATy->getElementType() != Type::UByteTy) - throw std::string("String constant data invalid!"); + error("String constant data invalid!"); // Read character data. The type tells us how long the string is. char Data[ATy->getNumElements()]; @@ -1442,7 +1448,7 @@ case 3: Linkage = GlobalValue::InternalLinkage; break; case 4: Linkage = GlobalValue::LinkOnceLinkage; break; default: - throw std::string("Invalid linkage type for Function."); + error("Invalid linkage type for Function."); Linkage = GlobalValue::InternalLinkage; break; } @@ -1501,7 +1507,7 @@ } if (BlockNum) - throw std::string("Already parsed basic blocks!"); + error("Already parsed basic blocks!"); BlockNum = ParseInstructionList(F); break; } @@ -1513,7 +1519,7 @@ default: At += Size; if (OldAt > At) - throw std::string("Wrapped around reading bytecode."); + error("Wrapped around reading bytecode."); break; } BlockEnd = MyEnd; @@ -1524,7 +1530,7 @@ // Make sure there were no references to non-existant basic blocks. if (BlockNum != ParsedBasicBlocks.size()) - throw std::string("Illegal basic block operand reference"); + error("Illegal basic block operand reference"); ParsedBasicBlocks.clear(); @@ -1580,7 +1586,7 @@ /// ParseAllFunctionBodies to get handler events for the functions. void BytecodeReader::ParseFunctionLazily() { if (FunctionSignatureList.empty()) - throw std::string("FunctionSignatureList empty!"); + error("FunctionSignatureList empty!"); Function *Func = FunctionSignatureList.back(); FunctionSignatureList.pop_back(); @@ -1604,13 +1610,13 @@ // Make sure we found it if ( Fi == LazyFunctionLoadMap.end() ) { - PARSE_ERROR("Unrecognized function of type " << Func->getType()->getDescription()); + error("Unrecognized function of type " + Func->getType()->getDescription()); return; } BlockStart = At = Fi->second.Buf; BlockEnd = Fi->second.EndBuf; - assert(Fi->first == Func); + assert(Fi->first == Func && "Found wrong function?"); LazyFunctionLoadMap.erase(Fi); @@ -1660,8 +1666,8 @@ // VarType Fields: bit0 = isConstant, bit1 = hasInitializer, bit2,3,4 = // Linkage, bit4+ = slot# unsigned SlotNo = VarType >> 5; - bool isTypeType = sanitizeTypeId(SlotNo); - assert(!isTypeType && "Invalid type (type type) for global var!"); + if ( sanitizeTypeId(SlotNo) ) + error("Invalid type (type type) for global var!"); unsigned LinkageID = (VarType >> 2) & 7; bool isConstant = VarType & 1; bool hasInitializer = VarType & 2; @@ -1674,18 +1680,18 @@ case 3: Linkage = GlobalValue::InternalLinkage; break; case 4: Linkage = GlobalValue::LinkOnceLinkage; break; default: - PARSE_ERROR("Unknown linkage type: " << LinkageID); + error("Unknown linkage type: " + utostr(LinkageID)); Linkage = GlobalValue::InternalLinkage; break; } const Type *Ty = getType(SlotNo); if ( !Ty ) { - PARSE_ERROR("Global has no type! SlotNo=" << SlotNo); + error("Global has no type! SlotNo=" + utostr(SlotNo)); } if ( !isa(Ty)) { - PARSE_ERROR("Global not a pointer type! Ty= " << Ty->getDescription()); + error("Global not a pointer type! Ty= " + Ty->getDescription()); } const Type *ElTy = cast(Ty)->getElementType(); @@ -1710,14 +1716,15 @@ // Read the function objects for all of the functions that are coming unsigned FnSignature = 0; - bool isTypeType = read_typeid(FnSignature); - assert(!isTypeType && "Invalid function type (type type) found"); + if ( read_typeid(FnSignature) ) + error("Invalid function type (type type) found"); + while (FnSignature != Type::VoidTyID) { // List is terminated by Void const Type *Ty = getType(FnSignature); if (!isa(Ty) || !isa(cast(Ty)->getElementType())) { - PARSE_ERROR( "Function not a pointer to function type! Ty = " + - Ty->getDescription()); + error("Function not a pointer to function type! Ty = " + + Ty->getDescription()); // FIXME: what should Ty be if handler continues? } @@ -1736,8 +1743,8 @@ if (Handler) Handler->handleFunctionDeclaration(Func); // Get Next function signature - isTypeType = read_typeid(FnSignature); - assert(!isTypeType && "Invalid function type (type type) found"); + if ( read_typeid(FnSignature) ) + error("Invalid function type (type type) found"); } if (hasInconsistentModuleGlobalInfo) @@ -1806,7 +1813,7 @@ break; default: - PARSE_ERROR("Unknown bytecode version number: " << RevisionNum); + error("Unknown bytecode version number: " + itostr(RevisionNum)); } if (hasNoEndianness) Endianness = Module::AnyEndianness; @@ -1836,7 +1843,7 @@ case BytecodeFormat::GlobalTypePlane: if ( SeenGlobalTypePlane ) - throw std::string("Two GlobalTypePlane Blocks Encountered!"); + error("Two GlobalTypePlane Blocks Encountered!"); ParseGlobalTypes(); SeenGlobalTypePlane = true; @@ -1844,7 +1851,7 @@ case BytecodeFormat::ModuleGlobalInfo: if ( SeenModuleGlobalInfo ) - throw std::string("Two ModuleGlobalInfo Blocks Encountered!"); + error("Two ModuleGlobalInfo Blocks Encountered!"); ParseModuleGlobalInfo(); SeenModuleGlobalInfo = true; break; @@ -1864,7 +1871,7 @@ default: At += Size; if (OldAt > At) { - PARSE_ERROR("Unexpected Block of Type" << Type << "encountered!" ); + error("Unexpected Block of Type #" + utostr(Type) + " encountered!" ); } break; } @@ -1886,18 +1893,17 @@ unsigned TypeSlot = getTypeSlot(GVType->getElementType()); if (Constant *CV = getConstantValue(TypeSlot, Slot)) { if (GV->hasInitializer()) - throw std::string("Global *already* has an initializer?!"); + error("Global *already* has an initializer?!"); if (Handler) Handler->handleGlobalInitializer(GV,CV); GV->setInitializer(CV); } else - throw std::string("Cannot find initializer value."); + error("Cannot find initializer value."); } /// Make sure we pulled them all out. If we didn't then there's a declaration /// but a missing body. That's not allowed. if (!FunctionSignatureList.empty()) - throw std::string( - "Function declared, but bytecode stream ended before definition"); + error("Function declared, but bytecode stream ended before definition"); } /// This function completely parses a bytecode buffer given by the \p Buf @@ -1919,7 +1925,7 @@ // Read and check signature... unsigned Sig = read_uint(); if (Sig != ('l' | ('l' << 8) | ('v' << 16) | ('m' << 24))) { - PARSE_ERROR("Invalid bytecode signature: " << Sig); + error("Invalid bytecode signature: " + utostr(Sig)); } @@ -1930,12 +1936,12 @@ unsigned Type, Size; read_block(Type, Size); if ( Type != BytecodeFormat::Module ) { - PARSE_ERROR("Expected Module Block! At: " << unsigned(intptr_t(At)) - << ", Type:" << Type << ", Size:" << Size); + error("Expected Module Block! Type:" + utostr(Type) + ", Size:" + + utostr(Size)); } if ( At + Size != MemEnd ) { - PARSE_ERROR("Invalid Top Level Block Length! At: " - << unsigned(intptr_t(At)) << ", Type:" << Type << ", Size:" << Size); + error("Invalid Top Level Block Length! Type:" + utostr(Type) + + ", Size:" + utostr(Size)); } // Parse the module contents @@ -1943,7 +1949,7 @@ // Check for missing functions if ( hasFunctions() ) - throw std::string("Function expected, but bytecode stream ended!"); + error("Function expected, but bytecode stream ended!"); // Process all the function bodies now, if requested if ( processFunctions ) From lattner at cs.uiuc.edu Sat Jul 10 01:08:09 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 01:08:09 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/index.html Message-ID: <200407100607.BAA07667@apoc.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: index.html updated: 1.16 -> 1.17 --- Log message: Minor cleanups: * Mention the --help and --help-hidden options * Don't say program when we really mean any old bytecode file * Add a link to the man pages * Move analyze down in the list, as it's not as important as the rest --- Diffs of the changes: (+21 -24) Index: llvm/docs/CommandGuide/index.html diff -u llvm/docs/CommandGuide/index.html:1.16 llvm/docs/CommandGuide/index.html:1.17 --- llvm/docs/CommandGuide/index.html:1.16 Fri Jul 2 10:46:55 2004 +++ llvm/docs/CommandGuide/index.html Sat Jul 10 01:06:56 2004 @@ -13,16 +13,12 @@
            -

            This document is the reference manual for the LLVM utilities. It will -show you how to use the LLVM commands and what their options are. Note that in -the descriptions below, `bytecode' and `program' refer to LLVM bytecode files -and assembly programs, respectively.

            - - +

            These documents are HTML versions of the man pages +for all of the LLVM tools. These pages describe how to use the LLVM commands +and what their options are. Note that these pages do not describe all of the +options available for all tools. To get a complete listing, pass the +--help (general options) or --help-hidden (general+debugging +options) arguments to the tool you are interested in.

            @@ -37,31 +33,32 @@
            • llvm-as - - assemble a human-readable program into bytecode
            • + assemble a human-readable .ll file into bytecode
            • llvm-dis - - disassemble a bytecode file into human-readable form
            • - -
            • analyze - - analyze a program compiled to bytecode
            • + disassemble a bytecode file into a human-readable .ll file
            • opt - - optimize a bytecode file
            • + run a series of LLVM-to-LLVM optimizations on a bytecode file
            • llc - - compile a bytecode program into native machine code
            • + generate native machine code for a bytecode file
            • lli - - run a bytecode program using either an interpreter or a JIT compiler
            • + directly run a program compiled to bytecode using a JIT compiler or + interpreter
            • llvm-link link several bytecode files into one
            • +
            • analyze - + run LLVM analyses on a bytecode file and print the results
            • +
            • llvm-nm print out the names and types of symbols in a bytecode file
            • llvm-prof - - transform raw `llvmprof.out' data into a human-readable report
            • + format raw `llvmprof.out' data into a human-readable report
            @@ -78,16 +75,16 @@
            • llvmgcc - - GCC-based C front end for LLVM + GCC-based C front-end for LLVM
            • llvmg++ - - GCC-based C++ front end for LLVM
            • + GCC-based C++ front-end for LLVM
            • gccas - - optimizing assembler used by llvm-g++ and llvm-gcc
            • + compile-time optimizer used by llvm-g++ and llvm-gcc
            • gccld - - optimizing linker used by llvm-g++ and llvm-gcc
            • + linker and link-time optimizer used by llvm-g++ and llvm-gcc
            @@ -128,7 +125,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"> LLVM Compiler Infrastructure
            - Last modified: $Date: 2004/07/02 15:46:55 $ + Last modified: $Date: 2004/07/10 06:06:56 $ From llvm at cs.uiuc.edu Sat Jul 10 03:05:22 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat Jul 10 03:05:22 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Analyzer.cpp Message-ID: <200407100804.DAA18423@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Analyzer.cpp updated: 1.9 -> 1.10 --- Log message: Make the VBRSavings percentage make sense (as a fraction of the total expanded size instead of the file size). Thanks Chris. --- Diffs of the changes: (+2 -3) Index: llvm/lib/Bytecode/Reader/Analyzer.cpp diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.9 llvm/lib/Bytecode/Reader/Analyzer.cpp:1.10 --- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.9 Sun Jul 4 19:57:50 2004 +++ llvm/lib/Bytecode/Reader/Analyzer.cpp Sat Jul 10 03:04:13 2004 @@ -505,7 +505,6 @@ { print(Out, "Bytecode Analysis Of Module", bca.ModuleId); print(Out, "File Size", bca.byteSize); - print(Out, "Bytecode Compression Index",std::string("TBD")); print(Out, "Number Of Bytecode Blocks", bca.numBlocks); print(Out, "Number Of Types", bca.numTypes); print(Out, "Number Of Values", bca.numValues); @@ -534,7 +533,7 @@ print(Out, "Number of VBR Expanded Bytes", bca.vbrExpdBytes); print(Out, "VBR Savings", double(bca.vbrExpdBytes)-double(bca.vbrCompBytes), - double(bca.byteSize)); + double(bca.vbrExpdBytes)); if ( bca.detailedResults ) { print(Out, "Module Bytes", @@ -589,7 +588,7 @@ print(Out, "Number of VBR Expanded Bytes", I->second.vbrExpdBytes); print(Out, "VBR Savings", double(I->second.vbrExpdBytes)-double(I->second.vbrCompBytes), - double(I->second.byteSize)); + double(I->second.vbrExpdBytes)); ++I; } } From llvm at cs.uiuc.edu Sat Jul 10 11:39:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat Jul 10 11:39:01 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Module.cpp Message-ID: <200407101637.LAA25375@zion.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Module.cpp updated: 1.51 -> 1.52 --- Log message: Replace use of defunct Type::setName method with SymbolTable::insert. Patch found and provided by Vladimir Merzliakov. Thanks Vladimir! --- Diffs of the changes: (+1 -1) Index: llvm/lib/VMCore/Module.cpp diff -u llvm/lib/VMCore/Module.cpp:1.51 llvm/lib/VMCore/Module.cpp:1.52 --- llvm/lib/VMCore/Module.cpp:1.51 Sun Jul 4 06:53:53 2004 +++ llvm/lib/VMCore/Module.cpp Sat Jul 10 11:37:42 2004 @@ -251,7 +251,7 @@ // Not in symbol table? Set the name with the Symtab as an argument so the // type knows what to update... - ((Value*)Ty)->setName(Name, &ST); + ST.insert(Name, Ty); return false; } From llvm at cs.uiuc.edu Sat Jul 10 15:05:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat Jul 10 15:05:01 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/stkrc.pod Message-ID: <200407102004.PAA26369@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: stkrc.pod added (r1.1) --- Log message: Command Guide for the Stacker language compiler, stkrc. --- Diffs of the changes: (+95 -0) Index: llvm/docs/CommandGuide/stkrc.pod diff -c /dev/null llvm/docs/CommandGuide/stkrc.pod:1.1 *** /dev/null Sat Jul 10 15:04:12 2004 --- llvm/docs/CommandGuide/stkrc.pod Sat Jul 10 15:04:02 2004 *************** *** 0 **** --- 1,95 ---- + =pod + + =head1 NAME + + stkrc - Stacker Compiler + + =head1 SYNOPSIS + + B [I] [I] + + =head1 DESCRIPTION + + The B command is the compiler for the Stacker language. Stacker is a + simple stack based, Forth-like language that was written as a demonstration + language for LLVM. For details on the language, please see + L . The B compiler is fairly + minimal. It compiles to bytecode only and doesn't perform any optimizations. + The output of stkrc (a bytecode file) can be piped through other LLVM tools + for optimization and linking. + + If F is omitted or is C<->, then B reads its input + from standard input. This is useful for combining the tool into a pipeline. + + If an output file is not specified with the B<-o> option, then + B sends its output to a file or standard output by following + these rules: + + =over + + =item * + + If the input is standard input, then the output is standard output. + + =item * + + If the input is a file that ends with C<.st>, then the output file is of + the same name, except that the suffix is changed to C<.bc>. + + =item * + + If the input is a file that does not end with the C<.st> suffix, then the + output file has the same name as the input file, except that the C<.bc> + suffix is appended. + + =back + + =head1 OPTIONS + + =over + + =item B<-o> F + + Specify the output file name. If F is C<->, then B + sends its output to standard output. + + =item B<-stats> + + Print statistics acquired during compilation. + + =item B<-time-passes> + + Record the amount of time needed for each pass and print it to standard + error. + + =item B<-f> + + Force the output to be written. Normally, B won't overwrite an existing + bytecode file. This option overrides that behavior. + + =item B<-s=stacksize> + + Specify the stack size for the program. The default stack size, 1024, should be + sufficient for most programs. For very large, programs, you might want to + provide a larger value. + + =item B<-help> + + Print a summary of command line options. + + =back + + =head1 EXIT STATUS + + If B succeeds, it will exit with 0. Otherwise, if an error + occurs, it will exit with a non-zero value, usually 1. + + =head1 SEE ALSO + + L, L + + =head1 AUTHORS + + Maintained by the LLVM Team (L). + + =cut From lattner at cs.uiuc.edu Sat Jul 10 16:44:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 16:44:01 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/index.html Message-ID: <200407102143.QAA18738@apoc.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: index.html updated: 1.17 -> 1.18 --- Log message: Add link to the stkrc page --- Diffs of the changes: (+6 -3) Index: llvm/docs/CommandGuide/index.html diff -u llvm/docs/CommandGuide/index.html:1.17 llvm/docs/CommandGuide/index.html:1.18 --- llvm/docs/CommandGuide/index.html:1.17 Sat Jul 10 01:06:56 2004 +++ llvm/docs/CommandGuide/index.html Sat Jul 10 16:43:12 2004 @@ -66,12 +66,11 @@
            -
            • llvmgcc - @@ -86,6 +85,10 @@
            • gccld - linker and link-time optimizer used by llvm-g++ and llvm-gcc
            • +
            • stkrc - + front-end compiler for the Stacker + language
            • +
            @@ -125,7 +128,7 @@ src="http://www.w3.org/Icons/valid-html401" alt="Valid HTML 4.01!"> LLVM Compiler Infrastructure
            - Last modified: $Date: 2004/07/10 06:06:56 $ + Last modified: $Date: 2004/07/10 21:43:12 $ From llvm at cs.uiuc.edu Sat Jul 10 18:37:02 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat Jul 10 18:37:02 2004 Subject: [llvm-commits] CVS: llvm/projects/Stacker/tools/stkrc/stkrc.cpp Message-ID: <200407102335.SAA27227@zion.cs.uiuc.edu> Changes in directory llvm/projects/Stacker/tools/stkrc: stkrc.cpp updated: 1.3 -> 1.4 --- Log message: Group the hidden command line arguments. Make the -s option actually work and default to the right value. --- Diffs of the changes: (+6 -7) Index: llvm/projects/Stacker/tools/stkrc/stkrc.cpp diff -u llvm/projects/Stacker/tools/stkrc/stkrc.cpp:1.3 llvm/projects/Stacker/tools/stkrc/stkrc.cpp:1.4 --- llvm/projects/Stacker/tools/stkrc/stkrc.cpp:1.3 Sun Jul 4 07:22:14 2004 +++ llvm/projects/Stacker/tools/stkrc/stkrc.cpp Sat Jul 10 18:35:46 2004 @@ -39,12 +39,12 @@ static cl::opt Force("f", cl::desc("Overwrite output files")); -static cl::opt -DumpAsm("d", cl::desc("Print LLVM Assembly as parsed"), cl::Hidden); - static cl::opt StackSize("s", cl::desc("Specify program maximum stack size"), - cl::value_desc("stacksize")); + cl::init(1024), cl::value_desc("stack size")); + +static cl::opt +DumpAsm("d", cl::desc("Print LLVM Assembly as parsed"), cl::Hidden); #ifdef PARSE_DEBUG static cl::opt @@ -57,8 +57,7 @@ #endif static cl::opt -EchoSource("e", cl::desc("Print Stacker Source as parsed"), - cl::value_desc("echo")); +EchoSource("e", cl::desc("Print Stacker Source as parsed"), cl::Hidden); int main(int argc, char **argv) { @@ -83,7 +82,7 @@ // Parse the file now... std::auto_ptr M ( - compiler.compile(InputFilename,EchoSource, 1024) ); + compiler.compile(InputFilename,EchoSource, StackSize) ); if (M.get() == 0) { std::cerr << argv[0] << ": assembly didn't read correctly.\n"; return 1; From llvm at cs.uiuc.edu Sat Jul 10 18:42:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sat Jul 10 18:42:01 2004 Subject: [llvm-commits] CVS: llvm/docs/CommandGuide/stkrc.pod Message-ID: <200407102341.SAA27288@zion.cs.uiuc.edu> Changes in directory llvm/docs/CommandGuide: stkrc.pod updated: 1.1 -> 1.2 --- Log message: - Correct grammar of -s description - Normalize -s option specification --- Diffs of the changes: (+4 -3) Index: llvm/docs/CommandGuide/stkrc.pod diff -u llvm/docs/CommandGuide/stkrc.pod:1.1 llvm/docs/CommandGuide/stkrc.pod:1.2 --- llvm/docs/CommandGuide/stkrc.pod:1.1 Sat Jul 10 15:04:02 2004 +++ llvm/docs/CommandGuide/stkrc.pod Sat Jul 10 18:41:08 2004 @@ -67,11 +67,12 @@ Force the output to be written. Normally, B won't overwrite an existing bytecode file. This option overrides that behavior. -=item B<-s=stacksize> +=item B<-s> F Specify the stack size for the program. The default stack size, 1024, should be -sufficient for most programs. For very large, programs, you might want to -provide a larger value. +sufficient for most programs. For very large programs, especially those that +recurse a lot, you might want to provide a larger value. Each unit of this +value consumes 8 bytes of memory. =item B<-help> From lattner at cs.uiuc.edu Sat Jul 10 20:05:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 20:05:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Support/PluginLoader.cpp Message-ID: <200407110104.UAA20142@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Support: PluginLoader.cpp updated: 1.10 -> 1.11 --- Log message: Implicitly getting a new option by linking to support.o instead of support.a is a bad idea. Make tools that want the option #include PluginSupport.h explicitly. --- Diffs of the changes: (+8 -23) Index: llvm/lib/Support/PluginLoader.cpp diff -u llvm/lib/Support/PluginLoader.cpp:1.10 llvm/lib/Support/PluginLoader.cpp:1.11 --- llvm/lib/Support/PluginLoader.cpp:1.10 Fri May 28 18:35:39 2004 +++ llvm/lib/Support/PluginLoader.cpp Sat Jul 10 20:04:33 2004 @@ -7,34 +7,19 @@ // //===----------------------------------------------------------------------===// // -// This file implements the -load command line option processor. When -// linked into a program, this new command line option is available that allows -// users to load shared objects into the running program. -// -// Note that there are no symbols exported by the .o file generated for this -// .cpp file. Because of this, a program must link against support.o instead of -// support.a: otherwise this translation unit will not be included. +// This file implements the -load command line option handler. // //===----------------------------------------------------------------------===// +#define DONT_GET_PLUGIN_LOADER_OPTION +#include "Support/PluginLoader.h" #include "Support/DynamicLinker.h" -#include "Support/CommandLine.h" -#include "Config/config.h" #include using namespace llvm; -namespace { - struct PluginLoader { - void operator=(const std::string &Filename) { - std::string ErrorMessage; - if (LinkDynamicObject (Filename.c_str (), &ErrorMessage)) - std::cerr << "Error opening '" << Filename << "': " << ErrorMessage - << "\n -load request ignored.\n"; - } - }; +void PluginLoader::operator=(const std::string &Filename) { + std::string ErrorMessage; + if (LinkDynamicObject(Filename.c_str(), &ErrorMessage)) + std::cerr << "Error opening '" << Filename << "': " << ErrorMessage + << "\n -load request ignored.\n"; } - -// This causes operator= above to be invoked for every -load option. -static cl::opt > -LoadOpt("load", cl::ZeroOrMore, cl::value_desc("plugin" SHLIBEXT), - cl::desc("Load the specified plugin")); From lattner at cs.uiuc.edu Sat Jul 10 20:05:10 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 20:05:10 2004 Subject: [llvm-commits] CVS: llvm/include/Support/PluginLoader.h Message-ID: <200407110104.UAA20130@apoc.cs.uiuc.edu> Changes in directory llvm/include/Support: PluginLoader.h added (r1.1) --- Log message: Add a new header --- Diffs of the changes: (+35 -0) Index: llvm/include/Support/PluginLoader.h diff -c /dev/null llvm/include/Support/PluginLoader.h:1.1 *** /dev/null Sat Jul 10 20:04:07 2004 --- llvm/include/Support/PluginLoader.h Sat Jul 10 20:03:57 2004 *************** *** 0 **** --- 1,35 ---- + //===-- Support/PluginLoader.h - Provide -load option to tool ---*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // A tool can #include this file to get a -load option that allows the user to + // load arbitrary shared objects into the tool's address space. Note that this + // header can only be included by a program ONCE, so it should never to used by + // library authors. + // + //===----------------------------------------------------------------------===// + + #ifndef SUPPORT_PLUGINLOADER_H + #define SUPPORT_PLUGINLOADER_H + + #include "Support/CommandLine.h" + + namespace llvm { + struct PluginLoader { + void operator=(const std::string &Filename); + }; + + #ifndef DONT_GET_PLUGIN_LOADER_OPTION + // This causes operator= above to be invoked for every -load option. + static cl::opt > + LoadOpt("load", cl::ZeroOrMore, cl::value_desc("pluginfilename"), + cl::desc("Load the specified plugin")); + #endif + } + + #endif From lattner at cs.uiuc.edu Sat Jul 10 20:07:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 20:07:01 2004 Subject: [llvm-commits] CVS: llvm/tools/bugpoint/bugpoint.cpp Message-ID: <200407110106.UAA20603@apoc.cs.uiuc.edu> Changes in directory llvm/tools/bugpoint: bugpoint.cpp updated: 1.16 -> 1.17 --- Log message: Add -load option --- Diffs of the changes: (+1 -0) Index: llvm/tools/bugpoint/bugpoint.cpp diff -u llvm/tools/bugpoint/bugpoint.cpp:1.16 llvm/tools/bugpoint/bugpoint.cpp:1.17 --- llvm/tools/bugpoint/bugpoint.cpp:1.16 Thu May 27 00:39:54 2004 +++ llvm/tools/bugpoint/bugpoint.cpp Sat Jul 10 20:06:20 2004 @@ -18,6 +18,7 @@ #include "llvm/Support/ToolRunner.h" #include "Support/CommandLine.h" #include "llvm/System/Signals.h" +#include "Support/PluginLoader.h" #include "Config/unistd.h" #include using namespace llvm; From lattner at cs.uiuc.edu Sat Jul 10 20:07:08 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 20:07:08 2004 Subject: [llvm-commits] CVS: llvm/tools/opt/opt.cpp Message-ID: <200407110106.UAA20177@apoc.cs.uiuc.edu> Changes in directory llvm/tools/opt: opt.cpp updated: 1.93 -> 1.94 --- Log message: Add -load option --- Diffs of the changes: (+1 -0) Index: llvm/tools/opt/opt.cpp diff -u llvm/tools/opt/opt.cpp:1.93 llvm/tools/opt/opt.cpp:1.94 --- llvm/tools/opt/opt.cpp:1.93 Thu May 27 15:32:10 2004 +++ llvm/tools/opt/opt.cpp Sat Jul 10 20:05:53 2004 @@ -22,6 +22,7 @@ #include "llvm/Target/TargetMachineImpls.h" #include "llvm/Support/PassNameParser.h" #include "llvm/System/Signals.h" +#include "Support/PluginLoader.h" #include "Support/SystemUtils.h" #include #include From lattner at cs.uiuc.edu Sat Jul 10 20:07:15 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 20:07:15 2004 Subject: [llvm-commits] CVS: llvm/tools/analyze/analyze.cpp Message-ID: <200407110105.UAA20169@apoc.cs.uiuc.edu> Changes in directory llvm/tools/analyze: analyze.cpp updated: 1.58 -> 1.59 --- Log message: Add -load option --- Diffs of the changes: (+1 -0) Index: llvm/tools/analyze/analyze.cpp diff -u llvm/tools/analyze/analyze.cpp:1.58 llvm/tools/analyze/analyze.cpp:1.59 --- llvm/tools/analyze/analyze.cpp:1.58 Thu May 27 00:39:49 2004 +++ llvm/tools/analyze/analyze.cpp Sat Jul 10 20:05:48 2004 @@ -24,6 +24,7 @@ #include "llvm/Target/TargetData.h" #include "llvm/Support/PassNameParser.h" #include "llvm/System/Signals.h" +#include "Support/PluginLoader.h" #include "Support/Timer.h" #include From lattner at cs.uiuc.edu Sat Jul 10 20:08:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 20:08:01 2004 Subject: [llvm-commits] CVS: llvm/tools/lli/lli.cpp Message-ID: <200407110107.UAA21040@apoc.cs.uiuc.edu> Changes in directory llvm/tools/lli: lli.cpp updated: 1.44 -> 1.45 --- Log message: Add a -load option --- Diffs of the changes: (+1 -0) Index: llvm/tools/lli/lli.cpp diff -u llvm/tools/lli/lli.cpp:1.44 llvm/tools/lli/lli.cpp:1.45 --- llvm/tools/lli/lli.cpp:1.44 Sun Jul 4 07:20:55 2004 +++ llvm/tools/lli/lli.cpp Sat Jul 10 20:06:59 2004 @@ -20,6 +20,7 @@ #include "llvm/ExecutionEngine/ExecutionEngine.h" #include "llvm/ExecutionEngine/GenericValue.h" #include "Support/CommandLine.h" +#include "Support/PluginLoader.h" #include "llvm/System/Signals.h" #include From lattner at cs.uiuc.edu Sat Jul 10 20:09:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 20:09:01 2004 Subject: [llvm-commits] CVS: llvm/tools/llvm-db/llvm-db.cpp Message-ID: <200407110108.UAA22524@apoc.cs.uiuc.edu> Changes in directory llvm/tools/llvm-db: llvm-db.cpp updated: 1.3 -> 1.4 --- Log message: Add -load option --- Diffs of the changes: (+1 -0) Index: llvm/tools/llvm-db/llvm-db.cpp diff -u llvm/tools/llvm-db/llvm-db.cpp:1.3 llvm/tools/llvm-db/llvm-db.cpp:1.4 --- llvm/tools/llvm-db/llvm-db.cpp:1.3 Thu May 27 00:39:32 2004 +++ llvm/tools/llvm-db/llvm-db.cpp Sat Jul 10 20:08:19 2004 @@ -14,6 +14,7 @@ #include "CLIDebugger.h" #include "Support/CommandLine.h" +#include "Support/PluginLoader.h" #include "llvm/System/Signals.h" #include From lattner at cs.uiuc.edu Sat Jul 10 21:44:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 21:44:02 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetMachine.h Message-ID: <200407110243.VAA13014@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: TargetMachine.h updated: 1.47 -> 1.48 --- Log message: Add two new "virtual static" methods to the TargetMachine class --- Diffs of the changes: (+14 -0) Index: llvm/include/llvm/Target/TargetMachine.h diff -u llvm/include/llvm/Target/TargetMachine.h:1.47 llvm/include/llvm/Target/TargetMachine.h:1.48 --- llvm/include/llvm/Target/TargetMachine.h:1.47 Thu Jul 1 15:42:00 2004 +++ llvm/include/llvm/Target/TargetMachine.h Sat Jul 10 21:43:07 2004 @@ -62,6 +62,20 @@ public: virtual ~TargetMachine(); + /// getModuleMatchQuality - This static method should be implemented by + /// targets to indicate how closely they match the specified module. This is + /// used by the LLC tool to determine which target to use when an explicit + /// -march option is not specified. If a target returns zero, it will never + /// be chosen without an explicit -march option. + static unsigned getModuleMatchQuality(const Module &M) { return 0; } + + /// getJITMatchQuality - This static method should be implemented by targets + /// that provide JIT capabilities to indicate how suitable they are for + /// execution on the current host. If a value of 0 is returned, the target + /// will not be used unless an explicit -march option is used. + static unsigned getJITMatchQuality() { return 0; } + + const std::string &getName() const { return Name; } /// getIntrinsicLowering - This method returns a reference to an From lattner at cs.uiuc.edu Sat Jul 10 21:45:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 21:45:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetMachineRegistry.h Message-ID: <200407110243.VAA13025@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: TargetMachineRegistry.h added (r1.1) --- Log message: First cut at TargetMachineRegistry and RegisterTarget classes --- Diffs of the changes: (+76 -0) Index: llvm/include/llvm/Target/TargetMachineRegistry.h diff -c /dev/null llvm/include/llvm/Target/TargetMachineRegistry.h:1.1 *** /dev/null Sat Jul 10 21:43:54 2004 --- llvm/include/llvm/Target/TargetMachineRegistry.h Sat Jul 10 21:43:43 2004 *************** *** 0 **** --- 1,76 ---- + //===-- Target/TargetMachineRegistry.h - Target Registration ----*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file exposes two classes: the TargetMachineRegistry class, which allows + // tools to inspect all of registered targets, and the RegisterTarget class, + // which TargetMachine implementations should use to register themselves with + // the system. + // + //===----------------------------------------------------------------------===// + + #ifndef LLVM_TARGET_TARGETMACHINEREGISTRY_H + #define LLVM_TARGET_TARGETMACHINEREGISTRY_H + + namespace llvm { + class Module; + class TargetMachine; + class IntrinsicLowering; + + struct TargetMachineRegistry { + /// Entry - One instance of this struct is created for each target that is + /// registered. + struct Entry { + const char *Name; + const char *ShortDesc; + TargetMachine *(*CtorFn)(const Module &, IntrinsicLowering*); + unsigned (*ModuleMatchQualityFn)(const Module &M); + unsigned (*JITMatchQualityFn)(); + + const Entry *getNext() const { return Next; } + + protected: + Entry(const char *N, const char *SD, + TargetMachine *(*CF)(const Module &, IntrinsicLowering*), + unsigned (*MMF)(const Module &M), unsigned (*JMF)()) + : Name(N), ShortDesc(SD), CtorFn(CF), ModuleMatchQualityFn(MMF), + JITMatchQualityFn(JMF), Next(List) { + List = this; + } + private: + const Entry *Next; // Next entry in the linked list. + }; + + /// TargetMachineRegistry::getList - This static method returns the list of + /// target machines that are registered with the system. + static const Entry *getList() { return List; } + + private: + static const Entry *List; + }; + + //===--------------------------------------------------------------------===// + /// RegisterTarget - This class is used to make targets automatically register + /// themselves with the tool they are linked. Targets should define an + /// instance of this and implement the static methods described in the + /// TargetMachine comments.. + template + struct RegisterTarget : public TargetMachineRegistry::Entry { + RegisterTarget(const char *Name, const char *ShortDesc) : + TargetMachineRegistry::Entry(Name, ShortDesc, &Allocator, + &TargetMachineImpl::getModuleMatchQuality, + &TargetMachineImpl::getJITMatchQuality) { + } + private: + static TargetMachine *Allocator(const Module &M, IntrinsicLowering *IL) { + return new TargetMachineImpl(M, IL); + } + }; + } + + #endif From lattner at cs.uiuc.edu Sat Jul 10 21:45:09 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 21:45:09 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/TargetMachineRegistry.cpp Message-ID: <200407110244.VAA13040@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target: TargetMachineRegistry.cpp added (r1.1) --- Log message: Initial impl of this file. Yes this is pretty useless right now, but it will grow in time. --- Diffs of the changes: (+21 -0) Index: llvm/lib/Target/TargetMachineRegistry.cpp diff -c /dev/null llvm/lib/Target/TargetMachineRegistry.cpp:1.1 *** /dev/null Sat Jul 10 21:44:36 2004 --- llvm/lib/Target/TargetMachineRegistry.cpp Sat Jul 10 21:44:26 2004 *************** *** 0 **** --- 1,21 ---- + //===-- TargetMachineRegistry.cpp - Target Auto Registration Impl ---------===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file exposes the RegisterTarget class, which TargetMachine + // implementations should use to register themselves with the system. This file + // also exposes the TargetMachineRegistry class, which allows tools to inspect + // all of registered targets. + // + //===----------------------------------------------------------------------===// + + #include "llvm/Target/TargetMachineRegistry.h" + using namespace llvm; + + const TargetMachineRegistry::Entry *TargetMachineRegistry::List = 0; + From lattner at cs.uiuc.edu Sat Jul 10 21:46:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 21:46:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86TargetMachine.cpp X86TargetMachine.h Message-ID: <200407110245.VAA13067@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86TargetMachine.cpp updated: 1.59 -> 1.60 X86TargetMachine.h updated: 1.24 -> 1.25 --- Log message: Auto-registrate target --- Diffs of the changes: (+25 -0) Index: llvm/lib/Target/X86/X86TargetMachine.cpp diff -u llvm/lib/Target/X86/X86TargetMachine.cpp:1.59 llvm/lib/Target/X86/X86TargetMachine.cpp:1.60 --- llvm/lib/Target/X86/X86TargetMachine.cpp:1.59 Fri Jul 2 00:46:41 2004 +++ llvm/lib/Target/X86/X86TargetMachine.cpp Sat Jul 10 21:44:51 2004 @@ -19,6 +19,7 @@ #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/Passes.h" #include "llvm/Target/TargetMachineImpls.h" +#include "llvm/Target/TargetMachineRegistry.h" #include "llvm/Transforms/Scalar.h" #include "Support/CommandLine.h" #include "Support/Statistic.h" @@ -35,6 +36,9 @@ "when profiling the code generator.")); cl::opt NoSimpleISel("disable-simple-isel", cl::init(true), cl::desc("Use the hand coded 'simple' X86 instruction selector")); + + // Register the target. + RegisterTarget X("x86", "IA-32 (Pentium and above)"); } // allocateX86TargetMachine - Allocate and return a subclass of TargetMachine @@ -45,6 +49,24 @@ return new X86TargetMachine(M, IL); } +unsigned X86TargetMachine::getJITMatchQuality() { +#if defined(i386) || defined(__i386__) || defined(__x86__) + return 10; +#else + return 0; +#endif +} + +unsigned X86TargetMachine::getModuleMatchQuality(const Module &M) { + if (M.getEndianness() == Module::LittleEndian && + M.getPointerSize() == Module::Pointer32) + return 10; // Direct match + else if (M.getEndianness() != Module::AnyEndianness || + M.getPointerSize() != Module::AnyPointerSize) + return 0; // Match for some other target + + return getJITMatchQuality()/2; +} /// X86TargetMachine ctor - Create an ILP32 architecture model /// Index: llvm/lib/Target/X86/X86TargetMachine.h diff -u llvm/lib/Target/X86/X86TargetMachine.h:1.24 llvm/lib/Target/X86/X86TargetMachine.h:1.25 --- llvm/lib/Target/X86/X86TargetMachine.h:1.24 Wed Jun 2 00:55:25 2004 +++ llvm/lib/Target/X86/X86TargetMachine.h Sat Jul 10 21:44:51 2004 @@ -47,6 +47,9 @@ MachineCodeEmitter &MCE); virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out); + + static unsigned getModuleMatchQuality(const Module &M); + static unsigned getJITMatchQuality(); }; // this is implemented in X86CodeEmitter.cpp From lattner at cs.uiuc.edu Sat Jul 10 21:46:07 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 21:46:07 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp SparcV9TargetMachine.h Message-ID: <200407110245.VAA13086@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: SparcV9TargetMachine.cpp updated: 1.115 -> 1.116 SparcV9TargetMachine.h updated: 1.10 -> 1.11 --- Log message: Auto-registrate target --- Diffs of the changes: (+33 -6) Index: llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp diff -u llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp:1.115 llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp:1.116 --- llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp:1.115 Sun Jun 20 02:47:30 2004 +++ llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp Sat Jul 10 21:45:11 2004 @@ -24,12 +24,12 @@ #include "llvm/CodeGen/MachineCodeForInstruction.h" #include "llvm/CodeGen/Passes.h" #include "llvm/Target/TargetMachineImpls.h" +#include "llvm/Target/TargetMachineRegistry.h" #include "llvm/Transforms/Scalar.h" #include "MappingInfo.h" #include "SparcV9Internals.h" #include "SparcV9TargetMachine.h" #include "Support/CommandLine.h" - using namespace llvm; static const unsigned ImplicitRegUseList[] = { 0 }; /* not used yet */ @@ -59,6 +59,28 @@ cl::opt DisableStrip("disable-strip", cl::desc("Do not strip the LLVM bytecode in executable")); + + // Register the target. + RegisterTarget X("sparcv9", "SPARC V9"); +} + +unsigned SparcV9TargetMachine::getJITMatchQuality() { +#if defined(sparc) || defined(__sparc__) || defined(__sparcv9) + return 10; +#else + return 0; +#endif +} + +unsigned SparcV9TargetMachine::getModuleMatchQuality(const Module &M) { + if (M.getEndianness() == Module::BigEndian && + M.getPointerSize() == Module::Pointer64) + return 10; // Direct match + else if (M.getEndianness() != Module::AnyEndianness || + M.getPointerSize() != Module::AnyPointerSize) + return 0; // Match for some other target + + return getJITMatchQuality()/2; } //===---------------------------------------------------------------------===// @@ -111,7 +133,8 @@ } -SparcV9TargetMachine::SparcV9TargetMachine(IntrinsicLowering *il) +SparcV9TargetMachine::SparcV9TargetMachine(const Module &M, + IntrinsicLowering *il) : TargetMachine("UltraSparcV9-Native", il, false), schedInfo(*this), regInfo(*this), @@ -264,10 +287,11 @@ PM.add(createMachineFunctionPrinterPass(&std::cerr, "Final code:\n")); } -/// allocateSparcV9TargetMachine - Allocate and return a subclass of TargetMachine -/// that implements the SparcV9 backend. (the llvm/CodeGen/SparcV9.h interface) +/// allocateSparcV9TargetMachine - Allocate and return a subclass of +/// TargetMachine that implements the SparcV9 backend. (the +/// llvm/CodeGen/SparcV9.h interface) /// TargetMachine *llvm::allocateSparcV9TargetMachine(const Module &M, IntrinsicLowering *IL) { - return new SparcV9TargetMachine(IL); + return new SparcV9TargetMachine(M, IL); } Index: llvm/lib/Target/SparcV9/SparcV9TargetMachine.h diff -u llvm/lib/Target/SparcV9/SparcV9TargetMachine.h:1.10 llvm/lib/Target/SparcV9/SparcV9TargetMachine.h:1.11 --- llvm/lib/Target/SparcV9/SparcV9TargetMachine.h:1.10 Wed Jun 2 21:45:09 2004 +++ llvm/lib/Target/SparcV9/SparcV9TargetMachine.h Sat Jul 10 21:45:11 2004 @@ -32,7 +32,7 @@ SparcV9FrameInfo frameInfo; SparcV9JITInfo jitInfo; public: - SparcV9TargetMachine(IntrinsicLowering *IL); + SparcV9TargetMachine(const Module &M, IntrinsicLowering *IL); virtual const TargetInstrInfo *getInstrInfo() const { return &instrInfo; } virtual const TargetSchedInfo *getSchedInfo() const { return &schedInfo; } @@ -46,6 +46,9 @@ virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out); virtual bool addPassesToEmitMachineCode(FunctionPassManager &PM, MachineCodeEmitter &MCE); + + static unsigned getModuleMatchQuality(const Module &M); + static unsigned getJITMatchQuality(); }; } // End llvm namespace From lattner at cs.uiuc.edu Sat Jul 10 21:47:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 21:47:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp Message-ID: <200407110246.VAA13115@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PowerPCTargetMachine.cpp updated: 1.8 -> 1.9 --- Log message: Auto-registrate target --- Diffs of the changes: (+6 -0) Index: llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp diff -u llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.8 llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.9 --- llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.8 Thu Jun 10 01:19:25 2004 +++ llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp Sat Jul 10 21:46:18 2004 @@ -15,10 +15,16 @@ #include "llvm/Module.h" #include "llvm/PassManager.h" #include "llvm/Target/TargetMachineImpls.h" +#include "llvm/Target/TargetMachineRegistry.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/Passes.h" using namespace llvm; +namespace { + // Register the target. + RegisterTarget X("powerpc", "PowerPC (experimental)"); +} + // allocatePowerPCTargetMachine - Allocate and return a subclass of // TargetMachine that implements the PowerPC backend. // From lattner at cs.uiuc.edu Sat Jul 10 21:50:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 21:50:00 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/CTargetMachine.h Writer.cpp Message-ID: <200407110248.VAA14561@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/CBackend: CTargetMachine.h updated: 1.4 -> 1.5 Writer.cpp updated: 1.184 -> 1.185 --- Log message: Auto-registrate target --- Diffs of the changes: (+7 -0) Index: llvm/lib/Target/CBackend/CTargetMachine.h diff -u llvm/lib/Target/CBackend/CTargetMachine.h:1.4 llvm/lib/Target/CBackend/CTargetMachine.h:1.5 --- llvm/lib/Target/CBackend/CTargetMachine.h:1.4 Wed Jun 2 00:53:52 2004 +++ llvm/lib/Target/CBackend/CTargetMachine.h Sat Jul 10 21:48:49 2004 @@ -25,6 +25,9 @@ // This is the only thing that actually does anything here. virtual bool addPassesToEmitAssembly(PassManager &PM, std::ostream &Out); + + // This class always works, but shouldn't be the default in most cases. + static unsigned getModuleMatchQuality(const Module &M) { return 1; } }; } // End llvm namespace Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.184 llvm/lib/Target/CBackend/Writer.cpp:1.185 --- llvm/lib/Target/CBackend/Writer.cpp:1.184 Sun Jul 4 07:19:56 2004 +++ llvm/lib/Target/CBackend/Writer.cpp Sat Jul 10 21:48:49 2004 @@ -27,6 +27,7 @@ #include "llvm/Analysis/LoopInfo.h" #include "llvm/CodeGen/IntrinsicLowering.h" #include "llvm/Transforms/Scalar.h" +#include "llvm/Target/TargetMachineRegistry.h" #include "llvm/Support/CallSite.h" #include "llvm/Support/CFG.h" #include "llvm/Support/GetElementPtrTypeIterator.h" @@ -40,6 +41,9 @@ using namespace llvm; namespace { + // Register the target. + RegisterTarget X("c", "C backend"); + /// NameAllUsedStructs - This pass inserts names for any unnamed structure /// types that are used by the program. /// From lattner at cs.uiuc.edu Sat Jul 10 22:19:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 22:19:01 2004 Subject: [llvm-commits] CVS: llvm/include/Support/CommandLine.h Message-ID: <200407110318.WAA16818@apoc.cs.uiuc.edu> Changes in directory llvm/include/Support: CommandLine.h updated: 1.32 -> 1.33 --- Log message: Provide better support for pointer-valued command line arguments --- Diffs of the changes: (+3 -0) Index: llvm/include/Support/CommandLine.h diff -u llvm/include/Support/CommandLine.h:1.32 llvm/include/Support/CommandLine.h:1.33 --- llvm/include/Support/CommandLine.h:1.32 Thu Jun 3 17:07:26 2004 +++ llvm/include/Support/CommandLine.h Sat Jul 10 22:18:30 2004 @@ -711,6 +711,9 @@ void setValue(const T &V) { Value = V; } DataType &getValue() { return Value; } DataType getValue() const { return Value; } + + // If the datatype is a pointer, support -> on it. + DataType operator->() const { return Value; } }; From lattner at cs.uiuc.edu Sat Jul 10 22:28:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 22:28:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86TargetMachine.cpp Message-ID: <200407110327.WAA20027@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86TargetMachine.cpp updated: 1.60 -> 1.61 --- Log message: Make these format a bit nicer --- Diffs of the changes: (+1 -1) Index: llvm/lib/Target/X86/X86TargetMachine.cpp diff -u llvm/lib/Target/X86/X86TargetMachine.cpp:1.60 llvm/lib/Target/X86/X86TargetMachine.cpp:1.61 --- llvm/lib/Target/X86/X86TargetMachine.cpp:1.60 Sat Jul 10 21:44:51 2004 +++ llvm/lib/Target/X86/X86TargetMachine.cpp Sat Jul 10 22:27:35 2004 @@ -38,7 +38,7 @@ cl::desc("Use the hand coded 'simple' X86 instruction selector")); // Register the target. - RegisterTarget X("x86", "IA-32 (Pentium and above)"); + RegisterTarget X("x86", " IA-32 (Pentium and above)"); } // allocateX86TargetMachine - Allocate and return a subclass of TargetMachine From lattner at cs.uiuc.edu Sat Jul 10 22:29:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 22:29:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp Message-ID: <200407110327.WAA20048@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PowerPCTargetMachine.cpp updated: 1.9 -> 1.10 --- Log message: Make these format a bit nicer --- Diffs of the changes: (+1 -1) Index: llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp diff -u llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.9 llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.10 --- llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.9 Sat Jul 10 21:46:18 2004 +++ llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp Sat Jul 10 22:27:40 2004 @@ -22,7 +22,7 @@ namespace { // Register the target. - RegisterTarget X("powerpc", "PowerPC (experimental)"); + RegisterTarget X("powerpc", " PowerPC (experimental)"); } // allocatePowerPCTargetMachine - Allocate and return a subclass of From lattner at cs.uiuc.edu Sat Jul 10 22:29:08 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 22:29:08 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp Message-ID: <200407110327.WAA20034@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/CBackend: Writer.cpp updated: 1.185 -> 1.186 --- Log message: Make these format a bit nicer --- Diffs of the changes: (+1 -1) Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.185 llvm/lib/Target/CBackend/Writer.cpp:1.186 --- llvm/lib/Target/CBackend/Writer.cpp:1.185 Sat Jul 10 21:48:49 2004 +++ llvm/lib/Target/CBackend/Writer.cpp Sat Jul 10 22:27:40 2004 @@ -42,7 +42,7 @@ namespace { // Register the target. - RegisterTarget X("c", "C backend"); + RegisterTarget X("c", " C backend"); /// NameAllUsedStructs - This pass inserts names for any unnamed structure /// types that are used by the program. From lattner at cs.uiuc.edu Sat Jul 10 22:29:15 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 22:29:15 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp Message-ID: <200407110327.WAA20041@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: SparcV9TargetMachine.cpp updated: 1.116 -> 1.117 --- Log message: Make these format a bit nicer --- Diffs of the changes: (+1 -1) Index: llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp diff -u llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp:1.116 llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp:1.117 --- llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp:1.116 Sat Jul 10 21:45:11 2004 +++ llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp Sat Jul 10 22:27:40 2004 @@ -61,7 +61,7 @@ cl::desc("Do not strip the LLVM bytecode in executable")); // Register the target. - RegisterTarget X("sparcv9", "SPARC V9"); + RegisterTarget X("sparcv9", " SPARC V9"); } unsigned SparcV9TargetMachine::getJITMatchQuality() { From lattner at cs.uiuc.edu Sat Jul 10 23:01:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 23:01:00 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/TargetMachineRegistry.cpp Message-ID: <200407110400.XAA30004@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target: TargetMachineRegistry.cpp updated: 1.1 -> 1.2 --- Log message: Implement a couple of methods that TargetMachineRegistry now provides. See, I told you this file wasn't useless :) --- Diffs of the changes: (+60 -0) Index: llvm/lib/Target/TargetMachineRegistry.cpp diff -u llvm/lib/Target/TargetMachineRegistry.cpp:1.1 llvm/lib/Target/TargetMachineRegistry.cpp:1.2 --- llvm/lib/Target/TargetMachineRegistry.cpp:1.1 Sat Jul 10 21:44:26 2004 +++ llvm/lib/Target/TargetMachineRegistry.cpp Sat Jul 10 23:00:19 2004 @@ -15,7 +15,67 @@ //===----------------------------------------------------------------------===// #include "llvm/Target/TargetMachineRegistry.h" +#include using namespace llvm; const TargetMachineRegistry::Entry *TargetMachineRegistry::List = 0; +/// getClosestStaticTargetForModule - Given an LLVM module, pick the best target +/// that is compatible with the module. If no close target can be found, this +/// returns null and sets the Error string to a reason. +const TargetMachineRegistry::Entry * +TargetMachineRegistry::getClosestStaticTargetForModule(const Module &M, + std::string &Error) { + std::vector > UsableTargets; + for (const Entry *E = getList(); E; E = E->getNext()) + if (unsigned Qual = E->ModuleMatchQualityFn(M)) + UsableTargets.push_back(std::make_pair(Qual, E)); + + if (UsableTargets.empty()) { + Error = "No available targets are compatible with this module"; + return 0; + } else if (UsableTargets.size() == 1) + return UsableTargets.back().second; + + // Otherwise, take the best target, but make sure we don't have to equally + // good best targets. + std::sort(UsableTargets.begin(), UsableTargets.end()); + if (UsableTargets.back().first ==UsableTargets[UsableTargets.size()-2].first){ + Error = "Cannot choose between targets \"" + + std::string(UsableTargets.back().second->Name) + "\" and \"" + + std::string(UsableTargets[UsableTargets.size()-2].second->Name) + "\""; + return 0; + } + return UsableTargets.back().second; +} + +/// getClosestTargetForJIT - Given an LLVM module, pick the best target that +/// is compatible with the current host and the specified module. If no +/// close target can be found, this returns null and sets the Error string +/// to a reason. +const TargetMachineRegistry::Entry * +TargetMachineRegistry::getClosestTargetForJIT(std::string &Error) { + std::vector > UsableTargets; + for (const Entry *E = getList(); E; E = E->getNext()) + if (unsigned Qual = E->JITMatchQualityFn()) + UsableTargets.push_back(std::make_pair(Qual, E)); + + if (UsableTargets.empty()) { + Error = "No JIT is available for this host"; + return 0; + } else if (UsableTargets.size() == 1) + return UsableTargets.back().second; + + // Otherwise, take the best target. If there is a tie, just pick one. + unsigned MaxQual = UsableTargets.front().first; + const Entry *MaxQualTarget = UsableTargets.front().second; + + for (unsigned i = 1, e = UsableTargets.size(); i != e; ++i) + if (UsableTargets[i].first > MaxQual) { + MaxQual = UsableTargets[i].first; + MaxQualTarget = UsableTargets[i].second; + } + + return MaxQualTarget; +} + From lattner at cs.uiuc.edu Sat Jul 10 23:01:08 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 23:01:08 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetMachineRegistry.h Message-ID: <200407110359.WAA29985@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: TargetMachineRegistry.h updated: 1.1 -> 1.2 --- Log message: Add a new TargetNameParser class, which is useful for parsing options. Add two methods which are useful for autoselecting targets. --- Diffs of the changes: (+36 -4) Index: llvm/include/llvm/Target/TargetMachineRegistry.h diff -u llvm/include/llvm/Target/TargetMachineRegistry.h:1.1 llvm/include/llvm/Target/TargetMachineRegistry.h:1.2 --- llvm/include/llvm/Target/TargetMachineRegistry.h:1.1 Sat Jul 10 21:43:43 2004 +++ llvm/include/llvm/Target/TargetMachineRegistry.h Sat Jul 10 22:59:46 2004 @@ -17,12 +17,33 @@ #ifndef LLVM_TARGET_TARGETMACHINEREGISTRY_H #define LLVM_TARGET_TARGETMACHINEREGISTRY_H +#include "Support/CommandLine.h" + namespace llvm { class Module; class TargetMachine; class IntrinsicLowering; struct TargetMachineRegistry { + struct Entry; + + /// TargetMachineRegistry::getList - This static method returns the list of + /// target machines that are registered with the system. + static const Entry *getList() { return List; } + + /// getClosestStaticTargetForModule - Given an LLVM module, pick the best + /// target that is compatible with the module. If no close target can be + /// found, this returns null and sets the Error string to a reason. + static const Entry *getClosestStaticTargetForModule(const Module &M, + std::string &Error); + + /// getClosestTargetForJIT - Given an LLVM module, pick the best target that + /// is compatible with the current host and the specified module. If no + /// close target can be found, this returns null and sets the Error string + /// to a reason. + static const Entry *getClosestTargetForJIT(std::string &Error); + + /// Entry - One instance of this struct is created for each target that is /// registered. struct Entry { @@ -46,10 +67,6 @@ const Entry *Next; // Next entry in the linked list. }; - /// TargetMachineRegistry::getList - This static method returns the list of - /// target machines that are registered with the system. - static const Entry *getList() { return List; } - private: static const Entry *List; }; @@ -71,6 +88,21 @@ return new TargetMachineImpl(M, IL); } }; + + //===--------------------------------------------------------------------===// + /// TargetNameParser - This option can be used to provide a command line + /// option to choose among the various registered targets (commonly -march). + class TargetNameParser : + public cl::parser { + public: + void initialize(cl::Option &O) { + for (const TargetMachineRegistry::Entry *E = + TargetMachineRegistry::getList(); E; E = E->getNext()) + Values.push_back(std::make_pair(E->Name, + std::make_pair(E, E->ShortDesc))); + cl::parser::initialize(O); + } + }; } #endif From lattner at cs.uiuc.edu Sat Jul 10 23:03:02 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 23:03:02 2004 Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/JIT/TargetSelect.cpp Message-ID: <200407110402.XAA31856@apoc.cs.uiuc.edu> Changes in directory llvm/lib/ExecutionEngine/JIT: TargetSelect.cpp updated: 1.4 -> 1.5 --- Log message: Goodbye macro hell, hello nice clean simple extensible code. This change also gives the JIT the ability to dynamically load targets. e.g. lli -load libparisc.so -march=parisc foo.bc --- Diffs of the changes: (+13 -55) Index: llvm/lib/ExecutionEngine/JIT/TargetSelect.cpp diff -u llvm/lib/ExecutionEngine/JIT/TargetSelect.cpp:1.4 llvm/lib/ExecutionEngine/JIT/TargetSelect.cpp:1.5 --- llvm/lib/ExecutionEngine/JIT/TargetSelect.cpp:1.4 Wed Feb 25 16:09:36 2004 +++ llvm/lib/ExecutionEngine/JIT/TargetSelect.cpp Sat Jul 10 23:02:06 2004 @@ -19,69 +19,29 @@ #include "llvm/Module.h" #include "llvm/ModuleProvider.h" #include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetMachineImpls.h" -#include "Support/CommandLine.h" +#include "llvm/Target/TargetMachineRegistry.h" +#include using namespace llvm; -#if !defined(ENABLE_X86_JIT) && !defined(ENABLE_SPARC_JIT) -#define NO_JITS_ENABLED -#endif - -namespace { - enum ArchName { x86, SparcV9 }; - -#ifndef NO_JITS_ENABLED - cl::opt - Arch("march", cl::desc("Architecture to JIT to:"), cl::Prefix, - cl::values( -#ifdef ENABLE_X86_JIT - clEnumVal(x86, " IA-32 (Pentium and above)"), -#endif -#ifdef ENABLE_SPARC_JIT - clEnumValN(SparcV9, "sparcv9", " Sparc-V9"), -#endif - 0), -#if defined(ENABLE_X86_JIT) - cl::init(x86) -#elif defined(ENABLE_SPARC_JIT) - cl::init(SparcV9) -#endif - ); -#endif /* NO_JITS_ENABLED */ -} +static cl::opt +MArch("march", cl::desc("Architecture to generate assembly for:")); /// create - Create an return a new JIT compiler if there is one available /// for the current target. Otherwise, return null. /// ExecutionEngine *JIT::create(ModuleProvider *MP, IntrinsicLowering *IL) { - TargetMachine* (*TargetMachineAllocator)(const Module &, - IntrinsicLowering *IL) = 0; - - // Allow a command-line switch to override what *should* be the default target - // machine for this platform. This allows for debugging a Sparc JIT on X86 -- - // our X86 machines are much faster at recompiling LLVM and linking LLI. -#ifndef NO_JITS_ENABLED - - switch (Arch) { -#ifdef ENABLE_X86_JIT - case x86: - TargetMachineAllocator = allocateX86TargetMachine; - break; -#endif -#ifdef ENABLE_SPARC_JIT - case SparcV9: - TargetMachineAllocator = allocateSparcV9TargetMachine; - break; -#endif - default: - assert(0 && "-march flag not supported on this host!"); + if (MArch == 0) { + std::string Error; + MArch = TargetMachineRegistry::getClosestTargetForJIT(Error); + if (MArch == 0) return 0; + } else if (MArch->JITMatchQualityFn() == 0) { + std::cerr << "WARNING: This target JIT is not designed for the host you are" + << " running. If bad things happen, please choose a different " + << "-march switch.\n"; } -#else - return 0; -#endif // Allocate a target... - TargetMachine *Target = TargetMachineAllocator(*MP->getModule(), IL); + TargetMachine *Target = MArch->CtorFn(*MP->getModule(), IL); assert(Target && "Could not allocate target machine!"); // If the target supports JIT code generation, return a new JIT now. @@ -89,5 +49,3 @@ return new JIT(MP, *Target, *TJ); return 0; } - - From lattner at cs.uiuc.edu Sat Jul 10 23:04:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 23:04:01 2004 Subject: [llvm-commits] CVS: llvm/tools/llc/llc.cpp Message-ID: <200407110403.XAA31875@apoc.cs.uiuc.edu> Changes in directory llvm/tools/llc: llc.cpp updated: 1.98 -> 1.99 --- Log message: Goodbye macro hell, hello nice clean and simple code. This also gives llc the ability to dynamically load and use targets that are not linked into it statically. e.g.: llc -load libparisc.so -march=parisc foo.bc -o foo.s --- Diffs of the changes: (+17 -58) Index: llvm/tools/llc/llc.cpp diff -u llvm/tools/llc/llc.cpp:1.98 llvm/tools/llc/llc.cpp:1.99 --- llvm/tools/llc/llc.cpp:1.98 Sun Jul 4 07:20:55 2004 +++ llvm/tools/llc/llc.cpp Sat Jul 10 23:03:24 2004 @@ -14,13 +14,14 @@ //===----------------------------------------------------------------------===// #include "llvm/Bytecode/Reader.h" -#include "llvm/Target/TargetMachineImpls.h" #include "llvm/Target/TargetMachine.h" +#include "llvm/Target/TargetMachineRegistry.h" #include "llvm/Transforms/Scalar.h" #include "llvm/Module.h" #include "llvm/PassManager.h" #include "llvm/Pass.h" #include "Support/CommandLine.h" +#include "Support/PluginLoader.h" #include "llvm/System/Signals.h" #include #include @@ -40,21 +41,13 @@ static cl::opt Force("f", cl::desc("Overwrite output files")); -enum ArchName { noarch, X86, SparcV9, PowerPC, CBackend }; - -static cl::opt -Arch("march", cl::desc("Architecture to generate assembly for:"), cl::Prefix, - cl::values(clEnumValN(X86, "x86", " IA-32 (Pentium and above)"), - clEnumValN(SparcV9, "sparcv9", " SPARC V9"), - clEnumValN(PowerPC, "powerpc", " PowerPC (experimental)"), - clEnumValN(CBackend, "c", " C backend"), - 0), - cl::init(noarch)); +static cl::opt +MArch("march", cl::desc("Architecture to generate assembly for:")); + // GetFileNameRoot - Helper function to get the basename of a filename... static inline std::string -GetFileNameRoot(const std::string &InputFilename) -{ +GetFileNameRoot(const std::string &InputFilename) { std::string IFN = InputFilename; std::string outputFilename; int Len = IFN.length(); @@ -86,52 +79,18 @@ // explicitly specified an architecture to compile for. TargetMachine* (*TargetMachineAllocator)(const Module&, IntrinsicLowering *) = 0; - switch (Arch) { - case CBackend: - TargetMachineAllocator = allocateCTargetMachine; - break; - case X86: - TargetMachineAllocator = allocateX86TargetMachine; - break; - case SparcV9: - TargetMachineAllocator = allocateSparcV9TargetMachine; - break; - case PowerPC: - TargetMachineAllocator = allocatePowerPCTargetMachine; - break; - default: - // Decide what the default target machine should be, by looking at - // the module. This heuristic (ILP32, LE -> IA32; LP64, BE -> - // SPARCV9) is kind of gross, but it will work until we have more - // sophisticated target information to work from. - if (mod.getEndianness() == Module::LittleEndian && - mod.getPointerSize() == Module::Pointer32) { - TargetMachineAllocator = allocateX86TargetMachine; - } else if (mod.getEndianness() == Module::BigEndian && - mod.getPointerSize() == Module::Pointer32) { - TargetMachineAllocator = allocatePowerPCTargetMachine; - } else if (mod.getEndianness() == Module::BigEndian && - mod.getPointerSize() == Module::Pointer64) { - TargetMachineAllocator = allocateSparcV9TargetMachine; - } else { - // If the module is target independent, favor a target which matches the - // current build system. -#if defined(i386) || defined(__i386__) || defined(__x86__) - TargetMachineAllocator = allocateX86TargetMachine; -#elif defined(sparc) || defined(__sparc__) || defined(__sparcv9) - TargetMachineAllocator = allocateSparcV9TargetMachine; -#elif defined(__POWERPC__) || defined(__ppc__) || defined(__APPLE__) - TargetMachineAllocator = allocatePowerPCTargetMachine; -#else - std::cerr << argv[0] << ": module does not specify a target to use. " - << "You must use the -march option. If no native target is " - << "available, use -march=c to emit C code.\n"; + if (MArch == 0) { + std::string Err; + MArch = TargetMachineRegistry::getClosestStaticTargetForModule(mod, Err); + if (MArch == 0) { + std::cerr << argv[0] << ": error auto-selecting target for module '" + << Err << "'. Please use the -march option to explicitly " + << "pick a target.\n"; return 1; -#endif - } - break; + } } - std::auto_ptr target(TargetMachineAllocator(mod, 0)); + + std::auto_ptr target(MArch->CtorFn(mod, 0)); assert(target.get() && "Could not allocate target machine!"); TargetMachine &Target = *target.get(); const TargetData &TD = Target.getTargetData(); @@ -169,7 +128,7 @@ } else { OutputFilename = GetFileNameRoot(InputFilename); - if (Arch != CBackend) + if (MArch->Name[0] != 'c' || MArch->Name[1] != 0) // not CBE OutputFilename += ".s"; else OutputFilename += ".cbe.c"; From lattner at cs.uiuc.edu Sat Jul 10 23:05:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 23:05:01 2004 Subject: [llvm-commits] CVS: llvm/test/Programs/TEST.dsgraph.report Message-ID: <200407110404.XAA31888@apoc.cs.uiuc.edu> Changes in directory llvm/test/Programs: TEST.dsgraph.report updated: 1.9 -> 1.10 --- Log message: This should have been checked in long ago --- Diffs of the changes: (+2 -0) Index: llvm/test/Programs/TEST.dsgraph.report diff -u llvm/test/Programs/TEST.dsgraph.report:1.9 llvm/test/Programs/TEST.dsgraph.report:1.10 --- llvm/test/Programs/TEST.dsgraph.report:1.9 Fri Aug 22 19:30:13 2003 +++ llvm/test/Programs/TEST.dsgraph.report Sat Jul 10 23:04:10 2004 @@ -6,6 +6,8 @@ # Sort numerically, not textually... $SortNumeric = 1; +$TrimRepeatedPrefix = 1; + # Helper function sub Ratio { From lattner at cs.uiuc.edu Sat Jul 10 23:06:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 23:06:01 2004 Subject: [llvm-commits] CVS: llvm/tools/opt/opt.cpp Message-ID: <200407110405.XAA32115@apoc.cs.uiuc.edu> Changes in directory llvm/tools/opt: opt.cpp updated: 1.94 -> 1.95 --- Log message: Prune unused #include --- Diffs of the changes: (+0 -1) Index: llvm/tools/opt/opt.cpp diff -u llvm/tools/opt/opt.cpp:1.94 llvm/tools/opt/opt.cpp:1.95 --- llvm/tools/opt/opt.cpp:1.94 Sat Jul 10 20:05:53 2004 +++ llvm/tools/opt/opt.cpp Sat Jul 10 23:05:32 2004 @@ -19,7 +19,6 @@ #include "llvm/Assembly/PrintModulePass.h" #include "llvm/Analysis/Verifier.h" #include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetMachineImpls.h" #include "llvm/Support/PassNameParser.h" #include "llvm/System/Signals.h" #include "Support/PluginLoader.h" From lattner at cs.uiuc.edu Sat Jul 10 23:17:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 23:17:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetOptions.h TargetMachineImpls.h Message-ID: <200407110416.XAA00877@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: TargetOptions.h added (r1.1) TargetMachineImpls.h (r1.16) removed --- Log message: Delete the allocate*TargetMachine functions. Move options to a header file that makes sense. --- Diffs of the changes: (+30 -0) Index: llvm/include/llvm/Target/TargetOptions.h diff -c /dev/null llvm/include/llvm/Target/TargetOptions.h:1.1 *** /dev/null Sat Jul 10 23:16:02 2004 --- llvm/include/llvm/Target/TargetOptions.h Sat Jul 10 23:15:52 2004 *************** *** 0 **** --- 1,30 ---- + //===-- llvm/Target/TargetOptions.h - Target Options ------------*- C++ -*-===// + // + // The LLVM Compiler Infrastructure + // + // This file was developed by the LLVM research group and is distributed under + // the University of Illinois Open Source License. See LICENSE.TXT for details. + // + //===----------------------------------------------------------------------===// + // + // This file defines command line option flags that are shared across various + // targets. + // + //===----------------------------------------------------------------------===// + + #ifndef LLVM_TARGET_TARGETOPTIONS_H + #define LLVM_TARGET_TARGETOPTIONS_H + + namespace llvm { + /// PrintMachineCode - This flag is enabled when the -print-machineinstrs + /// option is specified on the command line, and should enable debugging + /// output from the code generator. + extern bool PrintMachineCode; + + /// NoFramePointerElim - This flag is enabled when the -disable-fp-elim is + /// specified on the command line. If the target supports the frame pointer + /// elimination optimization, this option should disable it. + extern bool NoFramePointerElim; + } // End llvm namespace + + #endif From lattner at cs.uiuc.edu Sat Jul 10 23:18:00 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 23:18:00 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp Message-ID: <200407110417.XAA01204@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/SparcV9: SparcV9TargetMachine.cpp updated: 1.117 -> 1.118 --- Log message: Delete the allocate*TargetMachine function, which is now dead . The shared command line options are now in a header that makes sense. --- Diffs of the changes: (+1 -9) Index: llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp diff -u llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp:1.117 llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp:1.118 --- llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp:1.117 Sat Jul 10 22:27:40 2004 +++ llvm/lib/Target/SparcV9/SparcV9TargetMachine.cpp Sat Jul 10 23:16:54 2004 @@ -23,7 +23,7 @@ #include "llvm/CodeGen/MachineFunctionInfo.h" #include "llvm/CodeGen/MachineCodeForInstruction.h" #include "llvm/CodeGen/Passes.h" -#include "llvm/Target/TargetMachineImpls.h" +#include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetMachineRegistry.h" #include "llvm/Transforms/Scalar.h" #include "MappingInfo.h" @@ -287,11 +287,3 @@ PM.add(createMachineFunctionPrinterPass(&std::cerr, "Final code:\n")); } -/// allocateSparcV9TargetMachine - Allocate and return a subclass of -/// TargetMachine that implements the SparcV9 backend. (the -/// llvm/CodeGen/SparcV9.h interface) -/// -TargetMachine *llvm::allocateSparcV9TargetMachine(const Module &M, - IntrinsicLowering *IL) { - return new SparcV9TargetMachine(M, IL); -} From lattner at cs.uiuc.edu Sat Jul 10 23:18:07 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 23:18:07 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/X86/X86RegisterInfo.cpp X86TargetMachine.cpp Message-ID: <200407110417.XAA00920@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/X86: X86RegisterInfo.cpp updated: 1.86 -> 1.87 X86TargetMachine.cpp updated: 1.61 -> 1.62 --- Log message: Delete the allocate*TargetMachine function, which is now dead . The shared command line options are now in a header that makes sense. --- Diffs of the changes: (+2 -10) Index: llvm/lib/Target/X86/X86RegisterInfo.cpp diff -u llvm/lib/Target/X86/X86RegisterInfo.cpp:1.86 llvm/lib/Target/X86/X86RegisterInfo.cpp:1.87 --- llvm/lib/Target/X86/X86RegisterInfo.cpp:1.86 Sun Jul 4 07:19:56 2004 +++ llvm/lib/Target/X86/X86RegisterInfo.cpp Sat Jul 10 23:17:04 2004 @@ -23,7 +23,7 @@ #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/Target/TargetFrameInfo.h" #include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetMachineImpls.h" +#include "llvm/Target/TargetOptions.h" #include "Support/CommandLine.h" #include "Support/STLExtras.h" #include Index: llvm/lib/Target/X86/X86TargetMachine.cpp diff -u llvm/lib/Target/X86/X86TargetMachine.cpp:1.61 llvm/lib/Target/X86/X86TargetMachine.cpp:1.62 --- llvm/lib/Target/X86/X86TargetMachine.cpp:1.61 Sat Jul 10 22:27:35 2004 +++ llvm/lib/Target/X86/X86TargetMachine.cpp Sat Jul 10 23:17:04 2004 @@ -18,7 +18,7 @@ #include "llvm/CodeGen/IntrinsicLowering.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/Passes.h" -#include "llvm/Target/TargetMachineImpls.h" +#include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetMachineRegistry.h" #include "llvm/Transforms/Scalar.h" #include "Support/CommandLine.h" @@ -41,14 +41,6 @@ RegisterTarget X("x86", " IA-32 (Pentium and above)"); } -// allocateX86TargetMachine - Allocate and return a subclass of TargetMachine -// that implements the X86 backend. -// -TargetMachine *llvm::allocateX86TargetMachine(const Module &M, - IntrinsicLowering *IL) { - return new X86TargetMachine(M, IL); -} - unsigned X86TargetMachine::getJITMatchQuality() { #if defined(i386) || defined(__i386__) || defined(__x86__) return 10; From lattner at cs.uiuc.edu Sat Jul 10 23:18:15 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 23:18:15 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp Message-ID: <200407110417.XAA01173@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/PowerPC: PowerPCTargetMachine.cpp updated: 1.10 -> 1.11 --- Log message: Delete the allocate*TargetMachine function, which is now dead . The shared command line options are now in a header that makes sense. --- Diffs of the changes: (+1 -9) Index: llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp diff -u llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.10 llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.11 --- llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp:1.10 Sat Jul 10 22:27:40 2004 +++ llvm/lib/Target/PowerPC/PowerPCTargetMachine.cpp Sat Jul 10 23:16:48 2004 @@ -14,7 +14,7 @@ #include "PowerPC.h" #include "llvm/Module.h" #include "llvm/PassManager.h" -#include "llvm/Target/TargetMachineImpls.h" +#include "llvm/Target/TargetOptions.h" #include "llvm/Target/TargetMachineRegistry.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/Passes.h" @@ -25,14 +25,6 @@ RegisterTarget X("powerpc", " PowerPC (experimental)"); } -// allocatePowerPCTargetMachine - Allocate and return a subclass of -// TargetMachine that implements the PowerPC backend. -// -TargetMachine *llvm::allocatePowerPCTargetMachine(const Module &M, - IntrinsicLowering *IL) { - return new PowerPCTargetMachine(M, IL); -} - /// PowerPCTargetMachine ctor - Create an ILP32 architecture model /// PowerPCTargetMachine::PowerPCTargetMachine(const Module &M, From lattner at cs.uiuc.edu Sat Jul 10 23:18:22 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sat Jul 10 23:18:22 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/CBackend/Writer.cpp Message-ID: <200407110417.XAA00911@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target/CBackend: Writer.cpp updated: 1.186 -> 1.187 --- Log message: Delete the allocate*TargetMachine function, which is now dead . --- Diffs of the changes: (+0 -6) Index: llvm/lib/Target/CBackend/Writer.cpp diff -u llvm/lib/Target/CBackend/Writer.cpp:1.186 llvm/lib/Target/CBackend/Writer.cpp:1.187 --- llvm/lib/Target/CBackend/Writer.cpp:1.186 Sat Jul 10 22:27:40 2004 +++ llvm/lib/Target/CBackend/Writer.cpp Sat Jul 10 23:16:31 2004 @@ -13,7 +13,6 @@ //===----------------------------------------------------------------------===// #include "CTargetMachine.h" -#include "llvm/Target/TargetMachineImpls.h" #include "llvm/Constants.h" #include "llvm/DerivedTypes.h" #include "llvm/Module.h" @@ -1512,9 +1511,4 @@ return false; } -TargetMachine *llvm::allocateCTargetMachine(const Module &M, - IntrinsicLowering *IL) { - return new CTargetMachine(M, IL); -} - // vim: sw=2 From sabre at nondot.org Sat Jul 10 23:34:01 2004 From: sabre at nondot.org (Chris Lattner) Date: Sat Jul 10 23:34:01 2004 Subject: [llvm-commits] Dynamically loadable targets Message-ID: Hi guys, I just checked in support for auto-registrating targets. I think that this should make your lives substantially easier by not having to have hacky code in llc.cpp, the allocate*TargetMachine business is now all gone, and you can even dynamically load your targets as plugins to avoid having to rebuild llc all of the time. If updated targets that are in CVS, but Vladimir, I obviously can't update yours. If you look at the CVS commits for the PPC backend, you'll see what I basically did. Here's the synopsis: 1. delete allocate*TargetMachine 2. TargetMachineImpls.h is gone 3. TargetOptions.h now contains the PrintMachineCode flag 4. You must register your target with RegisterTarget. 5. If you want llc/lli to auto pick your target when run a -march=x option is not specified, implement the TargetMachine::getModuleMatchQuality getJITMatchQuality methods. When we have target triple support, we can do much more interesting things, but for now see the X86 or V9 implementations of them. 6. You can choose to either statically link your TargetMachine into llc/lli or to dynamically load it with -load. To use -load, put "SHARED_LIBRARY=1" in your target makefile (to build the so), then use this to verify that it is being loaded correctly: llc -load .../path/to/yourtarget.so --help Your target should be listed. Enjoy, -Chris -- http://llvm.cs.uiuc.edu/ http://nondot.org/sabre/ From lattner at cs.uiuc.edu Sun Jul 11 01:04:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Jul 11 01:04:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Target/TargetMachineRegistry.cpp Message-ID: <200407110603.BAA13738@apoc.cs.uiuc.edu> Changes in directory llvm/lib/Target: TargetMachineRegistry.cpp updated: 1.2 -> 1.3 --- Log message: Implement TargetRegistrationListener --- Diffs of the changes: (+26 -0) Index: llvm/lib/Target/TargetMachineRegistry.cpp diff -u llvm/lib/Target/TargetMachineRegistry.cpp:1.2 llvm/lib/Target/TargetMachineRegistry.cpp:1.3 --- llvm/lib/Target/TargetMachineRegistry.cpp:1.2 Sat Jul 10 23:00:19 2004 +++ llvm/lib/Target/TargetMachineRegistry.cpp Sun Jul 11 01:03:21 2004 @@ -18,8 +18,34 @@ #include using namespace llvm; +/// List - This is the main list of all of the registered target machines. const TargetMachineRegistry::Entry *TargetMachineRegistry::List = 0; +/// Listeners - All of the listeners registered to get notified when new targets +/// are loaded. +static TargetRegistrationListener *Listeners = 0; + +TargetMachineRegistry::Entry::Entry(const char *N, const char *SD, + TargetMachine *(*CF)(const Module &, IntrinsicLowering*), + unsigned (*MMF)(const Module &M), unsigned (*JMF)()) + : Name(N), ShortDesc(SD), CtorFn(CF), ModuleMatchQualityFn(MMF), + JITMatchQualityFn(JMF), Next(List) { + List = this; + for (TargetRegistrationListener *L = Listeners; L; L = L->getNext()) + L->targetRegistered(this); +} + +TargetRegistrationListener::TargetRegistrationListener() { + Next = Listeners; + if (Next) Next->Prev = &Next; + Prev = &Listeners; + Listeners = this; +} + +TargetRegistrationListener::~TargetRegistrationListener() { + *Prev = Next; +} + /// getClosestStaticTargetForModule - Given an LLVM module, pick the best target /// that is compatible with the module. If no close target can be found, this /// returns null and sets the Error string to a reason. From lattner at cs.uiuc.edu Sun Jul 11 01:04:11 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Jul 11 01:04:11 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/Target/TargetMachineRegistry.h Message-ID: <200407110603.BAA13727@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm/Target: TargetMachineRegistry.h updated: 1.2 -> 1.3 --- Log message: Add a new listener class for things that want to be informed about new targets that are loaded --- Diffs of the changes: (+21 -6) Index: llvm/include/llvm/Target/TargetMachineRegistry.h diff -u llvm/include/llvm/Target/TargetMachineRegistry.h:1.2 llvm/include/llvm/Target/TargetMachineRegistry.h:1.3 --- llvm/include/llvm/Target/TargetMachineRegistry.h:1.2 Sat Jul 10 22:59:46 2004 +++ llvm/include/llvm/Target/TargetMachineRegistry.h Sun Jul 11 01:02:59 2004 @@ -58,11 +58,7 @@ protected: Entry(const char *N, const char *SD, TargetMachine *(*CF)(const Module &, IntrinsicLowering*), - unsigned (*MMF)(const Module &M), unsigned (*JMF)()) - : Name(N), ShortDesc(SD), CtorFn(CF), ModuleMatchQualityFn(MMF), - JITMatchQualityFn(JMF), Next(List) { - List = this; - } + unsigned (*MMF)(const Module &M), unsigned (*JMF)()); private: const Entry *Next; // Next entry in the linked list. }; @@ -89,10 +85,24 @@ } }; + /// TargetRegistrationListener - This class allows code to listen for targets + /// that are dynamically registered, and be notified of it when they are. + class TargetRegistrationListener { + TargetRegistrationListener **Prev, *Next; + public: + TargetRegistrationListener(); + virtual ~TargetRegistrationListener(); + + TargetRegistrationListener *getNext() const { return Next; } + + virtual void targetRegistered(const TargetMachineRegistry::Entry *E) = 0; + }; + + //===--------------------------------------------------------------------===// /// TargetNameParser - This option can be used to provide a command line /// option to choose among the various registered targets (commonly -march). - class TargetNameParser : + class TargetNameParser : public TargetRegistrationListener, public cl::parser { public: void initialize(cl::Option &O) { @@ -102,6 +112,11 @@ std::make_pair(E, E->ShortDesc))); cl::parser::initialize(O); } + + virtual void targetRegistered(const TargetMachineRegistry::Entry *E) { + Values.push_back(std::make_pair(E->Name, + std::make_pair(E, E->ShortDesc))); + } }; } From lattner at cs.uiuc.edu Sun Jul 11 03:02:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Jul 11 03:02:01 2004 Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/ExecutionEngine.cpp Message-ID: <200407110801.DAA16252@apoc.cs.uiuc.edu> Changes in directory llvm/lib/ExecutionEngine: ExecutionEngine.cpp updated: 1.53 -> 1.54 --- Log message: Make add constantexprs work with all types, fixing the regressions from last night --- Diffs of the changes: (+28 -4) Index: llvm/lib/ExecutionEngine/ExecutionEngine.cpp diff -u llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.53 llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.54 --- llvm/lib/ExecutionEngine/ExecutionEngine.cpp:1.53 Wed Jul 7 16:01:38 2004 +++ llvm/lib/ExecutionEngine/ExecutionEngine.cpp Sun Jul 11 03:01:11 2004 @@ -208,14 +208,38 @@ } case Instruction::Add: - if (CE->getOperand(0)->getType() == Type::LongTy || - CE->getOperand(0)->getType() == Type::ULongTy) + switch (CE->getOperand(0)->getType()->getTypeID()) { + default: assert(0 && "Bad add type!"); abort(); + case Type::LongTyID: + case Type::ULongTyID: Result.LongVal = getConstantValue(CE->getOperand(0)).LongVal + getConstantValue(CE->getOperand(1)).LongVal; - else break; + case Type::IntTyID: + case Type::UIntTyID: + Result.IntVal = getConstantValue(CE->getOperand(0)).IntVal + + getConstantValue(CE->getOperand(1)).IntVal; + break; + case Type::ShortTyID: + case Type::UShortTyID: + Result.ShortVal = getConstantValue(CE->getOperand(0)).ShortVal + + getConstantValue(CE->getOperand(1)).ShortVal; + break; + case Type::SByteTyID: + case Type::UByteTyID: + Result.SByteVal = getConstantValue(CE->getOperand(0)).SByteVal + + getConstantValue(CE->getOperand(1)).SByteVal; + break; + case Type::FloatTyID: + Result.FloatVal = getConstantValue(CE->getOperand(0)).FloatVal + + getConstantValue(CE->getOperand(1)).FloatVal; + break; + case Type::DoubleTyID: + Result.DoubleVal = getConstantValue(CE->getOperand(0)).DoubleVal + + getConstantValue(CE->getOperand(1)).DoubleVal; + break; + } return Result; - default: break; } From lattner at cs.uiuc.edu Sun Jul 11 03:25:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Jul 11 03:25:01 2004 Subject: [llvm-commits] CVS: llvm/lib/ExecutionEngine/JIT/TargetSelect.cpp Message-ID: <200407110824.DAA16414@apoc.cs.uiuc.edu> Changes in directory llvm/lib/ExecutionEngine/JIT: TargetSelect.cpp updated: 1.5 -> 1.6 --- Log message: The cleanup is done. Update comment. --- Diffs of the changes: (+2 -5) Index: llvm/lib/ExecutionEngine/JIT/TargetSelect.cpp diff -u llvm/lib/ExecutionEngine/JIT/TargetSelect.cpp:1.5 llvm/lib/ExecutionEngine/JIT/TargetSelect.cpp:1.6 --- llvm/lib/ExecutionEngine/JIT/TargetSelect.cpp:1.5 Sat Jul 10 23:02:06 2004 +++ llvm/lib/ExecutionEngine/JIT/TargetSelect.cpp Sun Jul 11 03:24:02 2004 @@ -7,11 +7,8 @@ // //===----------------------------------------------------------------------===// // -// This file contains the hideously gross code that is currently used to select -// a particular TargetMachine for the JIT to use. This should obviously be -// improved in the future, probably by having the TargetMachines register -// themselves with the runtime, and then have them choose themselves if they -// match the current machine. +// This just asks the TargetMachineRegistry for the appropriate JIT to use, and +// allows the user to specify a specific one on the commandline with -march=x. // //===----------------------------------------------------------------------===// From gaeke at cs.uiuc.edu Sun Jul 11 05:04:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Sun Jul 11 05:04:01 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Message-ID: <200407111003.FAA03509@kain.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: UnpackTraceFunction.cpp updated: 1.94 -> 1.95 --- Log message: Add a boolean 'fpIsTraceFP' used for assertions about when it is OK to call addLiveOutCopy. Update comments and some debug msgs. Do trace exit phi elimination after other live-out copies, not before. --- Diffs of the changes: (+33 -26) Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.94 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.95 --- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.94 Fri Jul 9 15:55:35 2004 +++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Sun Jul 11 05:02:55 2004 @@ -253,6 +253,7 @@ // reference the new frame pointer (g1). E.push_back (BuildMI (V9::ORr, 3).addMReg (g1).addZImm (0) .addMReg (fp, MachineOperand::Def)); + fpIsTraceFP = true; MachineBasicBlock::iterator MBBIt = EntryBB.begin (); for (std::vector::iterator ei = E.begin (), ee = E.end (); @@ -346,6 +347,8 @@ static const unsigned sp = SparcV9::o6, fp = SparcV9::i6, g1 = SparcV9::g1, g2 = SparcV9::g2, g3 = SparcV9::g3; + assert (fpIsTraceFP + && "Can't call addLiveOutCopy without TraceFn stack frame pointer"); assert ((Target.AllocState == AllocInfo::Allocated || Target.AllocState == AllocInfo::Spilled) && "Live-out values must be in regs or spilled in the matrixFn"); @@ -400,7 +403,8 @@ MBB.push_back (*vi); } -/// eliminatePhiAtTraceExit - Perform Phi elimination along trace exit edges. +/// eliminatePhiAtTraceExit - Perform Phi elimination for PN along trace exit +/// edges. /// void UnpackTraceFunction::eliminatePhiAtTraceExit (MachineFunction &MF, MachineBasicBlock &MBB, @@ -412,24 +416,25 @@ const BasicBlock *Src = PN->getIncomingBlock (i); if (TF->T.contains (Src)) { BasicBlock *SrcTTF = cast (TF->getCorrespondingValue (Src)); - DEBUG (std::cerr << "rewriteEpilog: considering Phi node " + DEBUG (std::cerr << "eliminatePhiAtTraceExit: considering Phi node " << PN->getName () << ", found on-trace source #" << i << " (" << Src->getName () << ", corresponding to " << SrcTTF->getName () << " on trace)\n" << *PN << "\n"); const BasicBlock *TraceExitingBB = *pred_begin(MBB.getBasicBlock ()); - DEBUG (std::cerr << "rewriteEpilog: trace exiting BB for this block is " + DEBUG (std::cerr << "eliminatePhiAtTraceExit: trace exiting BB for this" + << " block is " << TraceExitingBB->getName () << "\n"); if (TraceExitingBB == SrcTTF) { Value *V = PN->getIncomingValue (i); - DEBUG (std::cerr << "rewriteEpilog: found match: trace exiting BB is " - << "phi source; phi's incoming value from " << Src->getName () - << " is " << V->getName () << "\n"); + DEBUG (std::cerr << "eliminatePhiAtTraceExit: found match: trace " + << "exiting BB is phi source; phi's incoming value from " + << Src->getName () << " is " << V->getName () << "\n"); std::pair outgoingValueAI = GetValueAllocState (TF, V, false); std::pair phiCpAI = // we want the PhiCp node GetValueAllocState (TF, const_cast (PN), true); - DEBUG (std::cerr << "rewriteEpilog: Outgoing value is in "; + DEBUG (std::cerr << "eliminatePhiAtTraceExit: Outgoing value is in "; PrintAI (outgoingValueAI.second); std::cerr << " in TraceFn, and " << PN->getName() << "'s PhiCp node is in "; @@ -437,7 +442,8 @@ std::cerr << " in MatrixFn\n"); AllocInfo &Target = phiCpAI.first, &Source = outgoingValueAI.second; - DEBUG (std::cerr << "rewriteEpilog: copying live-out phi value: "; + DEBUG (std::cerr << "eliminatePhiAtTraceExit: copying live-out phi " + << "value: "; PrintValueAIs(V->getName(), Target, Source)); addLiveOutCopy (MF, MBB, Source, Target, V, TF->getCorrespondingValue (V, false)); @@ -458,23 +464,6 @@ // have to use a separate MBB) MBB.clear (); - // Find the BasicBlock in MatrixFn that this block's return instr. - // would have returned to, by consulting the mapping information - // generated by TraceFunctionBuilder. - const ReturnInst *RI = - cast (MBB.getBasicBlock ()->getTerminator ()); - const BasicBlock *RBB = TF->ReturnBlockForTraceExit[RI]; - assert (RBB && "Can't find matrix fn BB address to return to from trace"); - DEBUG (std::cerr << "rewriteEpilog: Return block for trace exit path is:\n" - << *RBB << "\n"); - - // If there are Phi nodes in the target of the trace-exiting branch, we must - // eliminate them by inserting copies now. - for (BasicBlock::const_iterator Inst = RBB->begin (); - const PHINode *PN = dyn_cast (Inst); ++Inst) - eliminatePhiAtTraceExit (MF, MBB, PN); -//===----------------------------------------------------------------------===// - // Insert stores from each live-out variable's reg. in the trace // to its stack slot in the trace function, from which it will be // reloaded below into a register. @@ -491,8 +480,24 @@ addLiveOutCopy (MF, MBB, Source, Target, V, TF->getCorrespondingValue (V, false)); } + + // Find the BasicBlock in MatrixFn that this block's return instr. + // would have returned to, by consulting the mapping information + // generated by TraceFunctionBuilder. + const ReturnInst *RI = + cast (MBB.getBasicBlock ()->getTerminator ()); + const BasicBlock *RBB = TF->ReturnBlockForTraceExit[RI]; + assert (RBB && "Can't find matrix fn BB address to return to from trace"); + DEBUG (std::cerr << "rewriteEpilog: Return block for trace exit path is:\n" + << *RBB << "\n"); + + // If there are Phi nodes in the target of the trace-exiting branch, we must + // eliminate them by inserting copies now. + for (BasicBlock::const_iterator Inst = RBB->begin (); + const PHINode *PN = dyn_cast (Inst); ++Inst) + eliminatePhiAtTraceExit (MF, MBB, PN); - // Restore old FP. Warning! After this point, addLiveOutCopy won't work + // Restore MatrixFn's FP. Warning! After this point, addLiveOutCopy won't work // anymore, because it depends on being able to access TraceFn's frame // pointer in %fp. mvec.clear (); @@ -501,6 +506,7 @@ for (std::vector::iterator vi = mvec.begin (), ve = mvec.end (); vi != ve; ++vi) MBB.push_back (*vi); + fpIsTraceFP = false; RegsToSave.erase (fp); // Get the set of registers used in this function which we saved in @@ -553,6 +559,7 @@ DEBUG(std::cerr << "UnpackTraceFunction: unpacking " << MF.getFunction()->getName() << "()\n"); + fpIsTraceFP = false; // Initialize RegsToSave with the set of registers we'll need to save in the // prolog and restore in the epilog. From gaeke at cs.uiuc.edu Sun Jul 11 05:04:10 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Sun Jul 11 05:04:10 2004 Subject: [llvm-commits] CVS: reopt/include/reopt/UnpackTraceFunction.h Message-ID: <200407111003.FAA03506@kain.cs.uiuc.edu> Changes in directory reopt/include/reopt: UnpackTraceFunction.h updated: 1.11 -> 1.12 --- Log message: Add a boolean 'fpIsTraceFP' used for assertions about when it is OK to call addLiveOutCopy. Update comments and some debug msgs. Do trace exit phi elimination after other live-out copies, not before. --- Diffs of the changes: (+5 -0) Index: reopt/include/reopt/UnpackTraceFunction.h diff -u reopt/include/reopt/UnpackTraceFunction.h:1.11 reopt/include/reopt/UnpackTraceFunction.h:1.12 --- reopt/include/reopt/UnpackTraceFunction.h:1.11 Fri Jul 9 15:55:34 2004 +++ reopt/include/reopt/UnpackTraceFunction.h Sun Jul 11 05:02:55 2004 @@ -46,6 +46,11 @@ std::map > AllocStates; + /// True IFF, in the current MachineFunction, register %fp contains + /// the traceFn's frame pointer (as opposed to matrixFn's.) + /// Only used in assertions. + bool fpIsTraceFP; + unsigned getStaticStackSize (MachineFunction &MF); unsigned stackOffsetForReg (const unsigned R) const; void findRegsToSave (MachineFunction &MF); From llvm at cs.uiuc.edu Sun Jul 11 10:20:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 11 10:20:01 2004 Subject: [llvm-commits] CVS: llvm/test/Regression/Bytecode/ Message-ID: <200407111519.KAA13015@zion.cs.uiuc.edu> Changes in directory llvm/test/Regression/Bytecode: --- Log message: Directory /var/cvs/llvm/llvm/test/Regression/Bytecode added to the repository --- Diffs of the changes: (+0 -0) From llvm at cs.uiuc.edu Sun Jul 11 12:23:02 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 11 12:23:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Writer/ConstantWriter.cpp WriterPrimitives.h Message-ID: <200407111722.MAA13432@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Writer: ConstantWriter.cpp updated: 1.38 -> 1.39 WriterPrimitives.h updated: 1.5 -> 1.6 --- Log message: Prepare the writer for a non-broken implementation of writing floating point values. This will be fixed when I figure out how to do it correctly without depending on knowing the endianess of a platform. --- Diffs of the changes: (+19 -2) Index: llvm/lib/Bytecode/Writer/ConstantWriter.cpp diff -u llvm/lib/Bytecode/Writer/ConstantWriter.cpp:1.38 llvm/lib/Bytecode/Writer/ConstantWriter.cpp:1.39 --- llvm/lib/Bytecode/Writer/ConstantWriter.cpp:1.38 Sun Jul 4 06:37:54 2004 +++ llvm/lib/Bytecode/Writer/ConstantWriter.cpp Sun Jul 11 12:22:07 2004 @@ -176,12 +176,12 @@ case Type::FloatTyID: { // Floating point types... float Tmp = (float)cast(CPV)->getValue(); - output_data(&Tmp, &Tmp+1, Out); + output_float(Tmp, Out); break; } case Type::DoubleTyID: { double Tmp = cast(CPV)->getValue(); - output_data(&Tmp, &Tmp+1, Out); + output_double(Tmp, Out); break; } Index: llvm/lib/Bytecode/Writer/WriterPrimitives.h diff -u llvm/lib/Bytecode/Writer/WriterPrimitives.h:1.5 llvm/lib/Bytecode/Writer/WriterPrimitives.h:1.6 --- llvm/lib/Bytecode/Writer/WriterPrimitives.h:1.5 Thu Jun 24 19:11:25 2004 +++ llvm/lib/Bytecode/Writer/WriterPrimitives.h Sun Jul 11 12:22:07 2004 @@ -119,6 +119,23 @@ Out.insert(Out.end(), (const unsigned char*)Ptr, (const unsigned char*)End); } +static inline void output_float(float& FloatVal, + std::deque& Out) { + /// FIXME: This is a broken implementation! It writes + /// it in a platform-specific endianess. Need to make + /// it little endian always. + output_data(&FloatVal, &FloatVal+1, Out); +} + +static inline void output_double(double& DoubleVal, + std::deque& Out) { + /// FIXME: This is a broken implementation! It writes + /// it in a platform-specific endianess. Need to make + /// it little endian always. + output_data(&DoubleVal, &DoubleVal+1, Out); +} + } // End llvm namespace +// vim: sw=2 ai #endif From llvm at cs.uiuc.edu Sun Jul 11 12:24:01 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 11 12:24:01 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Writer/WriterPrimitives.h Message-ID: <200407111723.MAA13445@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Writer: WriterPrimitives.h updated: 1.6 -> 1.7 --- Log message: Remove tabs. --- Diffs of the changes: (+2 -2) Index: llvm/lib/Bytecode/Writer/WriterPrimitives.h diff -u llvm/lib/Bytecode/Writer/WriterPrimitives.h:1.6 llvm/lib/Bytecode/Writer/WriterPrimitives.h:1.7 --- llvm/lib/Bytecode/Writer/WriterPrimitives.h:1.6 Sun Jul 11 12:22:07 2004 +++ llvm/lib/Bytecode/Writer/WriterPrimitives.h Sun Jul 11 12:22:51 2004 @@ -120,7 +120,7 @@ } static inline void output_float(float& FloatVal, - std::deque& Out) { + std::deque& Out) { /// FIXME: This is a broken implementation! It writes /// it in a platform-specific endianess. Need to make /// it little endian always. @@ -128,7 +128,7 @@ } static inline void output_double(double& DoubleVal, - std::deque& Out) { + std::deque& Out) { /// FIXME: This is a broken implementation! It writes /// it in a platform-specific endianess. Need to make /// it little endian always. From llvm at cs.uiuc.edu Sun Jul 11 12:25:02 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 11 12:25:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.h Message-ID: <200407111724.MAA13468@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.h updated: 1.5 -> 1.6 --- Log message: - Rename two methods to give them more meaning - Add read_float and read_double in preparation for a correct implementation of bytecode floating point support. --- Diffs of the changes: (+8 -2) Index: llvm/lib/Bytecode/Reader/Reader.h diff -u llvm/lib/Bytecode/Reader/Reader.h:1.5 llvm/lib/Bytecode/Reader/Reader.h:1.6 --- llvm/lib/Bytecode/Reader/Reader.h:1.5 Fri Jul 9 17:21:33 2004 +++ llvm/lib/Bytecode/Reader/Reader.h Sun Jul 11 12:24:05 2004 @@ -223,10 +223,10 @@ Constant* ParseConstantValue(unsigned TypeID); /// @brief Parse a block of types constants - void ParseTypeConstants(TypeListTy &Tab, unsigned NumEntries); + void ParseTypes(TypeListTy &Tab, unsigned NumEntries); /// @brief Parse a single type constant - const Type *ParseTypeConstant(); + const Type *ParseType(); /// @brief Parse a string constants block void ParseStringConstants(unsigned NumEntries, ValueTable &Tab); @@ -438,6 +438,12 @@ /// @brief Read a string inline std::string read_str(); + + /// @brief Read a float value + inline void read_float(float& FloatVal); + + /// @brief Read a double value + inline void read_double(double& DoubleVal); /// @brief Read an arbitrary data chunk of fixed length inline void read_data(void *Ptr, void *End); From llvm at cs.uiuc.edu Sun Jul 11 12:30:02 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 11 12:30:02 2004 Subject: [llvm-commits] CVS: llvm/lib/Bytecode/Reader/Reader.cpp Message-ID: <200407111728.MAA13505@zion.cs.uiuc.edu> Changes in directory llvm/lib/Bytecode/Reader: Reader.cpp updated: 1.112 -> 1.113 --- Log message: Various cleanups: - Remove tabs - Standardize use of space around ( and ). - Consolidate the ConstantPlaceHolder class - Rename two methods to be more meaningful (ParseType, ParseTypes) - Correct indentation of blocks - Add documentation - Convert input dependent asserts to error(...) so it throws instead. Provide placeholder implementations of read_float and read_double that still read in platform-specific endianess. When I figure out how to do this without knowing the endianess of the platform, it will get implemented correctly. --- Diffs of the changes: (+193 -153) Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.112 llvm/lib/Bytecode/Reader/Reader.cpp:1.113 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.112 Fri Jul 9 17:21:33 2004 +++ llvm/lib/Bytecode/Reader/Reader.cpp Sun Jul 11 12:28:43 2004 @@ -29,24 +29,22 @@ using namespace llvm; +namespace { + /// @brief A class for maintaining the slot number definition -/// as a placeholder for the actual definition. -template -class PlaceholderDef : public SuperType { +/// as a placeholder for the actual definition for forward constants defs. +class ConstantPlaceHolder : public ConstantExpr { unsigned ID; - PlaceholderDef(); // DO NOT IMPLEMENT - void operator=(const PlaceholderDef &); // DO NOT IMPLEMENT + ConstantPlaceHolder(); // DO NOT IMPLEMENT + void operator=(const ConstantPlaceHolder &); // DO NOT IMPLEMENT public: - PlaceholderDef(const Type *Ty, unsigned id) : SuperType(Ty), ID(id) {} + ConstantPlaceHolder(const Type *Ty, unsigned id) + : ConstantExpr(Instruction::UserOp1, Constant::getNullValue(Ty), Ty), + ID(id) {} unsigned getID() { return ID; } }; -struct ConstantPlaceHolderHelper : public ConstantExpr { - ConstantPlaceHolderHelper(const Type *Ty) - : ConstantExpr(Instruction::UserOp1, Constant::getNullValue(Ty), Ty) {} -}; - -typedef PlaceholderDef ConstPHolder; +} // Provide some details on error inline void BytecodeReader::error(std::string err) { @@ -69,7 +67,7 @@ /// Throw an error if we've read past the end of the current block inline void BytecodeReader::checkPastBlockEnd(const char * block_name) { - if ( At > BlockEnd ) + if (At > BlockEnd) error(std::string("Attempt to read past the end of ") + block_name + " block."); } @@ -77,8 +75,8 @@ inline void BytecodeReader::align32() { BufPtr Save = At; At = (const unsigned char *)((unsigned long)(At+3) & (~3UL)); - if ( At > Save ) - if (Handler) Handler->handleAlignment( At - Save ); + if (At > Save) + if (Handler) Handler->handleAlignment(At - Save); if (At > BlockEnd) error("Ran out of data while aligning!"); } @@ -156,15 +154,31 @@ At += Amount; } +/// Read a float value in little-endian order +inline void BytecodeReader::read_float(float& FloatVal) { + /// FIXME: This is a broken implementation! It reads + /// it in a platform-specific endianess. Need to make + /// it little endian always. + read_data(&FloatVal, &FloatVal+1); +} + +/// Read a double value in little-endian order +inline void BytecodeReader::read_double(double& DoubleVal) { + /// FIXME: This is a broken implementation! It reads + /// it in a platform-specific endianess. Need to make + /// it little endian always. + read_data(&DoubleVal, &DoubleVal+1); +} + /// Read a block header and obtain its type and size inline void BytecodeReader::read_block(unsigned &Type, unsigned &Size) { Type = read_uint(); Size = read_uint(); BlockStart = At; - if ( At + Size > BlockEnd ) + if (At + Size > BlockEnd) error("Attempt to size a block past end of memory"); BlockEnd = At + Size; - if (Handler) Handler->handleBlock( Type, BlockStart, Size ); + if (Handler) Handler->handleBlock(Type, BlockStart, Size); } @@ -185,12 +199,12 @@ /// function returns true, otherwise false. This helps detect situations /// where the pre 1.3 bytecode is indicating that what follows is a type. /// @returns true iff type id corresponds to pre 1.3 "type type" -inline bool BytecodeReader::sanitizeTypeId(unsigned &TypeId ) { - if ( hasTypeDerivedFromValue ) { /// do nothing if 1.3 or later - if ( TypeId == Type::LabelTyID ) { +inline bool BytecodeReader::sanitizeTypeId(unsigned &TypeId) { + if (hasTypeDerivedFromValue) { /// do nothing if 1.3 or later + if (TypeId == Type::LabelTyID) { TypeId = Type::VoidTyID; // sanitize it return true; // indicate we got TypeTyID in pre 1.3 bytecode - } else if ( TypeId > Type::LabelTyID ) + } else if (TypeId > Type::LabelTyID) --TypeId; // shift all planes down because type type plane is missing } return false; @@ -210,7 +224,7 @@ //===----------------------------------------------------------------------===// /// Determine if a type id has an implicit null value -inline bool BytecodeReader::hasImplicitNull(unsigned TyID ) { +inline bool BytecodeReader::hasImplicitNull(unsigned TyID) { if (!hasExplicitPrimitiveZeros) return TyID != Type::LabelTyID && TyID != Type::VoidTyID; return TyID >= Type::FirstDerivedTyID; @@ -233,23 +247,23 @@ } // Is it a module-level type? - if (ID < ModuleTypes.size()) - return ModuleTypes[ID].get(); + if (ID < ModuleTypes.size()) + return ModuleTypes[ID].get(); - // Nope, is it a function-level type? - ID -= ModuleTypes.size(); - if (ID < FunctionTypes.size()) - return FunctionTypes[ID].get(); + // Nope, is it a function-level type? + ID -= ModuleTypes.size(); + if (ID < FunctionTypes.size()) + return FunctionTypes[ID].get(); - error("Illegal type reference!"); - return Type::VoidTy; + error("Illegal type reference!"); + return Type::VoidTy; } /// Get a sanitized type id. This just makes sure that the \p ID /// is both sanitized and not the "type type" of pre-1.3 bytecode. /// @see sanitizeTypeId inline const Type* BytecodeReader::getSanitizedType(unsigned& ID) { - if ( sanitizeTypeId(ID) ) + if (sanitizeTypeId(ID)) error("Invalid type id encountered"); return getType(ID); } @@ -259,8 +273,8 @@ /// then calls getType to return the type value. inline const Type* BytecodeReader::readSanitizedType() { unsigned ID; - if ( read_typeid(ID) ) - error( "Invalid type id encountered"); + if (read_typeid(ID)) + error("Invalid type id encountered"); return getType(ID); } @@ -272,20 +286,20 @@ // Scan the compaction table for the type if needed. if (!CompactionTypes.empty()) { - std::vector::const_iterator I = - find(CompactionTypes.begin(), CompactionTypes.end(), Ty); + std::vector::const_iterator I = + find(CompactionTypes.begin(), CompactionTypes.end(), Ty); - if (I == CompactionTypes.end()) - error("Couldn't find type specified in compaction table!"); - return Type::FirstDerivedTyID + (&*I - &CompactionTypes[0]); + if (I == CompactionTypes.end()) + error("Couldn't find type specified in compaction table!"); + return Type::FirstDerivedTyID + (&*I - &CompactionTypes[0]); } // Check the function level types first... TypeListTy::iterator I = find(FunctionTypes.begin(), FunctionTypes.end(), Ty); if (I != FunctionTypes.end()) - return Type::FirstDerivedTyID + ModuleTypes.size() + - (&*I - &FunctionTypes[0]); + return Type::FirstDerivedTyID + ModuleTypes.size() + + (&*I - &FunctionTypes[0]); // Check the module level types now... I = find(ModuleTypes.begin(), ModuleTypes.end(), Ty); @@ -300,7 +314,7 @@ const Type *BytecodeReader::getGlobalTableType(unsigned Slot) { if (Slot < Type::FirstDerivedTyID) { const Type *Ty = Type::getPrimitiveType((Type::TypeID)Slot); - if ( ! Ty ) + if (!Ty) error("Not a primitive type ID?"); return Ty; } @@ -395,9 +409,9 @@ SlotNo >= ModuleValues[TyID]->size()) { error("Corrupt compaction table entry!" + utostr(TyID) + ", " + utostr(SlotNo) + ": " - + utostr(ModuleValues.size()) + ", " + + utostr(ModuleValues.size()) + ", " + utohexstr(int((void*)ModuleValues[TyID])) + ", " - + utostr(ModuleValues[TyID]->size()) ); + + utostr(ModuleValues[TyID]->size())); } return ModuleValues[TyID]->getOperand(SlotNo); } @@ -427,7 +441,7 @@ } else { // Create a placeholder for the constant reference and // keep track of the fact that we have a forward ref to recycle it - Constant *C = new ConstPHolder(Ty, Slot); + Constant *C = new ConstantPlaceHolder(Ty, Slot); // Keep track of the fact that we have a forward ref to recycle it ConstantFwdRefs.insert(I, std::make_pair(Key, C)); @@ -442,8 +456,8 @@ /// As values are created, they are inserted into the appropriate place /// with this method. The ValueTable argument must be one of ModuleValues /// or FunctionValues data members of this class. -unsigned BytecodeReader::insertValue( - Value *Val, unsigned type, ValueTable &ValueTab) { +unsigned BytecodeReader::insertValue(Value *Val, unsigned type, + ValueTable &ValueTab) { assert((!isa(Val) || !cast(Val)->isNullValue()) || !hasImplicitNull(type) && "Cannot read null values from bytecode!"); @@ -460,7 +474,7 @@ } /// Insert the arguments of a function as new values in the reader. -void BytecodeReader::insertArguments(Function* F ) { +void BytecodeReader::insertArguments(Function* F) { const FunctionType *FT = F->getFunctionType(); Function::aiterator AI = F->abegin(); for (FunctionType::param_iterator It = FT->param_begin(); @@ -476,7 +490,7 @@ /// inserted at the end of the \p BB provided. The arguments of /// the instruction are provided in the \p Args vector. void BytecodeReader::ParseInstruction(std::vector &Oprnds, - BasicBlock* BB) { + BasicBlock* BB) { BufPtr SaveAt = At; // Clear instruction data @@ -549,7 +563,7 @@ const Type *InstTy = getSanitizedType(iType); - // Hae enough to inform the handler now + // We have enough info to inform the handler now. if (Handler) Handler->handleInstruction(Opcode, InstTy, Oprnds, At-SaveAt); // Declare the resulting instruction we'll build. @@ -569,15 +583,15 @@ break; case Instruction::VAArg: Result = new VAArgInst(getValue(iType, Oprnds[0]), - getSanitizedType(Oprnds[1])); + getSanitizedType(Oprnds[1])); break; case Instruction::VANext: Result = new VANextInst(getValue(iType, Oprnds[0]), - getSanitizedType(Oprnds[1])); + getSanitizedType(Oprnds[1])); break; case Instruction::Cast: Result = new CastInst(getValue(iType, Oprnds[0]), - getSanitizedType(Oprnds[1])); + getSanitizedType(Oprnds[1])); break; case Instruction::Select: Result = new SelectInst(getValue(Type::BoolTyID, Oprnds[0]), @@ -765,7 +779,7 @@ for (unsigned i = 1, e = Oprnds.size(); i != e; ++i) { const CompositeType *TopTy = dyn_cast_or_null(NextTy); if (!TopTy) - error("Invalid getelementptr instruction!"); + error("Invalid getelementptr instruction!"); unsigned ValIdx = Oprnds[i]; unsigned IdxTy = 0; @@ -862,8 +876,8 @@ /// This method reads in one of the basicblock packets. This method is not used /// for bytecode files after LLVM 1.0 /// @returns The basic block constructed. -BasicBlock *BytecodeReader::ParseBasicBlock( unsigned BlockNo) { - if (Handler) Handler->handleBasicBlockBegin( BlockNo ); +BasicBlock *BytecodeReader::ParseBasicBlock(unsigned BlockNo) { + if (Handler) Handler->handleBasicBlockBegin(BlockNo); BasicBlock *BB = 0; @@ -875,10 +889,10 @@ BB = ParsedBasicBlocks[BlockNo]; std::vector Operands; - while ( moreInBlock() ) + while (moreInBlock()) ParseInstruction(Operands, BB); - if (Handler) Handler->handleBasicBlockEnd( BlockNo ); + if (Handler) Handler->handleBasicBlockEnd(BlockNo); return BB; } @@ -890,8 +904,8 @@ unsigned BlockNo = 0; std::vector Args; - while ( moreInBlock() ) { - if (Handler) Handler->handleBasicBlockBegin( BlockNo ); + while (moreInBlock()) { + if (Handler) Handler->handleBasicBlockBegin(BlockNo); BasicBlock *BB; if (ParsedBasicBlocks.size() == BlockNo) ParsedBasicBlocks.push_back(BB = new BasicBlock()); @@ -903,13 +917,13 @@ F->getBasicBlockList().push_back(BB); // Read instructions into this basic block until we get to a terminator - while ( moreInBlock() && !BB->getTerminator()) + while (moreInBlock() && !BB->getTerminator()) ParseInstruction(Args, BB); if (!BB->getTerminator()) error("Non-terminated basic block found!"); - if (Handler) Handler->handleBasicBlockEnd( BlockNo-1 ); + if (Handler) Handler->handleBasicBlockEnd(BlockNo-1); } return BlockNo; @@ -934,10 +948,10 @@ /// In LLVM 1.3 we write types separately from values so /// The types are always first in the symbol table. This is /// because Type no longer derives from Value. - if ( ! hasTypeDerivedFromValue ) { + if (!hasTypeDerivedFromValue) { // Symtab block header: [num entries] unsigned NumEntries = read_vbr_uint(); - for ( unsigned i = 0; i < NumEntries; ++i ) { + for (unsigned i = 0; i < NumEntries; ++i) { // Symtab entry: [def slot #][name] unsigned slot = read_vbr_uint(); std::string Name = read_str(); @@ -946,7 +960,7 @@ } } - while ( moreInBlock() ) { + while (moreInBlock()) { // Symtab block header: [num entries][type id number] unsigned NumEntries = read_vbr_uint(); unsigned Typ = 0; @@ -960,23 +974,23 @@ // if we're reading a pre 1.3 bytecode file and the type plane // is the "type type", handle it here - if ( isTypeType ) { - const Type* T = getType(slot); - if ( T == 0 ) - error("Failed type look-up for name '" + Name + "'"); - ST->insert(Name, T); - continue; // code below must be short circuited + if (isTypeType) { + const Type* T = getType(slot); + if (T == 0) + error("Failed type look-up for name '" + Name + "'"); + ST->insert(Name, T); + continue; // code below must be short circuited } else { - Value *V = 0; - if (Typ == Type::LabelTyID) { - if (slot < BBMap.size()) - V = BBMap[slot]; - } else { - V = getValue(Typ, slot, false); // Find mapping... - } - if (V == 0) - error("Failed value look-up for name '" + Name + "'"); - V->setName(Name, ST); + Value *V = 0; + if (Typ == Type::LabelTyID) { + if (slot < BBMap.size()) + V = BBMap[slot]; + } else { + V = getValue(Typ, slot, false); // Find mapping... + } + if (V == 0) + error("Failed value look-up for name '" + Name + "'"); + V->setName(Name, ST); } } } @@ -985,40 +999,52 @@ } /// Read in the types portion of a compaction table. -void BytecodeReader::ParseCompactionTypes( unsigned NumEntries ) { +void BytecodeReader::ParseCompactionTypes(unsigned NumEntries) { for (unsigned i = 0; i != NumEntries; ++i) { unsigned TypeSlot = 0; - if ( read_typeid(TypeSlot) ) + if (read_typeid(TypeSlot)) error("Invalid type in compaction table: type type"); const Type *Typ = getGlobalTableType(TypeSlot); CompactionTypes.push_back(Typ); - if (Handler) Handler->handleCompactionTableType( i, TypeSlot, Typ ); + if (Handler) Handler->handleCompactionTableType(i, TypeSlot, Typ); } } /// Parse a compaction table. void BytecodeReader::ParseCompactionTable() { + // Notify handler that we're beginning a compaction table. if (Handler) Handler->handleCompactionTableBegin(); - /// In LLVM 1.3 Type no longer derives from Value. So, - /// we always write them first in the compaction table - /// because they can't occupy a "type plane" where the - /// Values reside. - if ( ! hasTypeDerivedFromValue ) { + // In LLVM 1.3 Type no longer derives from Value. So, + // we always write them first in the compaction table + // because they can't occupy a "type plane" where the + // Values reside. + if (! hasTypeDerivedFromValue) { unsigned NumEntries = read_vbr_uint(); - ParseCompactionTypes( NumEntries ); + ParseCompactionTypes(NumEntries); } - while ( moreInBlock() ) { + // Compaction tables live in separate blocks so we have to loop + // until we've read the whole thing. + while (moreInBlock()) { + // Read the number of Value* entries in the compaction table unsigned NumEntries = read_vbr_uint(); unsigned Ty = 0; unsigned isTypeType = false; + // Decode the type from value read in. Most compaction table + // planes will have one or two entries in them. If that's the + // case then the length is encoded in the bottom two bits and + // the higher bits encode the type. This saves another VBR value. if ((NumEntries & 3) == 3) { + // In this case, both low-order bits are set (value 3). This + // is a signal that the typeid follows. NumEntries >>= 2; isTypeType = read_typeid(Ty); } else { + // In this case, the low-order bits specify the number of entries + // and the high order bits specify the type. Ty = NumEntries >> 2; isTypeType = sanitizeTypeId(Ty); NumEntries &= 3; @@ -1026,35 +1052,47 @@ // if we're reading a pre 1.3 bytecode file and the type plane // is the "type type", handle it here - if ( isTypeType ) { + if (isTypeType) { ParseCompactionTypes(NumEntries); } else { + // Make sure we have enough room for the plane if (Ty >= CompactionValues.size()) - CompactionValues.resize(Ty+1); + CompactionValues.resize(Ty+1); + // Make sure the plane is empty or we have some kind of error if (!CompactionValues[Ty].empty()) - error("Compaction table plane contains multiple entries!"); + error("Compaction table plane contains multiple entries!"); - if (Handler) Handler->handleCompactionTablePlane( Ty, NumEntries ); + // Notify handler about the plane + if (Handler) Handler->handleCompactionTablePlane(Ty, NumEntries); + // Convert the type slot to a type const Type *Typ = getType(Ty); + // Push the implicit zero CompactionValues[Ty].push_back(Constant::getNullValue(Typ)); + + // Read in each of the entries, put them in the compaction table + // and notify the handler that we have a new compaction table value. for (unsigned i = 0; i != NumEntries; ++i) { - unsigned ValSlot = read_vbr_uint(); - Value *V = getGlobalTableValue(Typ, ValSlot); - CompactionValues[Ty].push_back(V); - if (Handler) Handler->handleCompactionTableValue( i, Ty, ValSlot, Typ ); + unsigned ValSlot = read_vbr_uint(); + Value *V = getGlobalTableValue(Typ, ValSlot); + CompactionValues[Ty].push_back(V); + if (Handler) Handler->handleCompactionTableValue(i, Ty, ValSlot, Typ); } } } + // Notify handler that the compaction table is done. if (Handler) Handler->handleCompactionTableEnd(); } -// Parse a single type constant. -const Type *BytecodeReader::ParseTypeConstant() { +// Parse a single type. The typeid is read in first. If its a primitive type +// then nothing else needs to be read, we know how to instantiate it. If its +// a derived type, then additional data is read to fill out the type +// definition. +const Type *BytecodeReader::ParseType() { unsigned PrimType = 0; - if ( read_typeid(PrimType) ) + if (read_typeid(PrimType)) error("Invalid type (type type) in type constants!"); const Type *Result = 0; @@ -1086,13 +1124,13 @@ case Type::StructTyID: { std::vector Elements; unsigned Typ = 0; - if ( read_typeid(Typ) ) + if (read_typeid(Typ)) error("Invalid element type (type type) for structure!"); while (Typ) { // List is terminated by void/0 typeid Elements.push_back(getType(Typ)); - if ( read_typeid(Typ) ) - error("Invalid element type (type type) for structure!"); + if (read_typeid(Typ)) + error("Invalid element type (type type) for structure!"); } Result = StructType::get(Elements); @@ -1112,11 +1150,11 @@ error("Don't know how to deserialize primitive type " + utostr(PrimType)); break; } - if (Handler) Handler->handleType( Result ); + if (Handler) Handler->handleType(Result); return Result; } -// ParseTypeConstants - We have to use this weird code to handle recursive +// ParseType - We have to use this weird code to handle recursive // types. We know that recursive types will only reference the current slab of // values in the type plane, but they can forward reference types before they // have been read. For example, Type #0 might be '{ Ty#1 }' and Type #1 might @@ -1126,7 +1164,7 @@ // something and when we reread the type later, we can replace the opaque type // with a new resolved concrete type. // -void BytecodeReader::ParseTypeConstants(TypeListTy &Tab, unsigned NumEntries){ +void BytecodeReader::ParseTypes(TypeListTy &Tab, unsigned NumEntries){ assert(Tab.size() == 0 && "should not have read type constants in before!"); // Insert a bunch of opaque types to be resolved later... @@ -1138,7 +1176,7 @@ // opaque types just inserted. // for (unsigned i = 0; i != NumEntries; ++i) { - const Type* NewTy = ParseTypeConstant(); + const Type* NewTy = ParseType(); const Type* OldTy = Tab[i].get(); if (NewTy == 0) error("Couldn't parse type!"); @@ -1159,7 +1197,7 @@ } /// Parse a single constant value -Constant *BytecodeReader::ParseConstantValue( unsigned TypeID) { +Constant *BytecodeReader::ParseConstantValue(unsigned TypeID) { // We must check for a ConstantExpr before switching by type because // a ConstantExpr can be of any type, and has no explicit value. // @@ -1176,8 +1214,8 @@ for (unsigned i = 0; i != isExprNumArgs; ++i) { unsigned ArgValSlot = read_vbr_uint(); unsigned ArgTypeSlot = 0; - if ( read_typeid(ArgTypeSlot) ) - error("Invalid argument type (type type) for constant value"); + if (read_typeid(ArgTypeSlot)) + error("Invalid argument type (type type) for constant value"); // Get the arg value from its slot if it exists, otherwise a placeholder ArgVec.push_back(getConstantValue(ArgTypeSlot, ArgValSlot)); @@ -1185,7 +1223,9 @@ // Construct a ConstantExpr of the appropriate kind if (isExprNumArgs == 1) { // All one-operand expressions - assert(Opcode == Instruction::Cast); + if (Opcode != Instruction::Cast) + error("Only Cast instruction has one argument for ConstantExpr"); + Constant* Result = ConstantExpr::getCast(ArgVec[0], getType(TypeID)); if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result); return Result; @@ -1209,7 +1249,8 @@ if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result); return Result; } else if (Opcode == Instruction::Select) { - assert(ArgVec.size() == 3); + if (ArgVec.size() != 3) + error("Select instruction must have three arguments."); Constant* Result = ConstantExpr::getSelect(ArgVec[0], ArgVec[1], ArgVec[2]); if (Handler) Handler->handleConstantExpression(Opcode, ArgVec, Result); @@ -1263,16 +1304,16 @@ } case Type::FloatTyID: { - float F; - read_data(&F, &F+1); - Constant* Result = ConstantFP::get(Ty, F); + float Val; + read_float(Val); + Constant* Result = ConstantFP::get(Ty, Val); if (Handler) Handler->handleConstantValue(Result); return Result; } case Type::DoubleTyID: { double Val; - read_data(&Val, &Val+1); + read_double(Val); Constant* Result = ConstantFP::get(Ty, Val); if (Handler) Handler->handleConstantValue(Result); return Result; @@ -1352,7 +1393,7 @@ void BytecodeReader::ParseStringConstants(unsigned NumEntries, ValueTable &Tab){ for (; NumEntries; --NumEntries) { unsigned Typ = 0; - if ( read_typeid(Typ) ) + if (read_typeid(Typ)) error("Invalid type (type type) for string constant"); const Type *Ty = getType(Typ); if (!isa(Ty)) @@ -1386,18 +1427,18 @@ /// Parse the constant pool. void BytecodeReader::ParseConstantPool(ValueTable &Tab, TypeListTy &TypeTab, - bool isFunction) { + bool isFunction) { if (Handler) Handler->handleGlobalConstantsBegin(); /// In LLVM 1.3 Type does not derive from Value so the types /// do not occupy a plane. Consequently, we read the types /// first in the constant pool. - if ( isFunction && !hasTypeDerivedFromValue ) { + if (isFunction && !hasTypeDerivedFromValue) { unsigned NumEntries = read_vbr_uint(); - ParseTypeConstants(TypeTab, NumEntries); + ParseTypes(TypeTab, NumEntries); } - while ( moreInBlock() ) { + while (moreInBlock()) { unsigned NumEntries = read_vbr_uint(); unsigned Typ = 0; bool isTypeType = read_typeid(Typ); @@ -1405,8 +1446,8 @@ /// In LLVM 1.2 and before, Types were written to the /// bytecode file in the "Type Type" plane (#12). /// In 1.3 plane 12 is now the label plane. Handle this here. - if ( isTypeType ) { - ParseTypeConstants(TypeTab, NumEntries); + if (isTypeType) { + ParseTypes(TypeTab, NumEntries); } else if (Typ == Type::VoidTyID) { /// Use of Type::VoidTyID is a misnomer. It actually means /// that the following plane is constant strings @@ -1435,7 +1476,7 @@ /// Parse the contents of a function. Note that this function can be /// called lazily by materializeFunction /// @see materializeFunction -void BytecodeReader::ParseFunctionBody(Function* F ) { +void BytecodeReader::ParseFunctionBody(Function* F) { unsigned FuncSize = BlockEnd - At; GlobalValue::LinkageTypes Linkage = GlobalValue::ExternalLinkage; @@ -1453,7 +1494,7 @@ break; } - F->setLinkage( Linkage ); + F->setLinkage(Linkage); if (Handler) Handler->handleFunctionBegin(F,FuncSize); // Keep track of how many basic blocks we have read in... @@ -1461,7 +1502,7 @@ bool InsertedArguments = false; BufPtr MyEnd = BlockEnd; - while ( At < MyEnd ) { + while (At < MyEnd) { unsigned Type, Size; BufPtr OldAt = At; read_block(Type, Size); @@ -1609,7 +1650,7 @@ LazyFunctionMap::iterator Fi = LazyFunctionLoadMap.find(Func); // Make sure we found it - if ( Fi == LazyFunctionLoadMap.end() ) { + if (Fi == LazyFunctionLoadMap.end()) { error("Unrecognized function of type " + Func->getType()->getDescription()); return; } @@ -1620,7 +1661,7 @@ LazyFunctionLoadMap.erase(Fi); - this->ParseFunctionBody( Func ); + this->ParseFunctionBody(Func); } /// The ParseAllFunctionBodies method parses through all the previously @@ -1634,7 +1675,7 @@ LazyFunctionMap::iterator Fi = LazyFunctionLoadMap.begin(); LazyFunctionMap::iterator Fe = LazyFunctionLoadMap.end(); - while ( Fi != Fe ) { + while (Fi != Fe) { Function* Func = Fi->first; BlockStart = At = Fi->second.Buf; BlockEnd = Fi->second.EndBuf; @@ -1652,7 +1693,7 @@ if (hasTypeDerivedFromValue) read_vbr_uint(); - ParseTypeConstants(ModuleTypes, NumEntries); + ParseTypes(ModuleTypes, NumEntries); } /// Parse the Global info (types, global vars, constants) @@ -1666,7 +1707,7 @@ // VarType Fields: bit0 = isConstant, bit1 = hasInitializer, bit2,3,4 = // Linkage, bit4+ = slot# unsigned SlotNo = VarType >> 5; - if ( sanitizeTypeId(SlotNo) ) + if (sanitizeTypeId(SlotNo)) error("Invalid type (type type) for global var!"); unsigned LinkageID = (VarType >> 2) & 7; bool isConstant = VarType & 1; @@ -1686,11 +1727,11 @@ } const Type *Ty = getType(SlotNo); - if ( !Ty ) { + if (!Ty) { error("Global has no type! SlotNo=" + utostr(SlotNo)); } - if ( !isa(Ty)) { + if (!isa(Ty)) { error("Global not a pointer type! Ty= " + Ty->getDescription()); } @@ -1708,7 +1749,7 @@ } // Notify handler about the global value. - if (Handler) Handler->handleGlobalVariable( ElTy, isConstant, Linkage, SlotNo, initSlot ); + if (Handler) Handler->handleGlobalVariable(ElTy, isConstant, Linkage, SlotNo, initSlot); // Get next item VarType = read_vbr_uint(); @@ -1716,7 +1757,7 @@ // Read the function objects for all of the functions that are coming unsigned FnSignature = 0; - if ( read_typeid(FnSignature) ) + if (read_typeid(FnSignature)) error("Invalid function type (type type) found"); while (FnSignature != Type::VoidTyID) { // List is terminated by Void @@ -1724,7 +1765,7 @@ if (!isa(Ty) || !isa(cast(Ty)->getElementType())) { error("Function not a pointer to function type! Ty = " + - Ty->getDescription()); + Ty->getDescription()); // FIXME: what should Ty be if handler continues? } @@ -1743,7 +1784,7 @@ if (Handler) Handler->handleFunctionDeclaration(Func); // Get Next function signature - if ( read_typeid(FnSignature) ) + if (read_typeid(FnSignature)) error("Invalid function type (type type) found"); } @@ -1819,7 +1860,7 @@ if (hasNoEndianness) Endianness = Module::AnyEndianness; if (hasNoPointerSize) PointerSize = Module::AnyPointerSize; - if (Handler) Handler->handleVersionInfo(RevisionNum, Endianness, PointerSize ); + if (Handler) Handler->handleVersionInfo(RevisionNum, Endianness, PointerSize); } /// Parse a whole module. @@ -1842,7 +1883,7 @@ switch (Type) { case BytecodeFormat::GlobalTypePlane: - if ( SeenGlobalTypePlane ) + if (SeenGlobalTypePlane) error("Two GlobalTypePlane Blocks Encountered!"); ParseGlobalTypes(); @@ -1850,7 +1891,7 @@ break; case BytecodeFormat::ModuleGlobalInfo: - if ( SeenModuleGlobalInfo ) + if (SeenModuleGlobalInfo) error("Two ModuleGlobalInfo Blocks Encountered!"); ParseModuleGlobalInfo(); SeenModuleGlobalInfo = true; @@ -1871,7 +1912,7 @@ default: At += Size; if (OldAt > At) { - error("Unexpected Block of Type #" + utostr(Type) + " encountered!" ); + error("Unexpected Block of Type #" + utostr(Type) + " encountered!"); } break; } @@ -1908,10 +1949,9 @@ /// This function completely parses a bytecode buffer given by the \p Buf /// and \p Length parameters. -void BytecodeReader::ParseBytecode( - BufPtr Buf, unsigned Length, - const std::string &ModuleID, - bool processFunctions) { +void BytecodeReader::ParseBytecode(BufPtr Buf, unsigned Length, + const std::string &ModuleID, + bool processFunctions) { try { At = MemStart = BlockStart = Buf; @@ -1935,24 +1975,24 @@ // Get the module block and size and verify unsigned Type, Size; read_block(Type, Size); - if ( Type != BytecodeFormat::Module ) { + if (Type != BytecodeFormat::Module) { error("Expected Module Block! Type:" + utostr(Type) + ", Size:" - + utostr(Size)); + + utostr(Size)); } - if ( At + Size != MemEnd ) { + if (At + Size != MemEnd) { error("Invalid Top Level Block Length! Type:" + utostr(Type) - + ", Size:" + utostr(Size)); + + ", Size:" + utostr(Size)); } // Parse the module contents this->ParseModule(); // Check for missing functions - if ( hasFunctions() ) + if (hasFunctions()) error("Function expected, but bytecode stream ended!"); // Process all the function bodies now, if requested - if ( processFunctions ) + if (processFunctions) ParseAllFunctionBodies(); // Tell the handler we're done with the module @@ -1962,7 +2002,7 @@ // Tell the handler we're finished the parse if (Handler) Handler->handleFinish(); - } catch (std::string& errstr ) { + } catch (std::string& errstr) { if (Handler) Handler->handleError(errstr); freeState(); delete TheModule; From llvm at cs.uiuc.edu Sun Jul 11 18:22:07 2004 From: llvm at cs.uiuc.edu (LLVM) Date: Sun Jul 11 18:22:07 2004 Subject: [llvm-commits] CVS: llvm/tools/llvm-as/llvm-as.cpp Message-ID: <200407112321.SAA14882@zion.cs.uiuc.edu> Changes in directory llvm/tools/llvm-as: llvm-as.cpp updated: 1.29 -> 1.30 --- Log message: Correct an output typo. --- Diffs of the changes: (+1 -1) Index: llvm/tools/llvm-as/llvm-as.cpp diff -u llvm/tools/llvm-as/llvm-as.cpp:1.29 llvm/tools/llvm-as/llvm-as.cpp:1.30 --- llvm/tools/llvm-as/llvm-as.cpp:1.29 Sun Jul 4 07:20:55 2004 +++ llvm/tools/llvm-as/llvm-as.cpp Sun Jul 11 18:20:54 2004 @@ -42,7 +42,7 @@ static cl::opt DisableVerify("disable-verify", cl::Hidden, - cl::desc("Do not run verifier on input LLVM (dangerous!")); + cl::desc("Do not run verifier on input LLVM (dangerous!)")); int main(int argc, char **argv) { cl::ParseCommandLineOptions(argc, argv, " llvm .ll -> .bc assembler\n"); From gaeke at cs.uiuc.edu Sun Jul 11 19:34:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Sun Jul 11 19:34:01 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceJIT/TraceJIT.cpp Message-ID: <200407120033.TAA23951@seraph.cs.uiuc.edu> Changes in directory reopt/lib/TraceJIT: TraceJIT.cpp updated: 1.3 -> 1.4 --- Log message: Steal some code from lib/ExecutionEngine/JIT/TargetSelect.cpp to mop up after the death of TargetMachineImpls.h. --- Diffs of the changes: (+15 -4) Index: reopt/lib/TraceJIT/TraceJIT.cpp diff -u reopt/lib/TraceJIT/TraceJIT.cpp:1.3 reopt/lib/TraceJIT/TraceJIT.cpp:1.4 --- reopt/lib/TraceJIT/TraceJIT.cpp:1.3 Wed Jun 30 01:33:12 2004 +++ reopt/lib/TraceJIT/TraceJIT.cpp Sun Jul 11 19:33:27 2004 @@ -28,7 +28,7 @@ #include "llvm/Assembly/PrintModulePass.h" #include "llvm/CodeGen/Passes.h" #include "llvm/Target/TargetMachine.h" -#include "llvm/Target/TargetMachineImpls.h" +#include "llvm/Target/TargetMachineRegistry.h" #include "llvm/Target/TargetJITInfo.h" #include "Support/CommandLine.h" #include "Support/DynamicLinker.h" @@ -241,12 +241,23 @@ return Addr; } -/// create - Create and return a new SparcV9 TraceJIT compiler, or 0 if +/// create - Create and return a new TraceJIT compiler, or 0 if /// there is an error. /// TraceJIT *TraceJIT::create(ModuleProvider *MP, IntrinsicLowering *IL) { - // Allocate a SparcV9 target. - TargetMachine *Target = allocateSparcV9TargetMachine(*MP->getModule(), IL); + std::string Error; + const TargetMachineRegistry::Entry *ent = + TargetMachineRegistry::getClosestTargetForJIT(Error); + if (ent == 0) { + return 0; + } else if (ent->JITMatchQualityFn() == 0) { + std::cerr << "WARNING: This target JIT is not designed for the host you are" + << " running. If bad things happen, please choose a different " + << "-march switch.\n"; + } + + // Allocate a target... + TargetMachine *Target = ent->CtorFn(*MP->getModule(), IL); assert(Target && "Could not allocate target machine!"); // If the target supports TraceJIT code generation, return a new TraceJIT now. From gaeke at cs.uiuc.edu Sun Jul 11 19:34:13 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Sun Jul 11 19:34:13 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Message-ID: <200407120033.TAA23944@seraph.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: UnpackTraceFunction.cpp updated: 1.95 -> 1.96 --- Log message: Use a throwaway MCFI for CreateCodeToLoadConst(), because you can no longer pass in an Instruction* to MachineCodeForInstruction::get() which is not attached to a Function*. Since this seems to work, it's likely that CreateCodeToLoadConst() doesn't need to have an MCFI passed in at all. We'll have to look into this. Fix the setting of fpIsTraceFP in rewriteEpilog(). --- Diffs of the changes: (+4 -2) Index: reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp diff -u reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.95 reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.96 --- reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp:1.95 Sun Jul 11 05:02:55 2004 +++ reopt/lib/LightWtProfiling/UnpackTraceFunction.cpp Sun Jul 11 19:33:26 2004 @@ -313,8 +313,8 @@ std::vector &mvec) { const TargetInstrInfo &TII = *TM->getInstrInfo (); TmpInstruction *tmp = new TmpInstruction (C); - TII.CreateCodeToLoadConst (*TM, const_cast (MF.getFunction ()), C, tmp, mvec, - MachineCodeForInstruction::get (tmp)); + MachineCodeForInstruction throwaway; + TII.CreateCodeToLoadConst (*TM, const_cast (MF.getFunction ()), C, tmp, mvec, throwaway); DEBUG (for (std::vector::iterator i = mvec.begin (), e = mvec.end (); i != e; ++i) @@ -463,6 +463,8 @@ // (FIXME: may not work once we start doing optimizations!!! We will probably // have to use a separate MBB) MBB.clear (); + // This is just an educated guess... + fpIsTraceFP = true; // Insert stores from each live-out variable's reg. in the trace // to its stack slot in the trace function, from which it will be From gaeke at cs.uiuc.edu Sun Jul 11 19:34:21 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Sun Jul 11 19:34:21 2004 Subject: [llvm-commits] CVS: reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp Message-ID: <200407120033.TAA23937@seraph.cs.uiuc.edu> Changes in directory reopt/lib/LightWtProfiling: RuntimeOptimizations.cpp updated: 1.46 -> 1.47 --- Log message: TargetMachineImpls.h is dead. --- Diffs of the changes: (+0 -1) Index: reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp diff -u reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.46 reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.47 --- reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp:1.46 Wed Jun 30 01:33:11 2004 +++ reopt/lib/LightWtProfiling/RuntimeOptimizations.cpp Sun Jul 11 19:33:25 2004 @@ -32,7 +32,6 @@ #include "llvm/Target/TargetJITInfo.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Target/TargetData.h" -#include "llvm/Target/TargetMachineImpls.h" namespace llvm { From lattner at cs.uiuc.edu Sun Jul 11 20:18:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Jul 11 20:18:01 2004 Subject: [llvm-commits] CVS: llvm/lib/VMCore/Function.cpp Message-ID: <200407120117.UAA06151@apoc.cs.uiuc.edu> Changes in directory llvm/lib/VMCore: Function.cpp updated: 1.73 -> 1.74 --- Log message: Implement new method --- Diffs of the changes: (+36 -0) Index: llvm/lib/VMCore/Function.cpp diff -u llvm/lib/VMCore/Function.cpp:1.73 llvm/lib/VMCore/Function.cpp:1.74 --- llvm/lib/VMCore/Function.cpp:1.73 Tue Jun 15 16:52:19 2004 +++ llvm/lib/VMCore/Function.cpp Sun Jul 11 20:17:34 2004 @@ -13,6 +13,7 @@ //===----------------------------------------------------------------------===// #include "llvm/Module.h" +#include "llvm/Constant.h" #include "llvm/DerivedTypes.h" #include "llvm/iOther.h" #include "llvm/Intrinsics.h" @@ -81,6 +82,41 @@ LeakDetector::removeGarbageObject(this); } +static bool removeDeadConstantUsers(Constant *C) { + while (!C->use_empty()) { + if (Constant *C = dyn_cast(C->use_back())) { + if (!removeDeadConstantUsers(C)) + return false; // Constant wasn't dead. + } else { + return false; // Nonconstant user of the global. + } + } + + C->destroyConstant(); + return true; +} + + +/// removeDeadConstantUsers - If there are any dead constant users dangling +/// off of this global value, remove them. This method is useful for clients +/// that want to check to see if a global is unused, but don't want to deal +/// with potentially dead constants hanging off of the globals. +/// +/// This function returns true if the global value is now dead. If all +/// users of this global are not dead, this method may return false and +/// leave some of them around. +bool GlobalValue::removeDeadConstantUsers() { + while (!use_empty()) { + if (Constant *C = dyn_cast(use_back())) { + if (!::removeDeadConstantUsers(C)) + return false; // Constant wasn't dead. + } else { + return false; // Nonconstant user of the global. + } + } + return true; +} + //===----------------------------------------------------------------------===// // Function Implementation From lattner at cs.uiuc.edu Sun Jul 11 20:19:01 2004 From: lattner at cs.uiuc.edu (Chris Lattner) Date: Sun Jul 11 20:19:01 2004 Subject: [llvm-commits] CVS: llvm/include/llvm/GlobalValue.h Message-ID: <200407120118.UAA06160@apoc.cs.uiuc.edu> Changes in directory llvm/include/llvm: GlobalValue.h updated: 1.14 -> 1.15 --- Log message: Implement a new method useful for things like the inliner --- Diffs of the changes: (+10 -0) Index: llvm/include/llvm/GlobalValue.h diff -u llvm/include/llvm/GlobalValue.h:1.14 llvm/include/llvm/GlobalValue.h:1.15 --- llvm/include/llvm/GlobalValue.h:1.14 Sun Nov 16 14:21:15 2003 +++ llvm/include/llvm/GlobalValue.h Sun Jul 11 20:17:52 2004 @@ -66,6 +66,16 @@ inline Module *getParent() { return Parent; } inline const Module *getParent() const { return Parent; } + /// removeDeadConstantUsers - If there are any dead constant users dangling + /// off of this global value, remove them. This method is useful for clients + /// that want to check to see if a global is unused, but don't want to deal + /// with potentially dead constants hanging off of the globals. + /// + /// This function returns true if the global value is now dead. If all + /// users of this global are not dead, this method may return false and + /// leave some of them around. + bool removeDeadConstantUsers(); + // Methods for support type inquiry through isa, cast, and dyn_cast: static inline bool classof(const GlobalValue *T) { return true; } static inline bool classof(const Value *V) { From gaeke at cs.uiuc.edu Sun Jul 11 22:04:01 2004 From: gaeke at cs.uiuc.edu (Brian Gaeke) Date: Sun Jul 11 22:04:01 2004 Subject: [llvm-commits] CVS: reopt/lib/TraceJIT/TraceJIT.cpp Message-ID: <200407120303.WAA24056@seraph.cs.uiuc.edu> Changes in directory reopt/lib/TraceJIT: TraceJIT.cpp updated: 1.4 -> 1.5 --- Log message: We don't need to check for JITMatchQuality=0 here, as Chris pointed out. --- Diffs of the changes: (+1 -6) Index: reopt/lib/TraceJIT/TraceJIT.cpp diff -u reopt/lib/TraceJIT/TraceJIT.cpp:1.4 reopt/lib/TraceJIT/TraceJIT.cpp:1.5 --- reopt/lib/TraceJIT/TraceJIT.cpp:1.4 Sun Jul 11 19:33:27 2004 +++ reopt/lib/TraceJIT/TraceJIT.cpp Sun Jul 11 22:03:39 2004 @@ -248,13 +248,8 @@ std::string Error; const TargetMachineRegistry::Entry *ent = TargetMachineRegistry::getClosestTargetForJIT(Error); - if (ent == 0) { + if (!ent) return 0; - } else if (ent->JITMatchQualityFn() == 0) { - std::cerr << "WARNING: This target JIT is not designed for the host you are" - << " running. If bad things happen, please choose a different " - << "-march switch.\n"; - } // Allocate a target... TargetMachine *Target = ent->CtorFn(*MP->getModule(), IL);