mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-22 18:54:02 +01:00
For PR411:
This patch replaces the SymbolTable class with ValueSymbolTable which does not support types planes. This means that all symbol names in LLVM must now be unique. The patch addresses the necessary changes to deal with this and removes code no longer needed as a result. This completes the bulk of the changes for this PR. Some cleanup patches will follow. llvm-svn: 33918
This commit is contained in:
parent
d8c5428a48
commit
6af21b3029
@ -181,16 +181,14 @@ public:
|
||||
virtual void handleCompactionTableEnd() {}
|
||||
|
||||
/// @brief Handle start of a symbol table
|
||||
virtual void handleSymbolTableBegin(
|
||||
Function* Func, ///< The function to which the ST belongs
|
||||
SymbolTable* ST ///< The symbol table being filled
|
||||
virtual void handleTypeSymbolTableBegin(
|
||||
TypeSymbolTable* ST ///< The symbol table being filled
|
||||
) {}
|
||||
|
||||
/// @brief Handle start of a symbol table plane
|
||||
virtual void handleSymbolTablePlane(
|
||||
unsigned TySlot, ///< The slotnum of the type plane
|
||||
unsigned NumEntries, ///< Number of entries in the plane
|
||||
const Type* Typ ///< The type of this type plane
|
||||
/// @brief Handle start of a symbol table
|
||||
virtual void handleValueSymbolTableBegin(
|
||||
Function* Func, ///< The function to which the ST belongs or 0 for Mod
|
||||
ValueSymbolTable* ST ///< The symbol table being filled
|
||||
) {}
|
||||
|
||||
/// @brief Handle a named type in the symbol table
|
||||
@ -207,8 +205,11 @@ public:
|
||||
const std::string& name ///< Name of the value.
|
||||
) {}
|
||||
|
||||
/// @brief Handle the end of a symbol table
|
||||
virtual void handleSymbolTableEnd() {}
|
||||
/// @brief Handle the end of a value symbol table
|
||||
virtual void handleTypeSymbolTableEnd() {}
|
||||
|
||||
/// @brief Handle the end of a type symbol table
|
||||
virtual void handleValueSymbolTableEnd() {}
|
||||
|
||||
/// @brief Handle the beginning of a function body
|
||||
virtual void handleFunctionBegin(
|
||||
@ -233,6 +234,7 @@ public:
|
||||
unsigned Opcode, ///< Opcode of the instruction
|
||||
const Type* iType, ///< Instruction type
|
||||
std::vector<unsigned>& Operands, ///< Vector of slot # operands
|
||||
Instruction *Inst, ///< The resulting instruction
|
||||
unsigned Length ///< Length of instruction in bc bytes
|
||||
) { return false; }
|
||||
|
||||
|
@ -63,7 +63,7 @@ private:
|
||||
BasicBlockListType BasicBlocks; // The basic blocks
|
||||
ArgumentListType ArgumentList; // The formal arguments
|
||||
|
||||
SymbolTable *SymTab;
|
||||
ValueSymbolTable *SymTab;
|
||||
unsigned CallingConvention;
|
||||
|
||||
friend class SymbolTableListTraits<Function, Module, Module>;
|
||||
@ -156,8 +156,8 @@ public:
|
||||
|
||||
/// getSymbolTable() - Return the symbol table...
|
||||
///
|
||||
inline SymbolTable &getValueSymbolTable() { return *SymTab; }
|
||||
inline const SymbolTable &getValueSymbolTable() const { return *SymTab; }
|
||||
inline ValueSymbolTable &getValueSymbolTable() { return *SymTab; }
|
||||
inline const ValueSymbolTable &getValueSymbolTable() const { return *SymTab; }
|
||||
|
||||
|
||||
//===--------------------------------------------------------------------===//
|
||||
|
@ -64,7 +64,6 @@ namespace {
|
||||
(void) llvm::createEmitFunctionTablePass();
|
||||
(void) llvm::createFunctionInliningPass();
|
||||
(void) llvm::createFunctionProfilerPass();
|
||||
(void) llvm::createFunctionResolvingPass();
|
||||
(void) llvm::createGCSEPass();
|
||||
(void) llvm::createGlobalDCEPass();
|
||||
(void) llvm::createGlobalOptimizerPass();
|
||||
|
@ -23,8 +23,6 @@ namespace llvm {
|
||||
class GlobalVariable;
|
||||
class GlobalValueRefMap; // Used by ConstantVals.cpp
|
||||
class FunctionType;
|
||||
class SymbolTable;
|
||||
class TypeSymbolTable;
|
||||
|
||||
template<> struct ilist_traits<Function>
|
||||
: public SymbolTableListTraits<Function, Module, Module> {
|
||||
@ -91,7 +89,7 @@ private:
|
||||
FunctionListType FunctionList; ///< The Functions in the module
|
||||
LibraryListType LibraryList; ///< The Libraries needed by the module
|
||||
std::string GlobalScopeAsm; ///< Inline Asm at global scope.
|
||||
SymbolTable *ValSymTab; ///< Symbol table for values
|
||||
ValueSymbolTable *ValSymTab; ///< Symbol table for values
|
||||
TypeSymbolTable *TypeSymTab; ///< Symbol table for types
|
||||
std::string ModuleID; ///< Human readable identifier for the module
|
||||
std::string TargetTriple; ///< Platform target triple Module compiled on
|
||||
@ -178,17 +176,19 @@ public:
|
||||
|
||||
/// getFunction - Look up the specified function in the module symbol table.
|
||||
/// If it does not exist, return null.
|
||||
Function *getFunction(const std::string &Name, const FunctionType *Ty);
|
||||
Function *getFunction(const std::string &Name) const;
|
||||
|
||||
/// getMainFunction - This function looks up main efficiently. This is such a
|
||||
/// common case, that it is a method in Module. If main cannot be found, a
|
||||
/// null pointer is returned.
|
||||
Function *getMainFunction();
|
||||
Function *getMainFunction() { return getFunction("main"); }
|
||||
|
||||
/// getNamedFunction - Return the first function in the module with the
|
||||
/// specified name, of arbitrary type. This method returns null if a function
|
||||
/// with the specified name is not found.
|
||||
Function *getNamedFunction(const std::string &Name) const;
|
||||
Function *getNamedFunction(const std::string &Name) const {
|
||||
return getFunction(Name);
|
||||
}
|
||||
|
||||
/// @}
|
||||
/// @name Global Variable Accessors
|
||||
@ -200,13 +200,15 @@ public:
|
||||
/// the top-level PointerType, which represents the address of the global.
|
||||
/// If AllowInternal is set to true, this function will return types that
|
||||
/// have InternalLinkage. By default, these types are not returned.
|
||||
GlobalVariable *getGlobalVariable(const std::string &Name, const Type *Ty,
|
||||
bool AllowInternal = false);
|
||||
GlobalVariable *getGlobalVariable(const std::string &Name,
|
||||
bool AllowInternal = false) const;
|
||||
|
||||
/// getNamedGlobal - Return the first global variable in the module with the
|
||||
/// specified name, of arbitrary type. This method returns null if a global
|
||||
/// with the specified name is not found.
|
||||
GlobalVariable *getNamedGlobal(const std::string &Name) const;
|
||||
GlobalVariable *getNamedGlobal(const std::string &Name) const {
|
||||
return getGlobalVariable(Name, true);
|
||||
}
|
||||
|
||||
/// @}
|
||||
/// @name Type Accessors
|
||||
@ -238,9 +240,9 @@ public:
|
||||
/// Get the Module's list of functions.
|
||||
FunctionListType &getFunctionList() { return FunctionList; }
|
||||
/// Get the symbol table of global variable and function identifiers
|
||||
const SymbolTable &getValueSymbolTable() const { return *ValSymTab; }
|
||||
const ValueSymbolTable &getValueSymbolTable() const { return *ValSymTab; }
|
||||
/// Get the Module's symbol table of global variable and function identifiers.
|
||||
SymbolTable &getValueSymbolTable() { return *ValSymTab; }
|
||||
ValueSymbolTable &getValueSymbolTable() { return *ValSymTab; }
|
||||
/// Get the symbol table of types
|
||||
const TypeSymbolTable &getTypeSymbolTable() const { return *TypeSymTab; }
|
||||
/// Get the Module's symbol table of types
|
||||
|
@ -1,257 +0,0 @@
|
||||
//===-- llvm/SymbolTable.h - Implement a type plane'd symtab ----*- C++ -*-===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and re-written by Reid
|
||||
// Spencer. It is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements the main symbol table for LLVM.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_SYMBOL_TABLE_H
|
||||
#define LLVM_SYMBOL_TABLE_H
|
||||
|
||||
#include "llvm/Value.h"
|
||||
#include "llvm/Support/DataTypes.h"
|
||||
#include <map>
|
||||
|
||||
namespace llvm {
|
||||
|
||||
/// This class provides a symbol table of name/value pairs that is broken
|
||||
/// up by type. For each Type* there is a "plane" of name/value pairs in
|
||||
/// the symbol table. Identical types may have overlapping symbol names as
|
||||
/// long as they are distinct. The SymbolTable also tracks, separately, a
|
||||
/// map of name/type pairs. This allows types to be named. Types are treated
|
||||
/// distinctly from Values.
|
||||
///
|
||||
/// The SymbolTable provides several utility functions for answering common
|
||||
/// questions about its contents as well as an iterator interface for
|
||||
/// directly iterating over the contents. To reduce confusion, the terms
|
||||
/// "type", "value", and "plane" are used consistently. For example,
|
||||
/// There is a TypeMap typedef that is the mapping of names to Types.
|
||||
/// Similarly there is a ValueMap typedef that is the mapping of
|
||||
/// names to Values. Finally, there is a PlaneMap typedef that is the
|
||||
/// mapping of types to planes of ValueMap. This is the basic structure
|
||||
/// of the symbol table. When you call type_begin() you're asking
|
||||
/// for an iterator at the start of the TypeMap. When you call
|
||||
/// plane_begin(), you're asking for an iterator at the start of
|
||||
/// the PlaneMap. Finally, when you call value_begin(), you're asking
|
||||
/// for an iterator at the start of a ValueMap for a specific type
|
||||
/// plane.
|
||||
class SymbolTable : public AbstractTypeUser {
|
||||
|
||||
/// @name Types
|
||||
/// @{
|
||||
public:
|
||||
/// @brief A mapping of names to values.
|
||||
typedef std::map<const std::string, Value *> ValueMap;
|
||||
|
||||
/// @brief An iterator over a ValueMap.
|
||||
typedef ValueMap::iterator value_iterator;
|
||||
|
||||
/// @brief A const_iterator over a ValueMap.
|
||||
typedef ValueMap::const_iterator value_const_iterator;
|
||||
|
||||
/// @brief A mapping of types to names to values (type planes).
|
||||
typedef std::map<const Type *, ValueMap> PlaneMap;
|
||||
|
||||
/// @brief An iterator over the type planes.
|
||||
typedef PlaneMap::iterator plane_iterator;
|
||||
|
||||
/// @brief A const_iterator over the type planes
|
||||
typedef PlaneMap::const_iterator plane_const_iterator;
|
||||
|
||||
/// @}
|
||||
/// @name Constructors
|
||||
/// @{
|
||||
public:
|
||||
|
||||
SymbolTable() : LastUnique(0) {}
|
||||
~SymbolTable();
|
||||
|
||||
/// @}
|
||||
/// @name Accessors
|
||||
/// @{
|
||||
public:
|
||||
|
||||
/// This method finds the value with the given \p name in the
|
||||
/// type plane \p Ty and returns it. This method will not find any
|
||||
/// Types, only Values. Use lookupType to find Types by name.
|
||||
/// @returns null on failure, otherwise the Value associated with
|
||||
/// the \p name in type plane \p Ty.
|
||||
/// @brief Lookup a named, typed value.
|
||||
Value *lookup(const Type *Ty, const std::string &name) const;
|
||||
|
||||
/// @returns true iff the type map and the type plane are both not
|
||||
/// empty.
|
||||
/// @brief Determine if the symbol table is empty
|
||||
inline bool isEmpty() const { return pmap.empty(); }
|
||||
|
||||
/// Given a base name, return a string that is either equal to it or
|
||||
/// derived from it that does not already occur in the symbol table
|
||||
/// for the specified type.
|
||||
/// @brief Get a name unique to this symbol table
|
||||
std::string getUniqueName(const Type *Ty,
|
||||
const std::string &BaseName) const;
|
||||
|
||||
/// This function can be used from the debugger to display the
|
||||
/// content of the symbol table while debugging.
|
||||
/// @brief Print out symbol table on stderr
|
||||
void dump() const;
|
||||
|
||||
/// @}
|
||||
/// @name Iteration
|
||||
/// @{
|
||||
public:
|
||||
|
||||
/// Get an iterator that starts at the beginning of the type planes.
|
||||
/// The iterator will iterate over the Type/ValueMap pairs in the
|
||||
/// type planes.
|
||||
inline plane_iterator plane_begin() { return pmap.begin(); }
|
||||
|
||||
/// Get a const_iterator that starts at the beginning of the type
|
||||
/// planes. The iterator will iterate over the Type/ValueMap pairs
|
||||
/// in the type planes.
|
||||
inline plane_const_iterator plane_begin() const { return pmap.begin(); }
|
||||
|
||||
/// Get an iterator at the end of the type planes. This serves as
|
||||
/// the marker for end of iteration over the type planes.
|
||||
inline plane_iterator plane_end() { return pmap.end(); }
|
||||
|
||||
/// Get a const_iterator at the end of the type planes. This serves as
|
||||
/// the marker for end of iteration over the type planes.
|
||||
inline plane_const_iterator plane_end() const { return pmap.end(); }
|
||||
|
||||
/// Get an iterator that starts at the beginning of a type plane.
|
||||
/// The iterator will iterate over the name/value pairs in the type plane.
|
||||
/// @note The type plane must already exist before using this.
|
||||
inline value_iterator value_begin(const Type *Typ) {
|
||||
assert(Typ && "Can't get value iterator with null type!");
|
||||
return pmap.find(Typ)->second.begin();
|
||||
}
|
||||
|
||||
/// Get a const_iterator that starts at the beginning of a type plane.
|
||||
/// The iterator will iterate over the name/value pairs in the type plane.
|
||||
/// @note The type plane must already exist before using this.
|
||||
inline value_const_iterator value_begin(const Type *Typ) const {
|
||||
assert(Typ && "Can't get value iterator with null type!");
|
||||
return pmap.find(Typ)->second.begin();
|
||||
}
|
||||
|
||||
/// Get an iterator to the end of a type plane. This serves as the marker
|
||||
/// for end of iteration of the type plane.
|
||||
/// @note The type plane must already exist before using this.
|
||||
inline value_iterator value_end(const Type *Typ) {
|
||||
assert(Typ && "Can't get value iterator with null type!");
|
||||
return pmap.find(Typ)->second.end();
|
||||
}
|
||||
|
||||
/// Get a const_iterator to the end of a type plane. This serves as the
|
||||
/// marker for end of iteration of the type plane.
|
||||
/// @note The type plane must already exist before using this.
|
||||
inline value_const_iterator value_end(const Type *Typ) const {
|
||||
assert(Typ && "Can't get value iterator with null type!");
|
||||
return pmap.find(Typ)->second.end();
|
||||
}
|
||||
|
||||
/// This method returns a plane_const_iterator for iteration over
|
||||
/// the type planes starting at a specific plane, given by \p Ty.
|
||||
/// @brief Find a type plane.
|
||||
inline plane_const_iterator find(const Type* Typ) const {
|
||||
assert(Typ && "Can't find type plane with null type!");
|
||||
return pmap.find(Typ);
|
||||
}
|
||||
|
||||
/// This method returns a plane_iterator for iteration over the
|
||||
/// type planes starting at a specific plane, given by \p Ty.
|
||||
/// @brief Find a type plane.
|
||||
inline plane_iterator find(const Type* Typ) {
|
||||
assert(Typ && "Can't find type plane with null type!");
|
||||
return pmap.find(Typ);
|
||||
}
|
||||
|
||||
|
||||
/// @}
|
||||
/// @name Mutators
|
||||
/// @{
|
||||
public:
|
||||
|
||||
/// This method will strip the symbol table of its names leaving the type and
|
||||
/// values.
|
||||
/// @brief Strip the symbol table.
|
||||
bool strip();
|
||||
|
||||
/// @}
|
||||
/// @name Mutators used by Value::setName and other LLVM internals.
|
||||
/// @{
|
||||
public:
|
||||
|
||||
/// This method adds the provided value \p N to the symbol table. The Value
|
||||
/// must have both a name and a type which are extracted and used to place the
|
||||
/// value in the correct type plane under the value's name.
|
||||
/// @brief Add a named value to the symbol table
|
||||
inline void insert(Value *Val) {
|
||||
assert(Val && "Can't insert null type into symbol table!");
|
||||
assert(Val->hasName() && "Value must be named to go into symbol table!");
|
||||
insertEntry(Val->getName(), Val->getType(), Val);
|
||||
}
|
||||
|
||||
/// This method removes a named value from the symbol table. The type and name
|
||||
/// of the Value are extracted from \p N and used to lookup the Value in the
|
||||
/// correct type plane. If the Value is not in the symbol table, this method
|
||||
/// silently ignores the request.
|
||||
/// @brief Remove a named value from the symbol table.
|
||||
void remove(Value* Val);
|
||||
|
||||
/// changeName - Given a value with a non-empty name, remove its existing
|
||||
/// entry from the symbol table and insert a new one for Name. This is
|
||||
/// equivalent to doing "remove(V), V->Name = Name, insert(V)", but is faster,
|
||||
/// and will not temporarily remove the symbol table plane if V is the last
|
||||
/// value in the symtab with that name (which could invalidate iterators to
|
||||
/// that plane).
|
||||
void changeName(Value *V, const std::string &Name);
|
||||
|
||||
/// @}
|
||||
/// @name Internal Methods
|
||||
/// @{
|
||||
private:
|
||||
/// @brief Insert a value into the symbol table with the specified name.
|
||||
void insertEntry(const std::string &Name, const Type *Ty, Value *V);
|
||||
|
||||
/// This function is called when one of the types in the type plane
|
||||
/// is refined.
|
||||
virtual void refineAbstractType(const DerivedType *OldTy, const Type *NewTy);
|
||||
|
||||
/// This function markes a type as being concrete (defined).
|
||||
virtual void typeBecameConcrete(const DerivedType *AbsTy);
|
||||
|
||||
/// @}
|
||||
/// @name Internal Data
|
||||
/// @{
|
||||
private:
|
||||
|
||||
/// This is the main content of the symbol table. It provides
|
||||
/// separate type planes for named values. That is, each named
|
||||
/// value is organized into a separate dictionary based on
|
||||
/// Type. This means that the same name can be used for different
|
||||
/// types without conflict.
|
||||
/// @brief The mapping of types to names to values.
|
||||
PlaneMap pmap;
|
||||
|
||||
/// This value is used to retain the last unique value used
|
||||
/// by getUniqueName to generate unique names.
|
||||
mutable uint32_t LastUnique;
|
||||
/// @}
|
||||
|
||||
};
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
// vim: sw=2
|
||||
|
||||
#endif
|
||||
|
@ -86,19 +86,6 @@ ModulePass *createFunctionExtractionPass(Function *F, bool deleteFn = false,
|
||||
bool relinkCallees = false);
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// FunctionResolvingPass - Go over the functions that are in the module and
|
||||
/// look for functions that have the same name. More often than not, there will
|
||||
/// be things like:
|
||||
/// void "foo"(...)
|
||||
/// void "foo"(int, int)
|
||||
/// because of the way things are declared in C. If this is the case, patch
|
||||
/// things up.
|
||||
///
|
||||
/// This is an interprocedural pass.
|
||||
///
|
||||
ModulePass *createFunctionResolvingPass();
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
/// createFunctionInliningPass - Return a new pass object that uses a heuristic
|
||||
/// to inline direct function calls to small functions.
|
||||
@ -163,20 +150,24 @@ FunctionPass *createLoopExtractorPass();
|
||||
///
|
||||
FunctionPass *createSingleLoopExtractorPass();
|
||||
|
||||
// createBlockExtractorPass - This pass extracts all blocks (except those
|
||||
// specified in the argument list) from the functions in the module.
|
||||
//
|
||||
/// createBlockExtractorPass - This pass extracts all blocks (except those
|
||||
/// specified in the argument list) from the functions in the module.
|
||||
///
|
||||
ModulePass *createBlockExtractorPass(std::vector<BasicBlock*> &BTNE);
|
||||
|
||||
// createOptimizeWellKnownCallsPass - This pass optimizes specific calls to
|
||||
// specific well-known (library) functions.
|
||||
/// createOptimizeWellKnownCallsPass - This pass optimizes specific calls to
|
||||
/// specific well-known (library) functions.
|
||||
ModulePass *createSimplifyLibCallsPass();
|
||||
|
||||
|
||||
// createIndMemRemPass - This pass removes potential indirect calls of
|
||||
// malloc and free
|
||||
/// createIndMemRemPass - This pass removes potential indirect calls of
|
||||
/// malloc and free
|
||||
ModulePass *createIndMemRemPass();
|
||||
|
||||
/// createStripDeadPrototypesPass - This pass removes any function declarations
|
||||
/// (prototypes) that are not used.
|
||||
ModulePass *createStripDeadPrototypesPass();
|
||||
|
||||
} // End llvm namespace
|
||||
|
||||
#endif
|
||||
|
@ -31,7 +31,8 @@ class GlobalValue;
|
||||
class Function;
|
||||
class GlobalVariable;
|
||||
class InlineAsm;
|
||||
class SymbolTable;
|
||||
class ValueSymbolTable;
|
||||
class TypeSymbolTable;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Value Class
|
||||
|
@ -72,6 +72,12 @@ public:
|
||||
/// @brief Get a name unique to this symbol table
|
||||
std::string getUniqueName(const std::string &BaseName) const;
|
||||
|
||||
/// @return 1 if the name is in the symbol table, 0 otherwise
|
||||
/// @brief Determine if a name is in the symbol table
|
||||
ValueMap::size_type count(const std::string &name) const {
|
||||
return vmap.count(name);
|
||||
}
|
||||
|
||||
/// This function can be used from the debugger to display the
|
||||
/// content of the symbol table while debugging.
|
||||
/// @brief Print out symbol table on stderr
|
||||
@ -111,10 +117,10 @@ public:
|
||||
/// This method removes a value from the symbol table. The name of the
|
||||
/// Value is extracted from \p Val and used to lookup the Value in the
|
||||
/// symbol table. If the Value is not in the symbol table, this method
|
||||
/// returns false.
|
||||
/// @returns true if \p Val was successfully erased, false otherwise
|
||||
/// returns false. \p Val is not deleted, just removed from the symbol table.
|
||||
/// @returns true if \p Val was successfully removed, false otherwise
|
||||
/// @brief Remove a value from the symbol table.
|
||||
bool erase(Value* Val);
|
||||
bool remove(Value* Val);
|
||||
|
||||
/// Given a value with a non-empty name, remove its existing
|
||||
/// entry from the symbol table and insert a new one for Name. This is
|
||||
|
@ -869,7 +869,7 @@ goto find_rule; \
|
||||
#define YY_MORE_ADJ 0
|
||||
#define YY_RESTORE_YY_MORE_OFFSET
|
||||
char *yytext;
|
||||
#line 1 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 1 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
#define INITIAL 0
|
||||
/*===-- Lexer.l - Scanner for llvm assembly files --------------*- C++ -*--===//
|
||||
//
|
||||
@ -884,7 +884,7 @@ char *yytext;
|
||||
//
|
||||
//===----------------------------------------------------------------------===*/
|
||||
#define YY_NEVER_INTERACTIVE 1
|
||||
#line 28 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 28 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
#include "ParserInternals.h"
|
||||
#include "llvm/Module.h"
|
||||
#include <list>
|
||||
@ -1168,7 +1168,7 @@ YY_DECL
|
||||
register char *yy_cp = NULL, *yy_bp = NULL;
|
||||
register int yy_act;
|
||||
|
||||
#line 189 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 189 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
|
||||
|
||||
#line 1175 "Lexer.cpp"
|
||||
@ -1264,252 +1264,252 @@ do_action: /* This label is used only to access EOF actions. */
|
||||
{ /* beginning of action switch */
|
||||
case 1:
|
||||
YY_RULE_SETUP
|
||||
#line 191 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 191 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ /* Ignore comments for now */ }
|
||||
YY_BREAK
|
||||
case 2:
|
||||
YY_RULE_SETUP
|
||||
#line 193 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 193 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return BEGINTOK; }
|
||||
YY_BREAK
|
||||
case 3:
|
||||
YY_RULE_SETUP
|
||||
#line 194 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 194 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return ENDTOK; }
|
||||
YY_BREAK
|
||||
case 4:
|
||||
YY_RULE_SETUP
|
||||
#line 195 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 195 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return TRUETOK; }
|
||||
YY_BREAK
|
||||
case 5:
|
||||
YY_RULE_SETUP
|
||||
#line 196 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 196 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return FALSETOK; }
|
||||
YY_BREAK
|
||||
case 6:
|
||||
YY_RULE_SETUP
|
||||
#line 197 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 197 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return DECLARE; }
|
||||
YY_BREAK
|
||||
case 7:
|
||||
YY_RULE_SETUP
|
||||
#line 198 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 198 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return DEFINE; }
|
||||
YY_BREAK
|
||||
case 8:
|
||||
YY_RULE_SETUP
|
||||
#line 199 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 199 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return GLOBAL; }
|
||||
YY_BREAK
|
||||
case 9:
|
||||
YY_RULE_SETUP
|
||||
#line 200 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 200 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return CONSTANT; }
|
||||
YY_BREAK
|
||||
case 10:
|
||||
YY_RULE_SETUP
|
||||
#line 201 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 201 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return INTERNAL; }
|
||||
YY_BREAK
|
||||
case 11:
|
||||
YY_RULE_SETUP
|
||||
#line 202 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 202 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return LINKONCE; }
|
||||
YY_BREAK
|
||||
case 12:
|
||||
YY_RULE_SETUP
|
||||
#line 203 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 203 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return WEAK; }
|
||||
YY_BREAK
|
||||
case 13:
|
||||
YY_RULE_SETUP
|
||||
#line 204 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 204 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return APPENDING; }
|
||||
YY_BREAK
|
||||
case 14:
|
||||
YY_RULE_SETUP
|
||||
#line 205 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 205 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return DLLIMPORT; }
|
||||
YY_BREAK
|
||||
case 15:
|
||||
YY_RULE_SETUP
|
||||
#line 206 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 206 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return DLLEXPORT; }
|
||||
YY_BREAK
|
||||
case 16:
|
||||
YY_RULE_SETUP
|
||||
#line 207 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 207 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return HIDDEN; }
|
||||
YY_BREAK
|
||||
case 17:
|
||||
YY_RULE_SETUP
|
||||
#line 208 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 208 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return EXTERN_WEAK; }
|
||||
YY_BREAK
|
||||
case 18:
|
||||
YY_RULE_SETUP
|
||||
#line 209 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 209 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return EXTERNAL; }
|
||||
YY_BREAK
|
||||
case 19:
|
||||
YY_RULE_SETUP
|
||||
#line 210 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 210 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return IMPLEMENTATION; }
|
||||
YY_BREAK
|
||||
case 20:
|
||||
YY_RULE_SETUP
|
||||
#line 211 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 211 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return ZEROINITIALIZER; }
|
||||
YY_BREAK
|
||||
case 21:
|
||||
YY_RULE_SETUP
|
||||
#line 212 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 212 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return DOTDOTDOT; }
|
||||
YY_BREAK
|
||||
case 22:
|
||||
YY_RULE_SETUP
|
||||
#line 213 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 213 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return UNDEF; }
|
||||
YY_BREAK
|
||||
case 23:
|
||||
YY_RULE_SETUP
|
||||
#line 214 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 214 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return NULL_TOK; }
|
||||
YY_BREAK
|
||||
case 24:
|
||||
YY_RULE_SETUP
|
||||
#line 215 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 215 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return TO; }
|
||||
YY_BREAK
|
||||
case 25:
|
||||
YY_RULE_SETUP
|
||||
#line 216 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 216 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return TAIL; }
|
||||
YY_BREAK
|
||||
case 26:
|
||||
YY_RULE_SETUP
|
||||
#line 217 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 217 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return TARGET; }
|
||||
YY_BREAK
|
||||
case 27:
|
||||
YY_RULE_SETUP
|
||||
#line 218 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 218 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return TRIPLE; }
|
||||
YY_BREAK
|
||||
case 28:
|
||||
YY_RULE_SETUP
|
||||
#line 219 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 219 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return DEPLIBS; }
|
||||
YY_BREAK
|
||||
case 29:
|
||||
YY_RULE_SETUP
|
||||
#line 220 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 220 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return DATALAYOUT; }
|
||||
YY_BREAK
|
||||
case 30:
|
||||
YY_RULE_SETUP
|
||||
#line 221 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 221 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return VOLATILE; }
|
||||
YY_BREAK
|
||||
case 31:
|
||||
YY_RULE_SETUP
|
||||
#line 222 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 222 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return ALIGN; }
|
||||
YY_BREAK
|
||||
case 32:
|
||||
YY_RULE_SETUP
|
||||
#line 223 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 223 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return SECTION; }
|
||||
YY_BREAK
|
||||
case 33:
|
||||
YY_RULE_SETUP
|
||||
#line 224 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 224 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return MODULE; }
|
||||
YY_BREAK
|
||||
case 34:
|
||||
YY_RULE_SETUP
|
||||
#line 225 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 225 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return ASM_TOK; }
|
||||
YY_BREAK
|
||||
case 35:
|
||||
YY_RULE_SETUP
|
||||
#line 226 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 226 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return SIDEEFFECT; }
|
||||
YY_BREAK
|
||||
case 36:
|
||||
YY_RULE_SETUP
|
||||
#line 228 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 228 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return CC_TOK; }
|
||||
YY_BREAK
|
||||
case 37:
|
||||
YY_RULE_SETUP
|
||||
#line 229 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 229 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return CCC_TOK; }
|
||||
YY_BREAK
|
||||
case 38:
|
||||
YY_RULE_SETUP
|
||||
#line 230 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 230 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return FASTCC_TOK; }
|
||||
YY_BREAK
|
||||
case 39:
|
||||
YY_RULE_SETUP
|
||||
#line 231 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 231 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return COLDCC_TOK; }
|
||||
YY_BREAK
|
||||
case 40:
|
||||
YY_RULE_SETUP
|
||||
#line 232 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 232 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return X86_STDCALLCC_TOK; }
|
||||
YY_BREAK
|
||||
case 41:
|
||||
YY_RULE_SETUP
|
||||
#line 233 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 233 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return X86_FASTCALLCC_TOK; }
|
||||
YY_BREAK
|
||||
case 42:
|
||||
YY_RULE_SETUP
|
||||
#line 235 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 235 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return INREG; }
|
||||
YY_BREAK
|
||||
case 43:
|
||||
YY_RULE_SETUP
|
||||
#line 236 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 236 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return SRET; }
|
||||
YY_BREAK
|
||||
case 44:
|
||||
YY_RULE_SETUP
|
||||
#line 238 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 238 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TY(Type::VoidTy, VOID); }
|
||||
YY_BREAK
|
||||
case 45:
|
||||
YY_RULE_SETUP
|
||||
#line 239 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 239 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TY(Type::FloatTy, FLOAT); }
|
||||
YY_BREAK
|
||||
case 46:
|
||||
YY_RULE_SETUP
|
||||
#line 240 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 240 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TY(Type::DoubleTy,DOUBLE);}
|
||||
YY_BREAK
|
||||
case 47:
|
||||
YY_RULE_SETUP
|
||||
#line 241 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 241 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TY(Type::LabelTy, LABEL); }
|
||||
YY_BREAK
|
||||
case 48:
|
||||
YY_RULE_SETUP
|
||||
#line 242 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 242 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return TYPE; }
|
||||
YY_BREAK
|
||||
case 49:
|
||||
YY_RULE_SETUP
|
||||
#line 243 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 243 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return OPAQUE; }
|
||||
YY_BREAK
|
||||
case 50:
|
||||
YY_RULE_SETUP
|
||||
#line 244 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 244 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ uint64_t NumBits = atoull(yytext+1);
|
||||
if (NumBits < IntegerType::MIN_INT_BITS ||
|
||||
NumBits > IntegerType::MAX_INT_BITS)
|
||||
@ -1520,347 +1520,347 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 51:
|
||||
YY_RULE_SETUP
|
||||
#line 252 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 252 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(BinaryOpVal, Add, ADD); }
|
||||
YY_BREAK
|
||||
case 52:
|
||||
YY_RULE_SETUP
|
||||
#line 253 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 253 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(BinaryOpVal, Sub, SUB); }
|
||||
YY_BREAK
|
||||
case 53:
|
||||
YY_RULE_SETUP
|
||||
#line 254 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 254 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(BinaryOpVal, Mul, MUL); }
|
||||
YY_BREAK
|
||||
case 54:
|
||||
YY_RULE_SETUP
|
||||
#line 255 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 255 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(BinaryOpVal, UDiv, UDIV); }
|
||||
YY_BREAK
|
||||
case 55:
|
||||
YY_RULE_SETUP
|
||||
#line 256 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 256 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(BinaryOpVal, SDiv, SDIV); }
|
||||
YY_BREAK
|
||||
case 56:
|
||||
YY_RULE_SETUP
|
||||
#line 257 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 257 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(BinaryOpVal, FDiv, FDIV); }
|
||||
YY_BREAK
|
||||
case 57:
|
||||
YY_RULE_SETUP
|
||||
#line 258 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 258 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(BinaryOpVal, URem, UREM); }
|
||||
YY_BREAK
|
||||
case 58:
|
||||
YY_RULE_SETUP
|
||||
#line 259 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 259 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(BinaryOpVal, SRem, SREM); }
|
||||
YY_BREAK
|
||||
case 59:
|
||||
YY_RULE_SETUP
|
||||
#line 260 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 260 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(BinaryOpVal, FRem, FREM); }
|
||||
YY_BREAK
|
||||
case 60:
|
||||
YY_RULE_SETUP
|
||||
#line 261 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 261 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(BinaryOpVal, Shl, SHL); }
|
||||
YY_BREAK
|
||||
case 61:
|
||||
YY_RULE_SETUP
|
||||
#line 262 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 262 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(BinaryOpVal, LShr, LSHR); }
|
||||
YY_BREAK
|
||||
case 62:
|
||||
YY_RULE_SETUP
|
||||
#line 263 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 263 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(BinaryOpVal, AShr, ASHR); }
|
||||
YY_BREAK
|
||||
case 63:
|
||||
YY_RULE_SETUP
|
||||
#line 264 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 264 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(BinaryOpVal, And, AND); }
|
||||
YY_BREAK
|
||||
case 64:
|
||||
YY_RULE_SETUP
|
||||
#line 265 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 265 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(BinaryOpVal, Or , OR ); }
|
||||
YY_BREAK
|
||||
case 65:
|
||||
YY_RULE_SETUP
|
||||
#line 266 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 266 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(BinaryOpVal, Xor, XOR); }
|
||||
YY_BREAK
|
||||
case 66:
|
||||
YY_RULE_SETUP
|
||||
#line 267 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 267 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(OtherOpVal, ICmp, ICMP); }
|
||||
YY_BREAK
|
||||
case 67:
|
||||
YY_RULE_SETUP
|
||||
#line 268 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 268 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(OtherOpVal, FCmp, FCMP); }
|
||||
YY_BREAK
|
||||
case 68:
|
||||
YY_RULE_SETUP
|
||||
#line 270 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 270 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return EQ; }
|
||||
YY_BREAK
|
||||
case 69:
|
||||
YY_RULE_SETUP
|
||||
#line 271 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 271 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return NE; }
|
||||
YY_BREAK
|
||||
case 70:
|
||||
YY_RULE_SETUP
|
||||
#line 272 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 272 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return SLT; }
|
||||
YY_BREAK
|
||||
case 71:
|
||||
YY_RULE_SETUP
|
||||
#line 273 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 273 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return SGT; }
|
||||
YY_BREAK
|
||||
case 72:
|
||||
YY_RULE_SETUP
|
||||
#line 274 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 274 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return SLE; }
|
||||
YY_BREAK
|
||||
case 73:
|
||||
YY_RULE_SETUP
|
||||
#line 275 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 275 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return SGE; }
|
||||
YY_BREAK
|
||||
case 74:
|
||||
YY_RULE_SETUP
|
||||
#line 276 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 276 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return ULT; }
|
||||
YY_BREAK
|
||||
case 75:
|
||||
YY_RULE_SETUP
|
||||
#line 277 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 277 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return UGT; }
|
||||
YY_BREAK
|
||||
case 76:
|
||||
YY_RULE_SETUP
|
||||
#line 278 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 278 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return ULE; }
|
||||
YY_BREAK
|
||||
case 77:
|
||||
YY_RULE_SETUP
|
||||
#line 279 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 279 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return UGE; }
|
||||
YY_BREAK
|
||||
case 78:
|
||||
YY_RULE_SETUP
|
||||
#line 280 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 280 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return OEQ; }
|
||||
YY_BREAK
|
||||
case 79:
|
||||
YY_RULE_SETUP
|
||||
#line 281 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 281 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return ONE; }
|
||||
YY_BREAK
|
||||
case 80:
|
||||
YY_RULE_SETUP
|
||||
#line 282 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 282 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return OLT; }
|
||||
YY_BREAK
|
||||
case 81:
|
||||
YY_RULE_SETUP
|
||||
#line 283 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 283 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return OGT; }
|
||||
YY_BREAK
|
||||
case 82:
|
||||
YY_RULE_SETUP
|
||||
#line 284 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 284 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return OLE; }
|
||||
YY_BREAK
|
||||
case 83:
|
||||
YY_RULE_SETUP
|
||||
#line 285 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 285 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return OGE; }
|
||||
YY_BREAK
|
||||
case 84:
|
||||
YY_RULE_SETUP
|
||||
#line 286 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 286 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return ORD; }
|
||||
YY_BREAK
|
||||
case 85:
|
||||
YY_RULE_SETUP
|
||||
#line 287 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 287 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return UNO; }
|
||||
YY_BREAK
|
||||
case 86:
|
||||
YY_RULE_SETUP
|
||||
#line 288 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 288 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return UEQ; }
|
||||
YY_BREAK
|
||||
case 87:
|
||||
YY_RULE_SETUP
|
||||
#line 289 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 289 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return UNE; }
|
||||
YY_BREAK
|
||||
case 88:
|
||||
YY_RULE_SETUP
|
||||
#line 291 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 291 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(OtherOpVal, PHI, PHI_TOK); }
|
||||
YY_BREAK
|
||||
case 89:
|
||||
YY_RULE_SETUP
|
||||
#line 292 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 292 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(OtherOpVal, Call, CALL); }
|
||||
YY_BREAK
|
||||
case 90:
|
||||
YY_RULE_SETUP
|
||||
#line 293 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 293 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(CastOpVal, Trunc, TRUNC); }
|
||||
YY_BREAK
|
||||
case 91:
|
||||
YY_RULE_SETUP
|
||||
#line 294 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 294 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(CastOpVal, ZExt, ZEXT); }
|
||||
YY_BREAK
|
||||
case 92:
|
||||
YY_RULE_SETUP
|
||||
#line 295 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 295 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(CastOpVal, SExt, SEXT); }
|
||||
YY_BREAK
|
||||
case 93:
|
||||
YY_RULE_SETUP
|
||||
#line 296 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 296 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(CastOpVal, FPTrunc, FPTRUNC); }
|
||||
YY_BREAK
|
||||
case 94:
|
||||
YY_RULE_SETUP
|
||||
#line 297 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 297 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(CastOpVal, FPExt, FPEXT); }
|
||||
YY_BREAK
|
||||
case 95:
|
||||
YY_RULE_SETUP
|
||||
#line 298 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 298 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(CastOpVal, UIToFP, UITOFP); }
|
||||
YY_BREAK
|
||||
case 96:
|
||||
YY_RULE_SETUP
|
||||
#line 299 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 299 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(CastOpVal, SIToFP, SITOFP); }
|
||||
YY_BREAK
|
||||
case 97:
|
||||
YY_RULE_SETUP
|
||||
#line 300 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 300 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(CastOpVal, FPToUI, FPTOUI); }
|
||||
YY_BREAK
|
||||
case 98:
|
||||
YY_RULE_SETUP
|
||||
#line 301 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 301 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(CastOpVal, FPToSI, FPTOSI); }
|
||||
YY_BREAK
|
||||
case 99:
|
||||
YY_RULE_SETUP
|
||||
#line 302 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 302 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(CastOpVal, IntToPtr, INTTOPTR); }
|
||||
YY_BREAK
|
||||
case 100:
|
||||
YY_RULE_SETUP
|
||||
#line 303 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 303 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(CastOpVal, PtrToInt, PTRTOINT); }
|
||||
YY_BREAK
|
||||
case 101:
|
||||
YY_RULE_SETUP
|
||||
#line 304 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 304 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(CastOpVal, BitCast, BITCAST); }
|
||||
YY_BREAK
|
||||
case 102:
|
||||
YY_RULE_SETUP
|
||||
#line 305 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 305 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(OtherOpVal, Select, SELECT); }
|
||||
YY_BREAK
|
||||
case 103:
|
||||
YY_RULE_SETUP
|
||||
#line 306 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 306 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(OtherOpVal, VAArg , VAARG); }
|
||||
YY_BREAK
|
||||
case 104:
|
||||
YY_RULE_SETUP
|
||||
#line 307 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 307 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(TermOpVal, Ret, RET); }
|
||||
YY_BREAK
|
||||
case 105:
|
||||
YY_RULE_SETUP
|
||||
#line 308 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 308 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(TermOpVal, Br, BR); }
|
||||
YY_BREAK
|
||||
case 106:
|
||||
YY_RULE_SETUP
|
||||
#line 309 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 309 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(TermOpVal, Switch, SWITCH); }
|
||||
YY_BREAK
|
||||
case 107:
|
||||
YY_RULE_SETUP
|
||||
#line 310 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 310 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(TermOpVal, Invoke, INVOKE); }
|
||||
YY_BREAK
|
||||
case 108:
|
||||
YY_RULE_SETUP
|
||||
#line 311 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 311 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(TermOpVal, Unwind, UNWIND); }
|
||||
YY_BREAK
|
||||
case 109:
|
||||
YY_RULE_SETUP
|
||||
#line 312 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 312 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(TermOpVal, Unreachable, UNREACHABLE); }
|
||||
YY_BREAK
|
||||
case 110:
|
||||
YY_RULE_SETUP
|
||||
#line 314 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 314 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(MemOpVal, Malloc, MALLOC); }
|
||||
YY_BREAK
|
||||
case 111:
|
||||
YY_RULE_SETUP
|
||||
#line 315 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 315 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(MemOpVal, Alloca, ALLOCA); }
|
||||
YY_BREAK
|
||||
case 112:
|
||||
YY_RULE_SETUP
|
||||
#line 316 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 316 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(MemOpVal, Free, FREE); }
|
||||
YY_BREAK
|
||||
case 113:
|
||||
YY_RULE_SETUP
|
||||
#line 317 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 317 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(MemOpVal, Load, LOAD); }
|
||||
YY_BREAK
|
||||
case 114:
|
||||
YY_RULE_SETUP
|
||||
#line 318 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 318 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(MemOpVal, Store, STORE); }
|
||||
YY_BREAK
|
||||
case 115:
|
||||
YY_RULE_SETUP
|
||||
#line 319 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 319 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(MemOpVal, GetElementPtr, GETELEMENTPTR); }
|
||||
YY_BREAK
|
||||
case 116:
|
||||
YY_RULE_SETUP
|
||||
#line 321 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 321 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(OtherOpVal, ExtractElement, EXTRACTELEMENT); }
|
||||
YY_BREAK
|
||||
case 117:
|
||||
YY_RULE_SETUP
|
||||
#line 322 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 322 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(OtherOpVal, InsertElement, INSERTELEMENT); }
|
||||
YY_BREAK
|
||||
case 118:
|
||||
YY_RULE_SETUP
|
||||
#line 323 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 323 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ RET_TOK(OtherOpVal, ShuffleVector, SHUFFLEVECTOR); }
|
||||
YY_BREAK
|
||||
case 119:
|
||||
YY_RULE_SETUP
|
||||
#line 326 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 326 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{
|
||||
UnEscapeLexed(yytext+1);
|
||||
llvmAsmlval.StrVal = strdup(yytext+1); // Skip %
|
||||
@ -1869,7 +1869,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 120:
|
||||
YY_RULE_SETUP
|
||||
#line 331 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 331 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{
|
||||
UnEscapeLexed(yytext+1);
|
||||
llvmAsmlval.StrVal = strdup(yytext+1); // Skip @
|
||||
@ -1878,7 +1878,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 121:
|
||||
YY_RULE_SETUP
|
||||
#line 336 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 336 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{
|
||||
yytext[strlen(yytext)-1] = 0; // nuke colon
|
||||
UnEscapeLexed(yytext);
|
||||
@ -1888,7 +1888,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 122:
|
||||
YY_RULE_SETUP
|
||||
#line 342 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 342 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{
|
||||
yytext[strlen(yytext)-2] = 0; // nuke colon, end quote
|
||||
UnEscapeLexed(yytext+1);
|
||||
@ -1898,7 +1898,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 123:
|
||||
YY_RULE_SETUP
|
||||
#line 349 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 349 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ // Note that we cannot unescape a string constant here! The
|
||||
// string constant might contain a \00 which would not be
|
||||
// understood by the string stuff. It is valid to make a
|
||||
@ -1911,7 +1911,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 124:
|
||||
YY_RULE_SETUP
|
||||
#line 358 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 358 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{
|
||||
yytext[strlen(yytext)-1] = 0; // nuke end quote
|
||||
llvmAsmlval.StrVal = strdup(yytext+2); // Nuke @, quote
|
||||
@ -1920,12 +1920,12 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 125:
|
||||
YY_RULE_SETUP
|
||||
#line 366 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 366 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ llvmAsmlval.UInt64Val = atoull(yytext); return EUINT64VAL; }
|
||||
YY_BREAK
|
||||
case 126:
|
||||
YY_RULE_SETUP
|
||||
#line 367 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 367 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{
|
||||
uint64_t Val = atoull(yytext+1);
|
||||
// +1: we have bigger negative range
|
||||
@ -1937,7 +1937,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 127:
|
||||
YY_RULE_SETUP
|
||||
#line 375 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 375 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{
|
||||
llvmAsmlval.UInt64Val = HexIntToVal(yytext+3);
|
||||
return yytext[0] == 's' ? ESINT64VAL : EUINT64VAL;
|
||||
@ -1945,7 +1945,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 128:
|
||||
YY_RULE_SETUP
|
||||
#line 380 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 380 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{
|
||||
uint64_t Val = atoull(yytext+1);
|
||||
if ((unsigned)Val != Val)
|
||||
@ -1956,7 +1956,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 129:
|
||||
YY_RULE_SETUP
|
||||
#line 387 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 387 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{
|
||||
uint64_t Val = atoull(yytext+1);
|
||||
if ((unsigned)Val != Val)
|
||||
@ -1967,16 +1967,16 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 130:
|
||||
YY_RULE_SETUP
|
||||
#line 395 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 395 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ llvmAsmlval.FPVal = atof(yytext); return FPVAL; }
|
||||
YY_BREAK
|
||||
case 131:
|
||||
YY_RULE_SETUP
|
||||
#line 396 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 396 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ llvmAsmlval.FPVal = HexToFP(yytext); return FPVAL; }
|
||||
YY_BREAK
|
||||
case YY_STATE_EOF(INITIAL):
|
||||
#line 398 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 398 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{
|
||||
/* Make sure to free the internal buffers for flex when we are
|
||||
* done reading our input!
|
||||
@ -1987,17 +1987,17 @@ case YY_STATE_EOF(INITIAL):
|
||||
YY_BREAK
|
||||
case 132:
|
||||
YY_RULE_SETUP
|
||||
#line 406 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 406 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ /* Ignore whitespace */ }
|
||||
YY_BREAK
|
||||
case 133:
|
||||
YY_RULE_SETUP
|
||||
#line 407 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 407 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
{ return yytext[0]; }
|
||||
YY_BREAK
|
||||
case 134:
|
||||
YY_RULE_SETUP
|
||||
#line 409 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 409 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
YY_FATAL_ERROR( "flex scanner jammed" );
|
||||
YY_BREAK
|
||||
#line 2004 "Lexer.cpp"
|
||||
@ -2878,5 +2878,5 @@ int main()
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#line 409 "/proj/llvm/llvm-4/lib/AsmParser/Lexer.l"
|
||||
#line 409 "/proj/llvm/llvm-3/lib/AsmParser/Lexer.l"
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -295,7 +295,7 @@
|
||||
|
||||
|
||||
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
|
||||
#line 886 "/proj/llvm/llvm-4/lib/AsmParser/llvmAsmParser.y"
|
||||
#line 900 "/proj/llvm/llvm-3/lib/AsmParser/llvmAsmParser.y"
|
||||
typedef union YYSTYPE {
|
||||
llvm::Module *ModuleVal;
|
||||
llvm::Function *FunctionVal;
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "llvm/InlineAsm.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/SymbolTable.h"
|
||||
#include "llvm/ValueSymbolTable.h"
|
||||
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
@ -209,7 +209,7 @@ static struct PerFunctionInfo {
|
||||
|
||||
std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
|
||||
std::map<const Type*, ValueList> LateResolveValues;
|
||||
bool isDeclare; // Is this function a forward declararation?
|
||||
bool isDeclare; // Is this function a forward declararation?
|
||||
GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
|
||||
GlobalValue::VisibilityTypes Visibility;
|
||||
|
||||
@ -341,24 +341,33 @@ static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
|
||||
|
||||
// Module constants occupy the lowest numbered slots...
|
||||
std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
|
||||
if (VI == CurModule.Values.end()) return 0;
|
||||
if (D.Num >= VI->second.size()) return 0;
|
||||
if (VI == CurModule.Values.end())
|
||||
return 0;
|
||||
if (D.Num >= VI->second.size())
|
||||
return 0;
|
||||
return VI->second[Num];
|
||||
}
|
||||
|
||||
case ValID::LocalName: { // Is it a named definition?
|
||||
if (!inFunctionScope()) return 0;
|
||||
SymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
|
||||
Value *N = SymTab.lookup(Ty, D.Name);
|
||||
if (N == 0) return 0;
|
||||
if (!inFunctionScope())
|
||||
return 0;
|
||||
ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
|
||||
Value *N = SymTab.lookup(D.Name);
|
||||
if (N == 0)
|
||||
return 0;
|
||||
if (N->getType() != Ty)
|
||||
return 0;
|
||||
|
||||
D.destroy(); // Free old strdup'd memory...
|
||||
return N;
|
||||
}
|
||||
case ValID::GlobalName: { // Is it a named definition?
|
||||
SymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
|
||||
Value *N = SymTab.lookup(Ty, D.Name);
|
||||
if (N == 0) return 0;
|
||||
ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
|
||||
Value *N = SymTab.lookup(D.Name);
|
||||
if (N == 0)
|
||||
return 0;
|
||||
if (N->getType() != Ty)
|
||||
return 0;
|
||||
|
||||
D.destroy(); // Free old strdup'd memory...
|
||||
return N;
|
||||
@ -499,8 +508,8 @@ static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
|
||||
break;
|
||||
case ValID::LocalName: // Is it a named definition?
|
||||
Name = ID.Name;
|
||||
if (Value *N = CurFun.CurrentFunction->
|
||||
getValueSymbolTable().lookup(Type::LabelTy, Name))
|
||||
Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
|
||||
if (N && N->getType()->getTypeID() == Type::LabelTyID)
|
||||
BB = cast<BasicBlock>(N);
|
||||
break;
|
||||
}
|
||||
@ -640,8 +649,8 @@ static void setValueName(Value *V, char *NameStr) {
|
||||
}
|
||||
|
||||
assert(inFunctionScope() && "Must be in function scope!");
|
||||
SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
|
||||
if (ST.lookup(V->getType(), Name)) {
|
||||
ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
|
||||
if (ST.lookup(Name)) {
|
||||
GenerateError("Redefinition of value '" + Name + "' of type '" +
|
||||
V->getType()->getDescription() + "'");
|
||||
return;
|
||||
@ -695,16 +704,21 @@ ParseGlobalVariable(char *NameStr,
|
||||
return GV;
|
||||
}
|
||||
|
||||
// If this global has a name, check to see if there is already a definition
|
||||
// of this global in the module. If so, it is an error.
|
||||
// If this global has a name
|
||||
if (!Name.empty()) {
|
||||
// We are a simple redefinition of a value, check to see if it is defined
|
||||
// the same as the old one.
|
||||
if (CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
|
||||
GenerateError("Redefinition of global variable named '" + Name +
|
||||
"' of type '" + Ty->getDescription() + "'");
|
||||
return 0;
|
||||
}
|
||||
// if the global we're parsing has an initializer (is a definition) and
|
||||
// has external linkage.
|
||||
if (Initializer && Linkage != GlobalValue::InternalLinkage)
|
||||
// If there is already a global with external linkage with this name
|
||||
if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
|
||||
// If we allow this GVar to get created, it will be renamed in the
|
||||
// symbol table because it conflicts with an existing GVar. We can't
|
||||
// allow redefinition of GVars whose linking indicates that their name
|
||||
// must stay the same. Issue the error.
|
||||
GenerateError("Redefinition of global variable named '" + Name +
|
||||
"' of type '" + Ty->getDescription() + "'");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise there is no existing GV to use, create one now.
|
||||
@ -2078,17 +2092,21 @@ FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')'
|
||||
CurModule.CurrentModule->getFunctionList().remove(Fn);
|
||||
CurModule.CurrentModule->getFunctionList().push_back(Fn);
|
||||
} else if (!FunctionName.empty() && // Merge with an earlier prototype?
|
||||
(Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
|
||||
// If this is the case, either we need to be a forward decl, or it needs
|
||||
// to be.
|
||||
if (!CurFun.isDeclare && !Fn->isDeclaration())
|
||||
(Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
|
||||
if (Fn->getFunctionType() != FT ) {
|
||||
// The existing function doesn't have the same type. This is an overload
|
||||
// error.
|
||||
GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
|
||||
} else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
|
||||
// Neither the existing or the current function is a declaration and they
|
||||
// have the same name and same type. Clearly this is a redefinition.
|
||||
GEN_ERROR("Redefinition of function '" + FunctionName + "'");
|
||||
|
||||
// Make sure to strip off any argument names so we can't get conflicts.
|
||||
if (Fn->isDeclaration())
|
||||
} if (Fn->isDeclaration()) {
|
||||
// Make sure to strip off any argument names so we can't get conflicts.
|
||||
for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
|
||||
AI != AE; ++AI)
|
||||
AI->setName("");
|
||||
}
|
||||
} else { // Not already defined?
|
||||
Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
|
||||
CurModule.CurrentModule);
|
||||
@ -2115,16 +2133,18 @@ FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')'
|
||||
// Add all of the arguments we parsed to the function...
|
||||
if ($5) { // Is null if empty...
|
||||
if (isVarArg) { // Nuke the last entry
|
||||
assert($5->back().Ty->get() == Type::VoidTy && $5->back().Name == 0&&
|
||||
assert($5->back().Ty->get() == Type::VoidTy && $5->back().Name == 0 &&
|
||||
"Not a varargs marker!");
|
||||
delete $5->back().Ty;
|
||||
$5->pop_back(); // Delete the last entry
|
||||
}
|
||||
Function::arg_iterator ArgIt = Fn->arg_begin();
|
||||
Function::arg_iterator ArgEnd = Fn->arg_end();
|
||||
unsigned Idx = 1;
|
||||
for (ArgListType::iterator I = $5->begin(); I != $5->end(); ++I, ++ArgIt) {
|
||||
for (ArgListType::iterator I = $5->begin();
|
||||
I != $5->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
|
||||
delete I->Ty; // Delete the typeholder...
|
||||
setValueName(ArgIt, I->Name); // Insert arg into symtab...
|
||||
setValueName(ArgIt, I->Name); // Insert arg into symtab...
|
||||
CHECK_FOR_ERROR
|
||||
InsertValue(ArgIt);
|
||||
Idx++;
|
||||
@ -2299,7 +2319,6 @@ BasicBlock : InstructionList OptLocalAssign BBTerminatorInst {
|
||||
setValueName($3, $2);
|
||||
CHECK_FOR_ERROR
|
||||
InsertValue($3);
|
||||
|
||||
$1->getInstList().push_back($3);
|
||||
InsertValue($1);
|
||||
$$ = $1;
|
||||
@ -2494,13 +2513,14 @@ JumpTable : JumpTable IntType ConstValueRef ',' LABEL ValueRef {
|
||||
};
|
||||
|
||||
Inst : OptLocalAssign InstVal {
|
||||
// Is this definition named?? if so, assign the name...
|
||||
setValueName($2, $1);
|
||||
CHECK_FOR_ERROR
|
||||
InsertValue($2);
|
||||
$$ = $2;
|
||||
CHECK_FOR_ERROR
|
||||
};
|
||||
// Is this definition named?? if so, assign the name...
|
||||
setValueName($2, $1);
|
||||
CHECK_FOR_ERROR
|
||||
InsertValue($2);
|
||||
$$ = $2;
|
||||
CHECK_FOR_ERROR
|
||||
};
|
||||
|
||||
|
||||
PHIList : Types '[' ValueRef ',' ValueRef ']' { // Used for PHI nodes
|
||||
if (!UpRefs.empty())
|
||||
@ -2570,7 +2590,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
|
||||
($1 == Instruction::URem ||
|
||||
$1 == Instruction::SRem ||
|
||||
$1 == Instruction::FRem))
|
||||
GEN_ERROR("U/S/FRem not supported on packed types");
|
||||
GEN_ERROR("Remainder not supported on packed types");
|
||||
Value* val1 = getVal(*$2, $3);
|
||||
CHECK_FOR_ERROR
|
||||
Value* val2 = getVal(*$2, $5);
|
||||
@ -2890,11 +2910,10 @@ int yyerror(const char *ErrorMsg) {
|
||||
std::string where
|
||||
= std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
|
||||
+ ":" + utostr((unsigned) llvmAsmlineno) + ": ";
|
||||
std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
|
||||
if (yychar == YYEMPTY || yychar == 0)
|
||||
errMsg += "end-of-file.";
|
||||
else
|
||||
errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
|
||||
std::string errMsg = where + "error: " + std::string(ErrorMsg);
|
||||
if (yychar != YYEMPTY && yychar != 0)
|
||||
errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
|
||||
"'";
|
||||
GenerateError(errMsg);
|
||||
return 0;
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "llvm/InlineAsm.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/SymbolTable.h"
|
||||
#include "llvm/ValueSymbolTable.h"
|
||||
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
#include "llvm/ADT/SmallVector.h"
|
||||
@ -209,7 +209,7 @@ static struct PerFunctionInfo {
|
||||
|
||||
std::map<const Type*, ValueList> Values; // Keep track of #'d definitions
|
||||
std::map<const Type*, ValueList> LateResolveValues;
|
||||
bool isDeclare; // Is this function a forward declararation?
|
||||
bool isDeclare; // Is this function a forward declararation?
|
||||
GlobalValue::LinkageTypes Linkage; // Linkage for forward declaration.
|
||||
GlobalValue::VisibilityTypes Visibility;
|
||||
|
||||
@ -341,24 +341,33 @@ static Value *getValNonImprovising(const Type *Ty, const ValID &D) {
|
||||
|
||||
// Module constants occupy the lowest numbered slots...
|
||||
std::map<const Type*,ValueList>::iterator VI = CurModule.Values.find(Ty);
|
||||
if (VI == CurModule.Values.end()) return 0;
|
||||
if (D.Num >= VI->second.size()) return 0;
|
||||
if (VI == CurModule.Values.end())
|
||||
return 0;
|
||||
if (D.Num >= VI->second.size())
|
||||
return 0;
|
||||
return VI->second[Num];
|
||||
}
|
||||
|
||||
case ValID::LocalName: { // Is it a named definition?
|
||||
if (!inFunctionScope()) return 0;
|
||||
SymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
|
||||
Value *N = SymTab.lookup(Ty, D.Name);
|
||||
if (N == 0) return 0;
|
||||
if (!inFunctionScope())
|
||||
return 0;
|
||||
ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
|
||||
Value *N = SymTab.lookup(D.Name);
|
||||
if (N == 0)
|
||||
return 0;
|
||||
if (N->getType() != Ty)
|
||||
return 0;
|
||||
|
||||
D.destroy(); // Free old strdup'd memory...
|
||||
return N;
|
||||
}
|
||||
case ValID::GlobalName: { // Is it a named definition?
|
||||
SymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
|
||||
Value *N = SymTab.lookup(Ty, D.Name);
|
||||
if (N == 0) return 0;
|
||||
ValueSymbolTable &SymTab = CurModule.CurrentModule->getValueSymbolTable();
|
||||
Value *N = SymTab.lookup(D.Name);
|
||||
if (N == 0)
|
||||
return 0;
|
||||
if (N->getType() != Ty)
|
||||
return 0;
|
||||
|
||||
D.destroy(); // Free old strdup'd memory...
|
||||
return N;
|
||||
@ -499,8 +508,8 @@ static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
|
||||
break;
|
||||
case ValID::LocalName: // Is it a named definition?
|
||||
Name = ID.Name;
|
||||
if (Value *N = CurFun.CurrentFunction->
|
||||
getValueSymbolTable().lookup(Type::LabelTy, Name))
|
||||
Value *N = CurFun.CurrentFunction->getValueSymbolTable().lookup(Name);
|
||||
if (N && N->getType()->getTypeID() == Type::LabelTyID)
|
||||
BB = cast<BasicBlock>(N);
|
||||
break;
|
||||
}
|
||||
@ -640,8 +649,8 @@ static void setValueName(Value *V, char *NameStr) {
|
||||
}
|
||||
|
||||
assert(inFunctionScope() && "Must be in function scope!");
|
||||
SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
|
||||
if (ST.lookup(V->getType(), Name)) {
|
||||
ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
|
||||
if (ST.lookup(Name)) {
|
||||
GenerateError("Redefinition of value '" + Name + "' of type '" +
|
||||
V->getType()->getDescription() + "'");
|
||||
return;
|
||||
@ -695,16 +704,21 @@ ParseGlobalVariable(char *NameStr,
|
||||
return GV;
|
||||
}
|
||||
|
||||
// If this global has a name, check to see if there is already a definition
|
||||
// of this global in the module. If so, it is an error.
|
||||
// If this global has a name
|
||||
if (!Name.empty()) {
|
||||
// We are a simple redefinition of a value, check to see if it is defined
|
||||
// the same as the old one.
|
||||
if (CurModule.CurrentModule->getGlobalVariable(Name, Ty)) {
|
||||
GenerateError("Redefinition of global variable named '" + Name +
|
||||
"' of type '" + Ty->getDescription() + "'");
|
||||
return 0;
|
||||
}
|
||||
// if the global we're parsing has an initializer (is a definition) and
|
||||
// has external linkage.
|
||||
if (Initializer && Linkage != GlobalValue::InternalLinkage)
|
||||
// If there is already a global with external linkage with this name
|
||||
if (CurModule.CurrentModule->getGlobalVariable(Name, false)) {
|
||||
// If we allow this GVar to get created, it will be renamed in the
|
||||
// symbol table because it conflicts with an existing GVar. We can't
|
||||
// allow redefinition of GVars whose linking indicates that their name
|
||||
// must stay the same. Issue the error.
|
||||
GenerateError("Redefinition of global variable named '" + Name +
|
||||
"' of type '" + Ty->getDescription() + "'");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Otherwise there is no existing GV to use, create one now.
|
||||
@ -2078,17 +2092,21 @@ FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')'
|
||||
CurModule.CurrentModule->getFunctionList().remove(Fn);
|
||||
CurModule.CurrentModule->getFunctionList().push_back(Fn);
|
||||
} else if (!FunctionName.empty() && // Merge with an earlier prototype?
|
||||
(Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
|
||||
// If this is the case, either we need to be a forward decl, or it needs
|
||||
// to be.
|
||||
if (!CurFun.isDeclare && !Fn->isDeclaration())
|
||||
(Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
|
||||
if (Fn->getFunctionType() != FT ) {
|
||||
// The existing function doesn't have the same type. This is an overload
|
||||
// error.
|
||||
GEN_ERROR("Overload of function '" + FunctionName + "' not permitted.");
|
||||
} else if (!CurFun.isDeclare && !Fn->isDeclaration()) {
|
||||
// Neither the existing or the current function is a declaration and they
|
||||
// have the same name and same type. Clearly this is a redefinition.
|
||||
GEN_ERROR("Redefinition of function '" + FunctionName + "'");
|
||||
|
||||
// Make sure to strip off any argument names so we can't get conflicts.
|
||||
if (Fn->isDeclaration())
|
||||
} if (Fn->isDeclaration()) {
|
||||
// Make sure to strip off any argument names so we can't get conflicts.
|
||||
for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
|
||||
AI != AE; ++AI)
|
||||
AI->setName("");
|
||||
}
|
||||
} else { // Not already defined?
|
||||
Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
|
||||
CurModule.CurrentModule);
|
||||
@ -2115,16 +2133,18 @@ FunctionHeaderH : OptCallingConv ResultTypes GlobalName '(' ArgList ')'
|
||||
// Add all of the arguments we parsed to the function...
|
||||
if ($5) { // Is null if empty...
|
||||
if (isVarArg) { // Nuke the last entry
|
||||
assert($5->back().Ty->get() == Type::VoidTy && $5->back().Name == 0&&
|
||||
assert($5->back().Ty->get() == Type::VoidTy && $5->back().Name == 0 &&
|
||||
"Not a varargs marker!");
|
||||
delete $5->back().Ty;
|
||||
$5->pop_back(); // Delete the last entry
|
||||
}
|
||||
Function::arg_iterator ArgIt = Fn->arg_begin();
|
||||
Function::arg_iterator ArgEnd = Fn->arg_end();
|
||||
unsigned Idx = 1;
|
||||
for (ArgListType::iterator I = $5->begin(); I != $5->end(); ++I, ++ArgIt) {
|
||||
for (ArgListType::iterator I = $5->begin();
|
||||
I != $5->end() && ArgIt != ArgEnd; ++I, ++ArgIt) {
|
||||
delete I->Ty; // Delete the typeholder...
|
||||
setValueName(ArgIt, I->Name); // Insert arg into symtab...
|
||||
setValueName(ArgIt, I->Name); // Insert arg into symtab...
|
||||
CHECK_FOR_ERROR
|
||||
InsertValue(ArgIt);
|
||||
Idx++;
|
||||
@ -2299,7 +2319,6 @@ BasicBlock : InstructionList OptLocalAssign BBTerminatorInst {
|
||||
setValueName($3, $2);
|
||||
CHECK_FOR_ERROR
|
||||
InsertValue($3);
|
||||
|
||||
$1->getInstList().push_back($3);
|
||||
InsertValue($1);
|
||||
$$ = $1;
|
||||
@ -2494,13 +2513,14 @@ JumpTable : JumpTable IntType ConstValueRef ',' LABEL ValueRef {
|
||||
};
|
||||
|
||||
Inst : OptLocalAssign InstVal {
|
||||
// Is this definition named?? if so, assign the name...
|
||||
setValueName($2, $1);
|
||||
CHECK_FOR_ERROR
|
||||
InsertValue($2);
|
||||
$$ = $2;
|
||||
CHECK_FOR_ERROR
|
||||
};
|
||||
// Is this definition named?? if so, assign the name...
|
||||
setValueName($2, $1);
|
||||
CHECK_FOR_ERROR
|
||||
InsertValue($2);
|
||||
$$ = $2;
|
||||
CHECK_FOR_ERROR
|
||||
};
|
||||
|
||||
|
||||
PHIList : Types '[' ValueRef ',' ValueRef ']' { // Used for PHI nodes
|
||||
if (!UpRefs.empty())
|
||||
@ -2570,7 +2590,7 @@ InstVal : ArithmeticOps Types ValueRef ',' ValueRef {
|
||||
($1 == Instruction::URem ||
|
||||
$1 == Instruction::SRem ||
|
||||
$1 == Instruction::FRem))
|
||||
GEN_ERROR("U/S/FRem not supported on packed types");
|
||||
GEN_ERROR("Remainder not supported on packed types");
|
||||
Value* val1 = getVal(*$2, $3);
|
||||
CHECK_FOR_ERROR
|
||||
Value* val2 = getVal(*$2, $5);
|
||||
@ -2890,11 +2910,10 @@ int yyerror(const char *ErrorMsg) {
|
||||
std::string where
|
||||
= std::string((CurFilename == "-") ? std::string("<stdin>") : CurFilename)
|
||||
+ ":" + utostr((unsigned) llvmAsmlineno) + ": ";
|
||||
std::string errMsg = std::string(ErrorMsg) + "\n" + where + " while reading ";
|
||||
if (yychar == YYEMPTY || yychar == 0)
|
||||
errMsg += "end-of-file.";
|
||||
else
|
||||
errMsg += "token: '" + std::string(llvmAsmtext, llvmAsmleng) + "'";
|
||||
std::string errMsg = where + "error: " + std::string(ErrorMsg);
|
||||
if (yychar != YYEMPTY && yychar != 0)
|
||||
errMsg += " while reading token: '" + std::string(llvmAsmtext, llvmAsmleng)+
|
||||
"'";
|
||||
GenerateError(errMsg);
|
||||
return 0;
|
||||
}
|
||||
|
@ -270,19 +270,15 @@ public:
|
||||
*os << " } END BLOCK: CompactionTable\n";
|
||||
}
|
||||
|
||||
virtual void handleSymbolTableBegin(Function* CF, SymbolTable* ST) {
|
||||
virtual void handleTypeSymbolTableBegin(TypeSymbolTable* ST) {
|
||||
bca.numSymTab++;
|
||||
if (os)
|
||||
*os << " BLOCK: SymbolTable {\n";
|
||||
*os << " BLOCK: TypeSymbolTable {\n";
|
||||
}
|
||||
|
||||
virtual void handleSymbolTablePlane(unsigned Ty, unsigned NumEntries,
|
||||
const Type* Typ) {
|
||||
if (os) {
|
||||
*os << " Plane: Ty=" << Ty << " Size=" << NumEntries << " Type: ";
|
||||
WriteTypeSymbolic(*os,Typ,M);
|
||||
*os << "\n";
|
||||
}
|
||||
virtual void handleValueSymbolTableBegin(Function* CF, ValueSymbolTable* ST) {
|
||||
bca.numSymTab++;
|
||||
if (os)
|
||||
*os << " BLOCK: ValueSymbolTable {\n";
|
||||
}
|
||||
|
||||
virtual void handleSymbolTableType(unsigned i, unsigned TypSlot,
|
||||
@ -292,18 +288,23 @@ public:
|
||||
<< " Name: " << name << "\n";
|
||||
}
|
||||
|
||||
virtual void handleSymbolTableValue(unsigned i, unsigned ValSlot,
|
||||
const std::string& name ) {
|
||||
virtual void handleSymbolTableValue(unsigned TySlot, unsigned ValSlot,
|
||||
const std::string& name) {
|
||||
if (os)
|
||||
*os << " Value " << i << " Slot=" << ValSlot
|
||||
*os << " Value " << TySlot << " Slot=" << ValSlot
|
||||
<< " Name: " << name << "\n";
|
||||
if (ValSlot > bca.maxValueSlot)
|
||||
bca.maxValueSlot = ValSlot;
|
||||
}
|
||||
|
||||
virtual void handleSymbolTableEnd() {
|
||||
virtual void handleValueSymbolTableEnd() {
|
||||
if (os)
|
||||
*os << " } END BLOCK: SymbolTable\n";
|
||||
*os << " } END BLOCK: ValueSymbolTable\n";
|
||||
}
|
||||
|
||||
virtual void handleTypeSymbolTableEnd() {
|
||||
if (os)
|
||||
*os << " } END BLOCK: TypeSymbolTable\n";
|
||||
}
|
||||
|
||||
virtual void handleFunctionBegin(Function* Func, unsigned Size) {
|
||||
@ -358,15 +359,15 @@ public:
|
||||
}
|
||||
|
||||
virtual bool handleInstruction( unsigned Opcode, const Type* iType,
|
||||
std::vector<unsigned>& Operands, unsigned Size){
|
||||
std::vector<unsigned>& Operands,
|
||||
Instruction *Inst,
|
||||
unsigned Size){
|
||||
if (os) {
|
||||
*os << " INST: OpCode="
|
||||
<< Instruction::getOpcodeName(Opcode) << " Type=\"";
|
||||
WriteTypeSymbolic(*os,iType,M);
|
||||
*os << "\"";
|
||||
<< Instruction::getOpcodeName(Opcode);
|
||||
for ( unsigned i = 0; i < Operands.size(); ++i )
|
||||
*os << " Op(" << i << ")=Slot(" << Operands[i] << ")";
|
||||
*os << "\n";
|
||||
*os << " Op(" << Operands[i] << ")";
|
||||
*os << *Inst;
|
||||
}
|
||||
|
||||
bca.numInstructions++;
|
||||
|
@ -23,7 +23,6 @@
|
||||
#include "llvm/Constants.h"
|
||||
#include "llvm/InlineAsm.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/SymbolTable.h"
|
||||
#include "llvm/TypeSymbolTable.h"
|
||||
#include "llvm/Bytecode/Format.h"
|
||||
#include "llvm/Config/alloca.h"
|
||||
@ -55,6 +54,7 @@ namespace {
|
||||
inline void BytecodeReader::error(const std::string& err) {
|
||||
ErrorMsg = err + " (Vers=" + itostr(RevisionNum) + ", Pos="
|
||||
+ itostr(At-MemStart) + ")";
|
||||
if (Handler) Handler->handleError(ErrorMsg);
|
||||
longjmp(context,1);
|
||||
}
|
||||
|
||||
@ -443,10 +443,6 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
|
||||
// of opcodes.
|
||||
Instruction* Result = 0;
|
||||
|
||||
// We have enough info to inform the handler now.
|
||||
if (Handler)
|
||||
Handler->handleInstruction(Opcode, InstTy, Oprnds, At-SaveAt);
|
||||
|
||||
// First, handle the easy binary operators case
|
||||
if (Opcode >= Instruction::BinaryOpsBegin &&
|
||||
Opcode < Instruction::BinaryOpsEnd && Oprnds.size() == 2) {
|
||||
@ -861,6 +857,10 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
|
||||
else
|
||||
TypeSlot = getTypeSlot(Result->getType());
|
||||
|
||||
// We have enough info to inform the handler now.
|
||||
if (Handler)
|
||||
Handler->handleInstruction(Opcode, InstTy, Oprnds, Result, At-SaveAt);
|
||||
|
||||
insertValue(Result, TypeSlot, FunctionValues);
|
||||
}
|
||||
|
||||
@ -936,9 +936,9 @@ void BytecodeReader::ParseTypeSymbolTable(TypeSymbolTable *TST) {
|
||||
/// CurrentFunction's symbol table. For Module level symbol tables, the
|
||||
/// CurrentFunction argument must be zero.
|
||||
void BytecodeReader::ParseValueSymbolTable(Function *CurrentFunction,
|
||||
SymbolTable *ST) {
|
||||
ValueSymbolTable *VST) {
|
||||
|
||||
if (Handler) Handler->handleSymbolTableBegin(CurrentFunction,ST);
|
||||
if (Handler) Handler->handleValueSymbolTableBegin(CurrentFunction,VST);
|
||||
|
||||
// Allow efficient basic block lookup by number.
|
||||
std::vector<BasicBlock*> BBMap;
|
||||
@ -963,13 +963,15 @@ void BytecodeReader::ParseValueSymbolTable(Function *CurrentFunction,
|
||||
} else {
|
||||
V = getValue(Typ, slot, false); // Find mapping...
|
||||
}
|
||||
if (Handler) Handler->handleSymbolTableValue(Typ, slot, Name);
|
||||
if (V == 0)
|
||||
error("Failed value look-up for name '" + Name + "'");
|
||||
error("Failed value look-up for name '" + Name + "', type #" +
|
||||
utostr(Typ) + " slot #" + utostr(slot));
|
||||
V->setName(Name);
|
||||
}
|
||||
}
|
||||
checkPastBlockEnd("Symbol Table");
|
||||
if (Handler) Handler->handleSymbolTableEnd();
|
||||
if (Handler) Handler->handleValueSymbolTableEnd();
|
||||
}
|
||||
|
||||
// Parse a single type. The typeid is read in first. If its a primitive type
|
||||
|
@ -28,8 +28,10 @@
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class BytecodeHandler; ///< Forward declare the handler interface
|
||||
class TypeSymbolTable; ///< Forward declare
|
||||
// Forward declarations
|
||||
class BytecodeHandler;
|
||||
class TypeSymbolTable;
|
||||
class ValueSymbolTable;
|
||||
|
||||
/// This class defines the interface for parsing a buffer of bytecode. The
|
||||
/// parser itself takes no action except to call the various functions of
|
||||
@ -204,7 +206,7 @@ protected:
|
||||
void ParseTypeSymbolTable(TypeSymbolTable *ST);
|
||||
|
||||
/// @brief Parse a value symbol table
|
||||
void ParseValueSymbolTable(Function* Func, SymbolTable *ST);
|
||||
void ParseValueSymbolTable(Function* Func, ValueSymbolTable *ST);
|
||||
|
||||
/// @brief Parse functions lazily.
|
||||
void ParseFunctionLazily();
|
||||
|
@ -21,9 +21,9 @@
|
||||
#include "llvm/InlineAsm.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/SymbolTable.h"
|
||||
#include "llvm/TypeSymbolTable.h"
|
||||
#include "llvm/Type.h"
|
||||
#include "llvm/ValueSymbolTable.h"
|
||||
#include "llvm/Analysis/ConstantsScanner.h"
|
||||
#include "llvm/ADT/PostOrderIterator.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
@ -218,8 +218,8 @@ void SlotCalculator::processModule() {
|
||||
|
||||
// processTypeSymbolTable - Insert all of the type sin the specified symbol
|
||||
// table.
|
||||
void SlotCalculator::processTypeSymbolTable(const TypeSymbolTable *ST) {
|
||||
for (TypeSymbolTable::const_iterator TI = ST->begin(), TE = ST->end();
|
||||
void SlotCalculator::processTypeSymbolTable(const TypeSymbolTable *TST) {
|
||||
for (TypeSymbolTable::const_iterator TI = TST->begin(), TE = TST->end();
|
||||
TI != TE; ++TI )
|
||||
getOrCreateSlot(TI->second);
|
||||
}
|
||||
@ -227,23 +227,18 @@ void SlotCalculator::processTypeSymbolTable(const TypeSymbolTable *ST) {
|
||||
// processSymbolTable - Insert all of the values in the specified symbol table
|
||||
// into the values table...
|
||||
//
|
||||
void SlotCalculator::processValueSymbolTable(const SymbolTable *ST) {
|
||||
for (SymbolTable::plane_const_iterator PI = ST->plane_begin(),
|
||||
PE = ST->plane_end(); PI != PE; ++PI)
|
||||
for (SymbolTable::value_const_iterator VI = PI->second.begin(),
|
||||
VE = PI->second.end(); VI != VE; ++VI)
|
||||
getOrCreateSlot(VI->second);
|
||||
void SlotCalculator::processValueSymbolTable(const ValueSymbolTable *VST) {
|
||||
for (ValueSymbolTable::const_iterator VI = VST->begin(), VE = VST->end();
|
||||
VI != VE; ++VI)
|
||||
getOrCreateSlot(VI->second);
|
||||
}
|
||||
|
||||
void SlotCalculator::processSymbolTableConstants(const SymbolTable *ST) {
|
||||
void SlotCalculator::processSymbolTableConstants(const ValueSymbolTable *VST) {
|
||||
// Now do the constant values in all planes
|
||||
for (SymbolTable::plane_const_iterator PI = ST->plane_begin(),
|
||||
PE = ST->plane_end(); PI != PE; ++PI)
|
||||
for (SymbolTable::value_const_iterator VI = PI->second.begin(),
|
||||
VE = PI->second.end(); VI != VE; ++VI)
|
||||
if (isa<Constant>(VI->second) &&
|
||||
!isa<GlobalValue>(VI->second))
|
||||
getOrCreateSlot(VI->second);
|
||||
for (ValueSymbolTable::const_iterator VI = VST->begin(), VE = VST->end();
|
||||
VI != VE; ++VI)
|
||||
if (isa<Constant>(VI->second) && !isa<GlobalValue>(VI->second))
|
||||
getOrCreateSlot(VI->second);
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,6 +31,7 @@ class Module;
|
||||
class Function;
|
||||
class SymbolTable;
|
||||
class TypeSymbolTable;
|
||||
class ValueSymbolTable;
|
||||
class ConstantArray;
|
||||
|
||||
class SlotCalculator {
|
||||
@ -130,8 +131,8 @@ private:
|
||||
// into the values table...
|
||||
//
|
||||
void processTypeSymbolTable(const TypeSymbolTable *ST);
|
||||
void processValueSymbolTable(const SymbolTable *ST);
|
||||
void processSymbolTableConstants(const SymbolTable *ST);
|
||||
void processValueSymbolTable(const ValueSymbolTable *ST);
|
||||
void processSymbolTableConstants(const ValueSymbolTable *ST);
|
||||
|
||||
// insertPrimitives - helper for constructors to insert primitive types.
|
||||
void insertPrimitives();
|
||||
|
@ -26,8 +26,8 @@
|
||||
#include "llvm/InlineAsm.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/SymbolTable.h"
|
||||
#include "llvm/TypeSymbolTable.h"
|
||||
#include "llvm/ValueSymbolTable.h"
|
||||
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
||||
#include "llvm/Support/Compressor.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
@ -1144,21 +1144,31 @@ void BytecodeWriter::outputTypeSymbolTable(const TypeSymbolTable &TST) {
|
||||
}
|
||||
}
|
||||
|
||||
void BytecodeWriter::outputValueSymbolTable(const SymbolTable &MST) {
|
||||
void BytecodeWriter::outputValueSymbolTable(const ValueSymbolTable &VST) {
|
||||
// Do not output the Bytecode block for an empty symbol table, it just wastes
|
||||
// space!
|
||||
if (MST.isEmpty()) return;
|
||||
if (VST.empty()) return;
|
||||
|
||||
BytecodeBlock SymTabBlock(BytecodeFormat::ValueSymbolTableBlockID, *this,
|
||||
true/*ElideIfEmpty*/);
|
||||
|
||||
// Now do each of the type planes in order.
|
||||
for (SymbolTable::plane_const_iterator PI = MST.plane_begin(),
|
||||
PE = MST.plane_end(); PI != PE; ++PI) {
|
||||
SymbolTable::value_const_iterator I = MST.value_begin(PI->first);
|
||||
SymbolTable::value_const_iterator End = MST.value_end(PI->first);
|
||||
// Organize the symbol table by type
|
||||
typedef std::pair<std::string, const Value*> PlaneMapEntry;
|
||||
typedef std::vector<PlaneMapEntry> PlaneMapVector;
|
||||
typedef std::map<const Type*, PlaneMapVector > PlaneMap;
|
||||
PlaneMap Planes;
|
||||
for (ValueSymbolTable::const_iterator SI = VST.begin(), SE = VST.end();
|
||||
SI != SE; ++SI)
|
||||
Planes[SI->second->getType()].push_back(
|
||||
std::make_pair(SI->first,SI->second));
|
||||
|
||||
for (PlaneMap::const_iterator PI = Planes.begin(), PE = Planes.end();
|
||||
PI != PE; ++PI) {
|
||||
int Slot;
|
||||
|
||||
PlaneMapVector::const_iterator I = PI->second.begin();
|
||||
PlaneMapVector::const_iterator End = PI->second.end();
|
||||
|
||||
if (I == End) continue; // Don't mess with an absent type...
|
||||
|
||||
// Write the number of values in this plane
|
||||
|
@ -26,6 +26,7 @@
|
||||
namespace llvm {
|
||||
class InlineAsm;
|
||||
class TypeSymbolTable;
|
||||
class ValueSymbolTable;
|
||||
|
||||
class BytecodeWriter {
|
||||
std::vector<unsigned char> &Out;
|
||||
@ -66,7 +67,7 @@ private:
|
||||
|
||||
void outputModuleInfoBlock(const Module *C);
|
||||
void outputTypeSymbolTable(const TypeSymbolTable &TST);
|
||||
void outputValueSymbolTable(const SymbolTable &ST);
|
||||
void outputValueSymbolTable(const ValueSymbolTable &ST);
|
||||
void outputTypes(unsigned StartNo);
|
||||
void outputConstantsInPlane(const std::vector<const Value*> &Plane,
|
||||
unsigned StartNo);
|
||||
|
@ -20,8 +20,8 @@
|
||||
#include "llvm/Constants.h"
|
||||
#include "llvm/DerivedTypes.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/SymbolTable.h"
|
||||
#include "llvm/TypeSymbolTable.h"
|
||||
#include "llvm/ValueSymbolTable.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Assembly/Writer.h"
|
||||
#include "llvm/Support/Streams.h"
|
||||
@ -273,7 +273,8 @@ static void PrintMap(const std::map<const Value*, Value*> &M) {
|
||||
static Value *RemapOperand(const Value *In,
|
||||
std::map<const Value*, Value*> &ValueMap) {
|
||||
std::map<const Value*,Value*>::const_iterator I = ValueMap.find(In);
|
||||
if (I != ValueMap.end()) return I->second;
|
||||
if (I != ValueMap.end())
|
||||
return I->second;
|
||||
|
||||
// Check to see if it's a constant that we are interested in transforming.
|
||||
Value *Result = 0;
|
||||
@ -333,20 +334,34 @@ static Value *RemapOperand(const Value *In,
|
||||
/// through the trouble to force this back.
|
||||
static void ForceRenaming(GlobalValue *GV, const std::string &Name) {
|
||||
assert(GV->getName() != Name && "Can't force rename to self");
|
||||
SymbolTable &ST = GV->getParent()->getValueSymbolTable();
|
||||
ValueSymbolTable &ST = GV->getParent()->getValueSymbolTable();
|
||||
|
||||
// If there is a conflict, rename the conflict.
|
||||
Value *ConflictVal = ST.lookup(GV->getType(), Name);
|
||||
assert(ConflictVal&&"Why do we have to force rename if there is no conflic?");
|
||||
GlobalValue *ConflictGV = cast<GlobalValue>(ConflictVal);
|
||||
assert(ConflictGV->hasInternalLinkage() &&
|
||||
"Not conflicting with a static global, should link instead!");
|
||||
GlobalValue *ConflictGV = cast_or_null<GlobalValue>(ST.lookup(Name));
|
||||
if (ConflictGV) {
|
||||
assert(ConflictGV->hasInternalLinkage() &&
|
||||
"Not conflicting with a static global, should link instead!");
|
||||
ConflictGV->setName(""); // Eliminate the conflict
|
||||
}
|
||||
GV->setName(Name); // Force the name back
|
||||
if (ConflictGV) {
|
||||
ConflictGV->setName(Name); // This will cause ConflictGV to get renamed
|
||||
assert(ConflictGV->getName() != Name && "ForceRenaming didn't work");
|
||||
}
|
||||
assert(GV->getName() == Name && "ForceRenaming didn't work");
|
||||
}
|
||||
|
||||
ConflictGV->setName(""); // Eliminate the conflict
|
||||
GV->setName(Name); // Force the name back
|
||||
ConflictGV->setName(Name); // This will cause ConflictGV to get renamed
|
||||
assert(GV->getName() == Name && ConflictGV->getName() != Name &&
|
||||
"ForceRenaming didn't work");
|
||||
/// CopyGVAttributes - copy additional attributes (those not needed to construct
|
||||
/// a GlobalValue) from the SrcGV to the DestGV.
|
||||
static void CopyGVAttributes(GlobalValue *DestGV, const GlobalValue *SrcGV) {
|
||||
// Propagate alignment, visibility and section info.
|
||||
DestGV->setAlignment(std::max(DestGV->getAlignment(), SrcGV->getAlignment()));
|
||||
DestGV->setSection(SrcGV->getSection());
|
||||
DestGV->setVisibility(SrcGV->getVisibility());
|
||||
if (const Function *SrcF = dyn_cast<Function>(SrcGV)) {
|
||||
Function *DestF = cast<Function>(DestGV);
|
||||
DestF->setCallingConv(SrcF->getCallingConv());
|
||||
}
|
||||
}
|
||||
|
||||
/// GetLinkageResult - This analyzes the two global values and determines what
|
||||
@ -431,29 +446,20 @@ static bool GetLinkageResult(GlobalValue *Dest, GlobalValue *Src,
|
||||
static bool LinkGlobals(Module *Dest, Module *Src,
|
||||
std::map<const Value*, Value*> &ValueMap,
|
||||
std::multimap<std::string, GlobalVariable *> &AppendingVars,
|
||||
std::map<std::string, GlobalValue*> &GlobalsByName,
|
||||
std::string *Err) {
|
||||
// We will need a module level symbol table if the src module has a module
|
||||
// level symbol table...
|
||||
TypeSymbolTable *TST = &Dest->getTypeSymbolTable();
|
||||
|
||||
// Loop over all of the globals in the src module, mapping them over as we go
|
||||
for (Module::global_iterator I = Src->global_begin(), E = Src->global_end();
|
||||
I != E; ++I) {
|
||||
GlobalVariable *SGV = I;
|
||||
GlobalVariable *DGV = 0;
|
||||
// Check to see if may have to link the global.
|
||||
if (SGV->hasName() && !SGV->hasInternalLinkage())
|
||||
if (!(DGV = Dest->getGlobalVariable(SGV->getName(),
|
||||
SGV->getType()->getElementType()))) {
|
||||
std::map<std::string, GlobalValue*>::iterator EGV =
|
||||
GlobalsByName.find(SGV->getName());
|
||||
if (EGV != GlobalsByName.end())
|
||||
DGV = dyn_cast<GlobalVariable>(EGV->second);
|
||||
if (DGV)
|
||||
// If types don't agree due to opaque types, try to resolve them.
|
||||
RecursiveResolveTypes(SGV->getType(), DGV->getType(), TST, "");
|
||||
}
|
||||
if (SGV->hasName() && !SGV->hasInternalLinkage()) {
|
||||
DGV = Dest->getGlobalVariable(SGV->getName());
|
||||
if (DGV && DGV->getType() != SGV->getType())
|
||||
// If types don't agree due to opaque types, try to resolve them.
|
||||
RecursiveResolveTypes(SGV->getType(), DGV->getType(),
|
||||
&Dest->getTypeSymbolTable(), "");
|
||||
}
|
||||
|
||||
if (DGV && DGV->hasInternalLinkage())
|
||||
DGV = 0;
|
||||
@ -476,9 +482,7 @@ static bool LinkGlobals(Module *Dest, Module *Src,
|
||||
SGV->isConstant(), SGV->getLinkage(), /*init*/0,
|
||||
SGV->getName(), Dest);
|
||||
// Propagate alignment, visibility and section info.
|
||||
NewDGV->setAlignment(SGV->getAlignment());
|
||||
NewDGV->setSection(SGV->getSection());
|
||||
NewDGV->setVisibility(SGV->getVisibility());
|
||||
CopyGVAttributes(NewDGV, SGV);
|
||||
|
||||
// If the LLVM runtime renamed the global, but it is an externally visible
|
||||
// symbol, DGV must be an existing global with internal linkage. Rename
|
||||
@ -502,9 +506,8 @@ static bool LinkGlobals(Module *Dest, Module *Src,
|
||||
"", Dest);
|
||||
|
||||
// Propagate alignment, section and visibility info.
|
||||
NewDGV->setAlignment(std::max(DGV->getAlignment(), SGV->getAlignment()));
|
||||
NewDGV->setSection(SGV->getSection());
|
||||
NewDGV->setVisibility(SGV->getVisibility());
|
||||
NewDGV->setAlignment(DGV->getAlignment());
|
||||
CopyGVAttributes(NewDGV, SGV);
|
||||
|
||||
// Make sure to remember this mapping...
|
||||
ValueMap.insert(std::make_pair(SGV, NewDGV));
|
||||
@ -513,9 +516,7 @@ static bool LinkGlobals(Module *Dest, Module *Src,
|
||||
AppendingVars.insert(std::make_pair(SGV->getName(), NewDGV));
|
||||
} else {
|
||||
// Propagate alignment, section, and visibility info.
|
||||
DGV->setAlignment(std::max(DGV->getAlignment(), SGV->getAlignment()));
|
||||
DGV->setSection(SGV->getSection());
|
||||
DGV->setVisibility(SGV->getVisibility());
|
||||
CopyGVAttributes(DGV, SGV);
|
||||
|
||||
// Otherwise, perform the mapping as instructed by GetLinkageResult. If
|
||||
// the types don't match, and if we are to link from the source, nuke DGV
|
||||
@ -524,9 +525,7 @@ static bool LinkGlobals(Module *Dest, Module *Src,
|
||||
GlobalVariable *NewDGV =
|
||||
new GlobalVariable(SGV->getType()->getElementType(),
|
||||
DGV->isConstant(), DGV->getLinkage());
|
||||
NewDGV->setAlignment(DGV->getAlignment());
|
||||
NewDGV->setSection(DGV->getSection());
|
||||
NewDGV->setVisibility(DGV->getVisibility());
|
||||
CopyGVAttributes(NewDGV, DGV);
|
||||
Dest->getGlobalList().insert(DGV, NewDGV);
|
||||
DGV->replaceAllUsesWith(
|
||||
ConstantExpr::getBitCast(NewDGV, DGV->getType()));
|
||||
@ -607,33 +606,64 @@ static bool LinkGlobalInits(Module *Dest, const Module *Src,
|
||||
//
|
||||
static bool LinkFunctionProtos(Module *Dest, const Module *Src,
|
||||
std::map<const Value*, Value*> &ValueMap,
|
||||
std::map<std::string,
|
||||
GlobalValue*> &GlobalsByName,
|
||||
std::string *Err) {
|
||||
TypeSymbolTable *TST = &Dest->getTypeSymbolTable();
|
||||
|
||||
// Loop over all of the functions in the src module, mapping them over
|
||||
for (Module::const_iterator I = Src->begin(), E = Src->end(); I != E; ++I) {
|
||||
const Function *SF = I; // SrcFunction
|
||||
Function *DF = 0;
|
||||
if (SF->hasName() && !SF->hasInternalLinkage()) {
|
||||
// Check to see if may have to link the function.
|
||||
if (!(DF = Dest->getFunction(SF->getName(), SF->getFunctionType()))) {
|
||||
std::map<std::string, GlobalValue*>::iterator EF =
|
||||
GlobalsByName.find(SF->getName());
|
||||
if (EF != GlobalsByName.end())
|
||||
DF = dyn_cast<Function>(EF->second);
|
||||
if (DF && RecursiveResolveTypes(SF->getType(), DF->getType(), TST, ""))
|
||||
DF = 0; // FIXME: gross.
|
||||
}
|
||||
DF = Dest->getFunction(SF->getName());
|
||||
if (DF && SF->getType() != DF->getType())
|
||||
// If types don't agree because of opaque, try to resolve them
|
||||
RecursiveResolveTypes(SF->getType(), DF->getType(),
|
||||
&Dest->getTypeSymbolTable(), "");
|
||||
}
|
||||
|
||||
if (DF && DF->getType() != SF->getType()) {
|
||||
if (DF->isDeclaration() && !SF->isDeclaration()) {
|
||||
// We have a definition of the same name but different type in the
|
||||
// source module. Copy the prototype to the destination and replace
|
||||
// uses of the destination's prototype with the new prototype.
|
||||
Function *NewDF = new Function(SF->getFunctionType(), SF->getLinkage(),
|
||||
SF->getName(), Dest);
|
||||
CopyGVAttributes(NewDF, SF);
|
||||
|
||||
if (!DF || SF->hasInternalLinkage() || DF->hasInternalLinkage()) {
|
||||
// Any uses of DF need to change to NewDF, with cast
|
||||
DF->replaceAllUsesWith(ConstantExpr::getBitCast(NewDF, DF->getType()));
|
||||
|
||||
// DF will conflict with NewDF because they both had the same. We must
|
||||
// erase this now so ForceRenaming doesn't assert because DF might
|
||||
// not have internal linkage.
|
||||
DF->eraseFromParent();
|
||||
|
||||
// If the symbol table renamed the function, but it is an externally
|
||||
// visible symbol, DF must be an existing function with internal
|
||||
// linkage. Rename it.
|
||||
if (NewDF->getName() != SF->getName() && !NewDF->hasInternalLinkage())
|
||||
ForceRenaming(NewDF, SF->getName());
|
||||
|
||||
// Remember this mapping so uses in the source module get remapped
|
||||
// later by RemapOperand.
|
||||
ValueMap[SF] = NewDF;
|
||||
} else if (SF->isDeclaration()) {
|
||||
// We have two functions of the same name but different type and the
|
||||
// source is a declaration while the destination is not. Any use of
|
||||
// the source must be mapped to the destination, with a cast.
|
||||
ValueMap[SF] = ConstantExpr::getBitCast(DF, SF->getType());
|
||||
} else {
|
||||
// We have two functions of the same name but different types and they
|
||||
// are both definitions. This is an error.
|
||||
return Error(Err, "Function '" + DF->getName() + "' defined as both '" +
|
||||
ToStr(SF->getFunctionType(), Src) + "' and '" +
|
||||
ToStr(DF->getFunctionType(), Dest) + "'");
|
||||
}
|
||||
} else if (!DF || SF->hasInternalLinkage() || DF->hasInternalLinkage()) {
|
||||
// Function does not already exist, simply insert an function signature
|
||||
// identical to SF into the dest module...
|
||||
Function *NewDF = new Function(SF->getFunctionType(), SF->getLinkage(),
|
||||
SF->getName(), Dest);
|
||||
NewDF->setCallingConv(SF->getCallingConv());
|
||||
CopyGVAttributes(NewDF, SF);
|
||||
|
||||
// If the LLVM runtime renamed the function, but it is an externally
|
||||
// visible symbol, DF must be an existing function with internal linkage.
|
||||
@ -644,8 +674,8 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src,
|
||||
// ... and remember this mapping...
|
||||
ValueMap.insert(std::make_pair(SF, NewDF));
|
||||
} else if (SF->isDeclaration()) {
|
||||
// If SF is external or if both SF & DF are external.. Just link the
|
||||
// external functions, we aren't adding anything.
|
||||
// If SF is a declaration or if both SF & DF are declarations, just link
|
||||
// the declarations, we aren't adding anything.
|
||||
if (SF->hasDLLImportLinkage()) {
|
||||
if (DF->isDeclaration()) {
|
||||
ValueMap.insert(std::make_pair(SF, DF));
|
||||
@ -668,8 +698,6 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src,
|
||||
if ((DF->hasLinkOnceLinkage() && SF->hasWeakLinkage()) ||
|
||||
DF->hasExternalWeakLinkage())
|
||||
DF->setLinkage(SF->getLinkage());
|
||||
|
||||
|
||||
} else if (DF->hasWeakLinkage() || DF->hasLinkOnceLinkage()) {
|
||||
// At this point we know that SF has LinkOnce or External* linkage.
|
||||
ValueMap.insert(std::make_pair(SF, DF));
|
||||
@ -677,10 +705,10 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src,
|
||||
// Don't inherit linkonce & external weak linkage
|
||||
DF->setLinkage(SF->getLinkage());
|
||||
} else if (SF->getLinkage() != DF->getLinkage()) {
|
||||
return Error(Err, "Functions named '" + SF->getName() +
|
||||
"' have different linkage specifiers!");
|
||||
return Error(Err, "Functions named '" + SF->getName() +
|
||||
"' have different linkage specifiers!");
|
||||
} else if (SF->hasExternalLinkage()) {
|
||||
// The function is defined in both modules!!
|
||||
// The function is defined identically in both modules!!
|
||||
return Error(Err, "Function '" +
|
||||
ToStr(SF->getFunctionType(), Src) + "':\"" +
|
||||
SF->getName() + "\" - Function is already defined!");
|
||||
@ -695,7 +723,7 @@ static bool LinkFunctionProtos(Module *Dest, const Module *Src,
|
||||
// fix up references to values. At this point we know that Dest is an external
|
||||
// function, and that Src is not.
|
||||
static bool LinkFunctionBody(Function *Dest, Function *Src,
|
||||
std::map<const Value*, Value*> &GlobalMap,
|
||||
std::map<const Value*, Value*> &ValueMap,
|
||||
std::string *Err) {
|
||||
assert(Src && Dest && Dest->isDeclaration() && !Src->isDeclaration());
|
||||
|
||||
@ -706,7 +734,7 @@ static bool LinkFunctionBody(Function *Dest, Function *Src,
|
||||
DI->setName(I->getName()); // Copy the name information over...
|
||||
|
||||
// Add a mapping to our local map
|
||||
GlobalMap.insert(std::make_pair(I, DI));
|
||||
ValueMap.insert(std::make_pair(I, DI));
|
||||
}
|
||||
|
||||
// Splice the body of the source function into the dest function.
|
||||
@ -722,12 +750,12 @@ static bool LinkFunctionBody(Function *Dest, Function *Src,
|
||||
for (Instruction::op_iterator OI = I->op_begin(), OE = I->op_end();
|
||||
OI != OE; ++OI)
|
||||
if (!isa<Instruction>(*OI) && !isa<BasicBlock>(*OI))
|
||||
*OI = RemapOperand(*OI, GlobalMap);
|
||||
*OI = RemapOperand(*OI, ValueMap);
|
||||
|
||||
// There is no need to map the arguments anymore.
|
||||
for (Function::arg_iterator I = Src->arg_begin(), E = Src->arg_end();
|
||||
I != E; ++I)
|
||||
GlobalMap.erase(I);
|
||||
ValueMap.erase(I);
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -747,11 +775,10 @@ static bool LinkFunctionBodies(Module *Dest, Module *Src,
|
||||
Function *DF = cast<Function>(ValueMap[SF]); // Destination function
|
||||
|
||||
// DF not external SF external?
|
||||
if (DF->isDeclaration()) {
|
||||
if (DF->isDeclaration())
|
||||
// Only provide the function body if there isn't one already.
|
||||
if (LinkFunctionBody(DF, SF, ValueMap, Err))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
@ -919,32 +946,17 @@ Linker::LinkModules(Module *Dest, Module *Src, std::string *ErrorMsg) {
|
||||
// with appending linkage. After the module is linked together, they are
|
||||
// appended and the module is rewritten.
|
||||
std::multimap<std::string, GlobalVariable *> AppendingVars;
|
||||
|
||||
// GlobalsByName - The LLVM SymbolTable class fights our best efforts at
|
||||
// linking by separating globals by type. Until PR411 is fixed, we replicate
|
||||
// it's functionality here.
|
||||
std::map<std::string, GlobalValue*> GlobalsByName;
|
||||
|
||||
for (Module::global_iterator I = Dest->global_begin(), E = Dest->global_end();
|
||||
I != E; ++I) {
|
||||
// Add all of the appending globals already in the Dest module to
|
||||
// AppendingVars.
|
||||
if (I->hasAppendingLinkage())
|
||||
AppendingVars.insert(std::make_pair(I->getName(), I));
|
||||
|
||||
// Keep track of all globals by name.
|
||||
if (!I->hasInternalLinkage() && I->hasName())
|
||||
GlobalsByName[I->getName()] = I;
|
||||
}
|
||||
|
||||
// Keep track of all globals by name.
|
||||
for (Module::iterator I = Dest->begin(), E = Dest->end(); I != E; ++I)
|
||||
if (!I->hasInternalLinkage() && I->hasName())
|
||||
GlobalsByName[I->getName()] = I;
|
||||
|
||||
// Insert all of the globals in src into the Dest module... without linking
|
||||
// initializers (which could refer to functions not yet mapped over).
|
||||
if (LinkGlobals(Dest, Src, ValueMap, AppendingVars, GlobalsByName, ErrorMsg))
|
||||
if (LinkGlobals(Dest, Src, ValueMap, AppendingVars, ErrorMsg))
|
||||
return true;
|
||||
|
||||
// Link the functions together between the two modules, without doing function
|
||||
@ -952,7 +964,7 @@ Linker::LinkModules(Module *Dest, Module *Src, std::string *ErrorMsg) {
|
||||
// function... We do this so that when we begin processing function bodies,
|
||||
// all of the global values that may be referenced are available in our
|
||||
// ValueMap.
|
||||
if (LinkFunctionProtos(Dest, Src, ValueMap, GlobalsByName, ErrorMsg))
|
||||
if (LinkFunctionProtos(Dest, Src, ValueMap, ErrorMsg))
|
||||
return true;
|
||||
|
||||
// Update the initializers in the Dest module now that all globals that may
|
||||
|
@ -20,7 +20,6 @@
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/PassManager.h"
|
||||
#include "llvm/SymbolTable.h"
|
||||
#include "llvm/TypeSymbolTable.h"
|
||||
#include "llvm/Intrinsics.h"
|
||||
#include "llvm/IntrinsicInst.h"
|
||||
|
@ -167,7 +167,8 @@ bool BlockExtractorPass::runOnModule(Module &M) {
|
||||
Function *F = BB->getParent();
|
||||
|
||||
// Map the corresponding function in this module.
|
||||
Function *MF = M.getFunction(F->getName(), F->getFunctionType());
|
||||
Function *MF = M.getFunction(F->getName());
|
||||
assert(MF->getFunctionType() == F->getFunctionType() && "Wrong function?");
|
||||
|
||||
// Figure out which index the basic block is in its function.
|
||||
Function::iterator BBI = MF->begin();
|
||||
|
@ -65,47 +65,65 @@ ModulePass *llvm::createRaiseAllocationsPass() {
|
||||
// function into the appropriate instruction.
|
||||
//
|
||||
void RaiseAllocations::doInitialization(Module &M) {
|
||||
const FunctionType *MallocType = // Get the type for malloc
|
||||
FunctionType::get(PointerType::get(Type::Int8Ty),
|
||||
std::vector<const Type*>(1, Type::Int64Ty), false);
|
||||
|
||||
const FunctionType *FreeType = // Get the type for free
|
||||
FunctionType::get(Type::VoidTy,
|
||||
std::vector<const Type*>(1, PointerType::get(Type::Int8Ty)),
|
||||
false);
|
||||
|
||||
// Get Malloc and free prototypes if they exist!
|
||||
MallocFunc = M.getFunction("malloc", MallocType);
|
||||
FreeFunc = M.getFunction("free" , FreeType);
|
||||
MallocFunc = M.getFunction("malloc");
|
||||
if (MallocFunc) {
|
||||
const FunctionType* TyWeHave = MallocFunc->getFunctionType();
|
||||
|
||||
// Check to see if the prototype is wrong, giving us sbyte*(uint) * malloc
|
||||
// This handles the common declaration of: 'void *malloc(unsigned);'
|
||||
if (MallocFunc == 0) {
|
||||
MallocType = FunctionType::get(PointerType::get(Type::Int8Ty),
|
||||
std::vector<const Type*>(1, Type::Int32Ty), false);
|
||||
MallocFunc = M.getFunction("malloc", MallocType);
|
||||
// Get the expected prototype for malloc
|
||||
const FunctionType *Malloc1Type =
|
||||
FunctionType::get(PointerType::get(Type::Int8Ty),
|
||||
std::vector<const Type*>(1, Type::Int64Ty), false);
|
||||
|
||||
// Chck to see if we got the expected malloc
|
||||
if (TyWeHave != Malloc1Type) {
|
||||
// Check to see if the prototype is wrong, giving us sbyte*(uint) * malloc
|
||||
// This handles the common declaration of: 'void *malloc(unsigned);'
|
||||
const FunctionType *Malloc2Type =
|
||||
FunctionType::get(PointerType::get(Type::Int8Ty),
|
||||
std::vector<const Type*>(1, Type::Int32Ty), false);
|
||||
if (TyWeHave != Malloc2Type) {
|
||||
// Check to see if the prototype is missing, giving us
|
||||
// sbyte*(...) * malloc
|
||||
// This handles the common declaration of: 'void *malloc();'
|
||||
const FunctionType *Malloc3Type =
|
||||
FunctionType::get(PointerType::get(Type::Int8Ty),
|
||||
std::vector<const Type*>(), true);
|
||||
if (TyWeHave != Malloc3Type)
|
||||
// Give up
|
||||
MallocFunc = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check to see if the prototype is missing, giving us sbyte*(...) * malloc
|
||||
// This handles the common declaration of: 'void *malloc();'
|
||||
if (MallocFunc == 0) {
|
||||
MallocType = FunctionType::get(PointerType::get(Type::Int8Ty),
|
||||
std::vector<const Type*>(), true);
|
||||
MallocFunc = M.getFunction("malloc", MallocType);
|
||||
}
|
||||
FreeFunc = M.getFunction("free");
|
||||
if (FreeFunc) {
|
||||
const FunctionType* TyWeHave = FreeFunc->getFunctionType();
|
||||
|
||||
// Get the expected prototype for void free(i8*)
|
||||
const FunctionType *Free1Type = FunctionType::get(Type::VoidTy,
|
||||
std::vector<const Type*>(1, PointerType::get(Type::Int8Ty)), false);
|
||||
|
||||
// Check to see if the prototype was forgotten, giving us void (...) * free
|
||||
// This handles the common forward declaration of: 'void free();'
|
||||
if (FreeFunc == 0) {
|
||||
FreeType = FunctionType::get(Type::VoidTy, std::vector<const Type*>(),true);
|
||||
FreeFunc = M.getFunction("free", FreeType);
|
||||
}
|
||||
if (TyWeHave != Free1Type) {
|
||||
// Check to see if the prototype was forgotten, giving us
|
||||
// void (...) * free
|
||||
// This handles the common forward declaration of: 'void free();'
|
||||
const FunctionType* Free2Type = FunctionType::get(Type::VoidTy,
|
||||
std::vector<const Type*>(),true);
|
||||
|
||||
// One last try, check to see if we can find free as 'int (...)* free'. This
|
||||
// handles the case where NOTHING was declared.
|
||||
if (FreeFunc == 0) {
|
||||
FreeType = FunctionType::get(Type::Int32Ty, std::vector<const Type*>(),true);
|
||||
FreeFunc = M.getFunction("free", FreeType);
|
||||
if (TyWeHave != Free2Type) {
|
||||
// One last try, check to see if we can find free as
|
||||
// int (...)* free. This handles the case where NOTHING was declared.
|
||||
const FunctionType* Free3Type = FunctionType::get(Type::Int32Ty,
|
||||
std::vector<const Type*>(),true);
|
||||
|
||||
if (TyWeHave != Free3Type) {
|
||||
// Give up.
|
||||
FreeFunc = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Don't mess with locally defined versions of these functions...
|
||||
|
@ -28,7 +28,7 @@
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/SymbolTable.h"
|
||||
#include "llvm/ValueSymbolTable.h"
|
||||
#include "llvm/TypeSymbolTable.h"
|
||||
using namespace llvm;
|
||||
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "llvm/Transforms/Utils/Cloning.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/DerivedTypes.h"
|
||||
#include "llvm/SymbolTable.h"
|
||||
#include "llvm/TypeSymbolTable.h"
|
||||
#include "llvm/Constant.h"
|
||||
#include "ValueMapper.h"
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include "llvm/Instruction.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/SymbolTable.h"
|
||||
#include "llvm/ValueSymbolTable.h"
|
||||
#include "llvm/TypeSymbolTable.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
|
@ -16,7 +16,6 @@
|
||||
#include "llvm/DerivedTypes.h"
|
||||
#include "llvm/GlobalValue.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/SymbolTable.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
@ -24,6 +23,7 @@
|
||||
#include "llvm/Support/ManagedStatic.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
#include <algorithm>
|
||||
#include <map>
|
||||
using namespace llvm;
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -7,8 +7,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements the Function & GlobalVariable classes for the VMCore
|
||||
// library.
|
||||
// This file implements the Function class for the VMCore library.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
@ -82,7 +81,7 @@ Function::Function(const FunctionType *Ty, LinkageTypes Linkage,
|
||||
BasicBlocks.setParent(this);
|
||||
ArgumentList.setItemParent(this);
|
||||
ArgumentList.setParent(this);
|
||||
SymTab = new SymbolTable();
|
||||
SymTab = new ValueSymbolTable();
|
||||
|
||||
assert((getReturnType()->isFirstClassType() ||getReturnType() == Type::VoidTy)
|
||||
&& "LLVM functions cannot return aggregate values!");
|
||||
@ -138,7 +137,6 @@ void Function::eraseFromParent() {
|
||||
getParent()->getFunctionList().erase(this);
|
||||
}
|
||||
|
||||
|
||||
// dropAllReferences() - This function causes all the subinstructions to "let
|
||||
// go" of all references that they are maintaining. This allows one to
|
||||
// 'delete' a whole class at a time, even though there may be circular
|
||||
|
@ -15,7 +15,6 @@
|
||||
#include "llvm/GlobalVariable.h"
|
||||
#include "llvm/DerivedTypes.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/SymbolTable.h"
|
||||
#include "llvm/Support/LeakDetector.h"
|
||||
using namespace llvm;
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
#include "llvm/Type.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Function.h"
|
||||
#include "llvm/SymbolTable.h"
|
||||
#include "llvm/Support/LeakDetector.h"
|
||||
using namespace llvm;
|
||||
|
||||
|
@ -69,7 +69,7 @@ Module::Module(const std::string &MID)
|
||||
FunctionList.setParent(this);
|
||||
GlobalList.setItemParent(this);
|
||||
GlobalList.setParent(this);
|
||||
ValSymTab = new SymbolTable();
|
||||
ValSymTab = new ValueSymbolTable();
|
||||
TypeSymTab = new TypeSymbolTable();
|
||||
}
|
||||
|
||||
@ -132,15 +132,19 @@ Module::PointerSize Module::getPointerSize() const {
|
||||
// Methods for easy access to the functions in the module.
|
||||
//
|
||||
|
||||
// getOrInsertFunction - Look up the specified function in the module symbol
|
||||
// table. If it does not exist, add a prototype for the function and return
|
||||
// it. This is nice because it allows most passes to get away with not handling
|
||||
// the symbol table directly for this common task.
|
||||
//
|
||||
Constant *Module::getOrInsertFunction(const std::string &Name,
|
||||
const FunctionType *Ty) {
|
||||
SymbolTable &SymTab = getValueSymbolTable();
|
||||
ValueSymbolTable &SymTab = getValueSymbolTable();
|
||||
|
||||
// See if we have a definitions for the specified function already.
|
||||
Function *F =
|
||||
dyn_cast_or_null<Function>(SymTab.lookup(PointerType::get(Ty), Name));
|
||||
// See if we have a definition for the specified function already.
|
||||
Function *F = dyn_cast_or_null<Function>(SymTab.lookup(Name));
|
||||
if (F == 0) {
|
||||
// Nope, add it.
|
||||
// Nope, add it
|
||||
Function *New = new Function(Ty, GlobalVariable::ExternalLinkage, Name);
|
||||
FunctionList.push_back(New);
|
||||
return New; // Return the new prototype.
|
||||
@ -149,7 +153,7 @@ Constant *Module::getOrInsertFunction(const std::string &Name,
|
||||
// Okay, the function exists. Does it have externally visible linkage?
|
||||
if (F->hasInternalLinkage()) {
|
||||
// Rename the function.
|
||||
F->setName(SymTab.getUniqueName(F->getType(), F->getName()));
|
||||
F->setName(SymTab.getUniqueName(F->getName()));
|
||||
// Retry, now there won't be a conflict.
|
||||
return getOrInsertFunction(Name, Ty);
|
||||
}
|
||||
@ -188,73 +192,9 @@ Constant *Module::getOrInsertFunction(const std::string &Name,
|
||||
// getFunction - Look up the specified function in the module symbol table.
|
||||
// If it does not exist, return null.
|
||||
//
|
||||
Function *Module::getFunction(const std::string &Name, const FunctionType *Ty) {
|
||||
SymbolTable &SymTab = getValueSymbolTable();
|
||||
return cast_or_null<Function>(SymTab.lookup(PointerType::get(Ty), Name));
|
||||
}
|
||||
|
||||
|
||||
/// getMainFunction - This function looks up main efficiently. This is such a
|
||||
/// common case, that it is a method in Module. If main cannot be found, a
|
||||
/// null pointer is returned.
|
||||
///
|
||||
Function *Module::getMainFunction() {
|
||||
std::vector<const Type*> Params;
|
||||
|
||||
// int main(void)...
|
||||
if (Function *F = getFunction("main", FunctionType::get(Type::Int32Ty,
|
||||
Params, false)))
|
||||
return F;
|
||||
|
||||
// void main(void)...
|
||||
if (Function *F = getFunction("main", FunctionType::get(Type::VoidTy,
|
||||
Params, false)))
|
||||
return F;
|
||||
|
||||
Params.push_back(Type::Int32Ty);
|
||||
|
||||
// int main(int argc)...
|
||||
if (Function *F = getFunction("main", FunctionType::get(Type::Int32Ty,
|
||||
Params, false)))
|
||||
return F;
|
||||
|
||||
// void main(int argc)...
|
||||
if (Function *F = getFunction("main", FunctionType::get(Type::VoidTy,
|
||||
Params, false)))
|
||||
return F;
|
||||
|
||||
for (unsigned i = 0; i != 2; ++i) { // Check argv and envp
|
||||
Params.push_back(PointerType::get(PointerType::get(Type::Int8Ty)));
|
||||
|
||||
// int main(int argc, char **argv)...
|
||||
if (Function *F = getFunction("main", FunctionType::get(Type::Int32Ty,
|
||||
Params, false)))
|
||||
return F;
|
||||
|
||||
// void main(int argc, char **argv)...
|
||||
if (Function *F = getFunction("main", FunctionType::get(Type::VoidTy,
|
||||
Params, false)))
|
||||
return F;
|
||||
}
|
||||
|
||||
// Ok, try to find main the hard way...
|
||||
return getNamedFunction("main");
|
||||
}
|
||||
|
||||
/// getNamedFunction - Return the first function in the module with the
|
||||
/// specified name, of arbitrary type. This method returns null if a function
|
||||
/// with the specified name is not found.
|
||||
///
|
||||
Function *Module::getNamedFunction(const std::string &Name) const {
|
||||
// Loop over all of the functions, looking for the function desired
|
||||
const Function *Found = 0;
|
||||
for (const_iterator I = begin(), E = end(); I != E; ++I)
|
||||
if (I->getName() == Name)
|
||||
if (I->isDeclaration())
|
||||
Found = I;
|
||||
else
|
||||
return const_cast<Function*>(&(*I));
|
||||
return const_cast<Function*>(Found); // Non-external function not found...
|
||||
Function *Module::getFunction(const std::string &Name) const {
|
||||
const ValueSymbolTable &SymTab = getValueSymbolTable();
|
||||
return dyn_cast_or_null<Function>(SymTab.lookup(Name));
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
@ -269,31 +209,15 @@ Function *Module::getNamedFunction(const std::string &Name) const {
|
||||
/// have InternalLinkage. By default, these types are not returned.
|
||||
///
|
||||
GlobalVariable *Module::getGlobalVariable(const std::string &Name,
|
||||
const Type *Ty, bool AllowInternal) {
|
||||
if (Value *V = getValueSymbolTable().lookup(PointerType::get(Ty), Name)) {
|
||||
GlobalVariable *Result = cast<GlobalVariable>(V);
|
||||
if (AllowInternal || !Result->hasInternalLinkage())
|
||||
bool AllowInternal) const {
|
||||
if (Value *V = ValSymTab->lookup(Name)) {
|
||||
GlobalVariable *Result = dyn_cast<GlobalVariable>(V);
|
||||
if (Result && (AllowInternal || !Result->hasInternalLinkage()))
|
||||
return Result;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// getNamedGlobal - Return the first global variable in the module with the
|
||||
/// specified name, of arbitrary type. This method returns null if a global
|
||||
/// with the specified name is not found.
|
||||
///
|
||||
GlobalVariable *Module::getNamedGlobal(const std::string &Name) const {
|
||||
// FIXME: This would be much faster with a symbol table that doesn't
|
||||
// discriminate based on type!
|
||||
for (const_global_iterator I = global_begin(), E = global_end();
|
||||
I != E; ++I)
|
||||
if (I->getName() == Name)
|
||||
return const_cast<GlobalVariable*>(&(*I));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Methods for easy access to the types in the module.
|
||||
//
|
||||
|
@ -1,336 +0,0 @@
|
||||
//===-- SymbolTable.cpp - Implement the SymbolTable class -----------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
// This file was developed by the LLVM research group and revised by Reid
|
||||
// Spencer. It is distributed under the University of Illinois Open Source
|
||||
// License. See LICENSE.TXT for details.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// This file implements the SymbolTable class for the VMCore library.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#include "llvm/SymbolTable.h"
|
||||
#include "llvm/DerivedTypes.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include <algorithm>
|
||||
using namespace llvm;
|
||||
|
||||
#define DEBUG_SYMBOL_TABLE 0
|
||||
#define DEBUG_ABSTYPE 0
|
||||
|
||||
SymbolTable::~SymbolTable() {
|
||||
// TODO: FIXME: BIG ONE: This doesn't unreference abstract types for the
|
||||
// planes that could still have entries!
|
||||
|
||||
#ifndef NDEBUG // Only do this in -g mode...
|
||||
bool LeftoverValues = true;
|
||||
for (plane_iterator PI = pmap.begin(); PI != pmap.end(); ++PI) {
|
||||
for (value_iterator VI = PI->second.begin(); VI != PI->second.end(); ++VI)
|
||||
if (!isa<Constant>(VI->second) ) {
|
||||
DOUT << "Value still in symbol table! Type = '"
|
||||
<< PI->first->getDescription() << "' Name = '"
|
||||
<< VI->first << "'\n";
|
||||
LeftoverValues = false;
|
||||
}
|
||||
}
|
||||
|
||||
assert(LeftoverValues && "Values remain in symbol table!");
|
||||
#endif
|
||||
}
|
||||
|
||||
// getUniqueName - Given a base name, return a string that is either equal to
|
||||
// it (or derived from it) that does not already occur in the symbol table for
|
||||
// the specified type.
|
||||
//
|
||||
std::string SymbolTable::getUniqueName(const Type *Ty,
|
||||
const std::string &BaseName) const {
|
||||
// Find the plane
|
||||
plane_const_iterator PI = pmap.find(Ty);
|
||||
if (PI == pmap.end()) return BaseName;
|
||||
|
||||
std::string TryName = BaseName;
|
||||
const ValueMap& vmap = PI->second;
|
||||
value_const_iterator End = vmap.end();
|
||||
|
||||
// See if the name exists
|
||||
while (vmap.find(TryName) != End) // Loop until we find a free
|
||||
TryName = BaseName + utostr(++LastUnique); // name in the symbol table
|
||||
return TryName;
|
||||
}
|
||||
|
||||
|
||||
// lookup a value - Returns null on failure...
|
||||
Value *SymbolTable::lookup(const Type *Ty, const std::string &Name) const {
|
||||
plane_const_iterator PI = pmap.find(Ty);
|
||||
if (PI != pmap.end()) { // We have symbols in that plane.
|
||||
value_const_iterator VI = PI->second.find(Name);
|
||||
if (VI != PI->second.end()) // and the name is in our hash table.
|
||||
return VI->second;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/// changeName - Given a value with a non-empty name, remove its existing entry
|
||||
/// from the symbol table and insert a new one for Name. This is equivalent to
|
||||
/// doing "remove(V), V->Name = Name, insert(V)", but is faster, and will not
|
||||
/// temporarily remove the symbol table plane if V is the last value in the
|
||||
/// symtab with that name (which could invalidate iterators to that plane).
|
||||
void SymbolTable::changeName(Value *V, const std::string &name) {
|
||||
assert(!V->getName().empty() && !name.empty() && V->getName() != name &&
|
||||
"Illegal use of this method!");
|
||||
|
||||
plane_iterator PI = pmap.find(V->getType());
|
||||
assert(PI != pmap.end() && "Value doesn't have an entry in this table?");
|
||||
ValueMap &VM = PI->second;
|
||||
|
||||
value_iterator VI = VM.find(V->getName());
|
||||
assert(VI != VM.end() && "Value does have an entry in this table?");
|
||||
|
||||
// Remove the old entry.
|
||||
VM.erase(VI);
|
||||
|
||||
// See if we can insert the new name.
|
||||
VI = VM.lower_bound(name);
|
||||
|
||||
// Is there a naming conflict?
|
||||
if (VI != VM.end() && VI->first == name) {
|
||||
V->Name = getUniqueName(V->getType(), name);
|
||||
VM.insert(make_pair(V->Name, V));
|
||||
} else {
|
||||
V->Name = name;
|
||||
VM.insert(VI, make_pair(name, V));
|
||||
}
|
||||
}
|
||||
|
||||
// Remove a value
|
||||
void SymbolTable::remove(Value *N) {
|
||||
assert(N->hasName() && "Value doesn't have name!");
|
||||
|
||||
plane_iterator PI = pmap.find(N->getType());
|
||||
assert(PI != pmap.end() &&
|
||||
"Trying to remove a value that doesn't have a type plane yet!");
|
||||
ValueMap &VM = PI->second;
|
||||
value_iterator Entry = VM.find(N->getName());
|
||||
assert(Entry != VM.end() && "Invalid entry to remove!");
|
||||
|
||||
#if DEBUG_SYMBOL_TABLE
|
||||
dump();
|
||||
DOUT << " Removing Value: " << Entry->second->getName() << "\n";
|
||||
#endif
|
||||
|
||||
// Remove the value from the plane...
|
||||
VM.erase(Entry);
|
||||
|
||||
// If the plane is empty, remove it now!
|
||||
if (VM.empty()) {
|
||||
// If the plane represented an abstract type that we were interested in,
|
||||
// unlink ourselves from this plane.
|
||||
//
|
||||
if (N->getType()->isAbstract()) {
|
||||
#if DEBUG_ABSTYPE
|
||||
DOUT << "Plane Empty: Removing type: "
|
||||
<< N->getType()->getDescription() << "\n";
|
||||
#endif
|
||||
cast<DerivedType>(N->getType())->removeAbstractTypeUser(this);
|
||||
}
|
||||
|
||||
pmap.erase(PI);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// insertEntry - Insert a value into the symbol table with the specified name.
|
||||
void SymbolTable::insertEntry(const std::string &Name, const Type *VTy,
|
||||
Value *V) {
|
||||
plane_iterator PI = pmap.find(VTy); // Plane iterator
|
||||
value_iterator VI; // Actual value iterator
|
||||
ValueMap *VM; // The plane we care about.
|
||||
|
||||
#if DEBUG_SYMBOL_TABLE
|
||||
dump();
|
||||
DOUT << " Inserting definition: " << Name << ": "
|
||||
<< VTy->getDescription() << "\n";
|
||||
#endif
|
||||
|
||||
if (PI == pmap.end()) { // Not in collection yet... insert dummy entry
|
||||
// Insert a new empty element. I points to the new elements.
|
||||
VM = &pmap.insert(make_pair(VTy, ValueMap())).first->second;
|
||||
VI = VM->end();
|
||||
|
||||
// Check to see if the type is abstract. If so, it might be refined in the
|
||||
// future, which would cause the plane of the old type to get merged into
|
||||
// a new type plane.
|
||||
//
|
||||
if (VTy->isAbstract()) {
|
||||
cast<DerivedType>(VTy)->addAbstractTypeUser(this);
|
||||
#if DEBUG_ABSTYPE
|
||||
DOUT << "Added abstract type value: " << VTy->getDescription()
|
||||
<< "\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
} else {
|
||||
// Check to see if there is a naming conflict. If so, rename this value!
|
||||
VM = &PI->second;
|
||||
VI = VM->lower_bound(Name);
|
||||
if (VI != VM->end() && VI->first == Name) {
|
||||
V->Name = getUniqueName(VTy, Name);
|
||||
VM->insert(make_pair(V->Name, V));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
VM->insert(VI, make_pair(Name, V));
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Strip the symbol table of its names.
|
||||
bool SymbolTable::strip() {
|
||||
bool RemovedSymbol = false;
|
||||
for (plane_iterator I = pmap.begin(); I != pmap.end();) {
|
||||
// Removing items from the plane can cause the plane itself to get deleted.
|
||||
// If this happens, make sure we incremented our plane iterator already!
|
||||
ValueMap &Plane = (I++)->second;
|
||||
value_iterator B = Plane.begin(), Bend = Plane.end();
|
||||
while (B != Bend) { // Found nonempty type plane!
|
||||
Value *V = B->second;
|
||||
++B;
|
||||
if (!isa<GlobalValue>(V) || cast<GlobalValue>(V)->hasInternalLinkage()) {
|
||||
// Set name to "", removing from symbol table!
|
||||
V->setName("");
|
||||
RemovedSymbol = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return RemovedSymbol;
|
||||
}
|
||||
|
||||
|
||||
// This function is called when one of the types in the type plane are refined
|
||||
void SymbolTable::refineAbstractType(const DerivedType *OldType,
|
||||
const Type *NewType) {
|
||||
|
||||
// Search to see if we have any values of the type Oldtype. If so, we need to
|
||||
// move them into the newtype plane...
|
||||
plane_iterator PI = pmap.find(OldType);
|
||||
if (PI != pmap.end()) {
|
||||
// Get a handle to the new type plane...
|
||||
plane_iterator NewTypeIt = pmap.find(NewType);
|
||||
if (NewTypeIt == pmap.end()) { // If no plane exists, add one
|
||||
NewTypeIt = pmap.insert(make_pair(NewType, ValueMap())).first;
|
||||
|
||||
if (NewType->isAbstract()) {
|
||||
cast<DerivedType>(NewType)->addAbstractTypeUser(this);
|
||||
#if DEBUG_ABSTYPE
|
||||
DOUT << "[Added] refined to abstype: " << NewType->getDescription()
|
||||
<< "\n";
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
ValueMap &NewPlane = NewTypeIt->second;
|
||||
ValueMap &OldPlane = PI->second;
|
||||
while (!OldPlane.empty()) {
|
||||
std::pair<const std::string, Value*> V = *OldPlane.begin();
|
||||
|
||||
// Check to see if there is already a value in the symbol table that this
|
||||
// would collide with.
|
||||
value_iterator VI = NewPlane.find(V.first);
|
||||
if (VI != NewPlane.end() && VI->second == V.second) {
|
||||
// No action
|
||||
|
||||
} else if (VI != NewPlane.end()) {
|
||||
// The only thing we are allowing for now is two external global values
|
||||
// folded into one.
|
||||
//
|
||||
GlobalValue *ExistGV = dyn_cast<GlobalValue>(VI->second);
|
||||
GlobalValue *NewGV = dyn_cast<GlobalValue>(V.second);
|
||||
|
||||
if (ExistGV && NewGV) {
|
||||
assert((ExistGV->isDeclaration() || NewGV->isDeclaration()) &&
|
||||
"Two planes folded together with overlapping value names!");
|
||||
|
||||
// Make sure that ExistGV is the one we want to keep!
|
||||
if (!NewGV->isDeclaration())
|
||||
std::swap(NewGV, ExistGV);
|
||||
|
||||
// Ok we have two external global values. Make all uses of the new
|
||||
// one use the old one...
|
||||
NewGV->uncheckedReplaceAllUsesWith(ExistGV);
|
||||
|
||||
// Update NewGV's name, we're about the remove it from the symbol
|
||||
// table.
|
||||
NewGV->Name = "";
|
||||
|
||||
// Now we can remove this global from the module entirely...
|
||||
Module *M = NewGV->getParent();
|
||||
if (Function *F = dyn_cast<Function>(NewGV))
|
||||
M->getFunctionList().remove(F);
|
||||
else
|
||||
M->getGlobalList().remove(cast<GlobalVariable>(NewGV));
|
||||
delete NewGV;
|
||||
} else {
|
||||
// If they are not global values, they must be just random values who
|
||||
// happen to conflict now that types have been resolved. If this is
|
||||
// the case, reinsert the value into the new plane, allowing it to get
|
||||
// renamed.
|
||||
assert(V.second->getType() == NewType &&"Type resolution is broken!");
|
||||
insert(V.second);
|
||||
}
|
||||
} else {
|
||||
insertEntry(V.first, NewType, V.second);
|
||||
}
|
||||
// Remove the item from the old type plane
|
||||
OldPlane.erase(OldPlane.begin());
|
||||
}
|
||||
|
||||
// Ok, now we are not referencing the type anymore... take me off your user
|
||||
// list please!
|
||||
#if DEBUG_ABSTYPE
|
||||
DOUT << "Removing type " << OldType->getDescription() << "\n";
|
||||
#endif
|
||||
OldType->removeAbstractTypeUser(this);
|
||||
|
||||
// Remove the plane that is no longer used
|
||||
pmap.erase(PI);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Handle situation where type becomes Concreate from Abstract
|
||||
void SymbolTable::typeBecameConcrete(const DerivedType *AbsTy) {
|
||||
plane_iterator PI = pmap.find(AbsTy);
|
||||
|
||||
// If there are any values in the symbol table of this type, then the type
|
||||
// plane is a use of the abstract type which must be dropped.
|
||||
if (PI != pmap.end())
|
||||
AbsTy->removeAbstractTypeUser(this);
|
||||
}
|
||||
|
||||
static void DumpVal(const std::pair<const std::string, Value *> &V) {
|
||||
DOUT << " '" << V.first << "' = ";
|
||||
V.second->dump();
|
||||
DOUT << "\n";
|
||||
}
|
||||
|
||||
static void DumpPlane(const std::pair<const Type *,
|
||||
std::map<const std::string, Value *> >&P){
|
||||
P.first->dump();
|
||||
DOUT << "\n";
|
||||
for_each(P.second.begin(), P.second.end(), DumpVal);
|
||||
}
|
||||
|
||||
void SymbolTable::dump() const {
|
||||
DOUT << "Symbol table dump:\n Plane:";
|
||||
for_each(pmap.begin(), pmap.end(), DumpPlane);
|
||||
}
|
||||
|
||||
// vim: sw=2 ai
|
@ -17,7 +17,7 @@
|
||||
#define LLVM_SYMBOLTABLELISTTRAITS_IMPL_H
|
||||
|
||||
#include "llvm/SymbolTableListTraits.h"
|
||||
#include "llvm/SymbolTable.h"
|
||||
#include "llvm/ValueSymbolTable.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
@ -29,7 +29,7 @@ void SymbolTableListTraits<ValueSubClass,ItemParentClass,SymTabClass,SubClass>
|
||||
|
||||
// Remove all of the items from the old symtab..
|
||||
if (SymTabObject && !List.empty()) {
|
||||
SymbolTable &SymTab = SymTabObject->getValueSymbolTable();
|
||||
ValueSymbolTable &SymTab = SymTabObject->getValueSymbolTable();
|
||||
for (typename iplist<ValueSubClass>::iterator I = List.begin();
|
||||
I != List.end(); ++I)
|
||||
if (I->hasName()) SymTab.remove(I);
|
||||
@ -39,7 +39,7 @@ void SymbolTableListTraits<ValueSubClass,ItemParentClass,SymTabClass,SubClass>
|
||||
|
||||
// Add all of the items to the new symtab...
|
||||
if (SymTabObject && !List.empty()) {
|
||||
SymbolTable &SymTab = SymTabObject->getValueSymbolTable();
|
||||
ValueSymbolTable &SymTab = SymTabObject->getValueSymbolTable();
|
||||
for (typename iplist<ValueSubClass>::iterator I = List.begin();
|
||||
I != List.end(); ++I)
|
||||
if (I->hasName()) SymTab.insert(I);
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
#include "llvm/AbstractTypeUser.h"
|
||||
#include "llvm/DerivedTypes.h"
|
||||
#include "llvm/SymbolTable.h"
|
||||
#include "llvm/Constants.h"
|
||||
#include "llvm/ADT/DepthFirstIterator.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
|
@ -15,7 +15,7 @@
|
||||
#include "llvm/DerivedTypes.h"
|
||||
#include "llvm/InstrTypes.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/SymbolTable.h"
|
||||
#include "llvm/ValueSymbolTable.h"
|
||||
#include "llvm/Support/Debug.h"
|
||||
#include "llvm/Support/LeakDetector.h"
|
||||
#include <algorithm>
|
||||
@ -97,17 +97,20 @@ void Value::setName(const std::string &name) {
|
||||
if (Name == name) return; // Name is already set.
|
||||
|
||||
// Get the symbol table to update for this object.
|
||||
SymbolTable *ST = 0;
|
||||
ValueSymbolTable *ST = 0;
|
||||
if (Instruction *I = dyn_cast<Instruction>(this)) {
|
||||
if (BasicBlock *P = I->getParent())
|
||||
if (Function *PP = P->getParent())
|
||||
ST = &PP->getValueSymbolTable();
|
||||
} else if (BasicBlock *BB = dyn_cast<BasicBlock>(this)) {
|
||||
if (Function *P = BB->getParent()) ST = &P->getValueSymbolTable();
|
||||
if (Function *P = BB->getParent())
|
||||
ST = &P->getValueSymbolTable();
|
||||
} else if (GlobalValue *GV = dyn_cast<GlobalValue>(this)) {
|
||||
if (Module *P = GV->getParent()) ST = &P->getValueSymbolTable();
|
||||
if (Module *P = GV->getParent())
|
||||
ST = &P->getValueSymbolTable();
|
||||
} else if (Argument *A = dyn_cast<Argument>(this)) {
|
||||
if (Function *P = A->getParent()) ST = &P->getValueSymbolTable();
|
||||
if (Function *P = A->getParent())
|
||||
ST = &P->getValueSymbolTable();
|
||||
} else {
|
||||
assert(isa<Constant>(this) && "Unknown value type!");
|
||||
return; // no name is setable for this.
|
||||
@ -117,7 +120,7 @@ void Value::setName(const std::string &name) {
|
||||
Name = name;
|
||||
else if (hasName()) {
|
||||
if (!name.empty()) { // Replacing name.
|
||||
ST->changeName(this, name);
|
||||
ST->rename(this, name);
|
||||
} else { // Transitioning from hasName -> noname.
|
||||
ST->remove(this);
|
||||
Name.clear();
|
||||
|
@ -11,6 +11,7 @@
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#define DEBUG_TYPE "valuesymtab"
|
||||
#include "llvm/GlobalValue.h"
|
||||
#include "llvm/Type.h"
|
||||
#include "llvm/ValueSymbolTable.h"
|
||||
@ -19,18 +20,15 @@
|
||||
#include <algorithm>
|
||||
using namespace llvm;
|
||||
|
||||
#define DEBUG_SYMBOL_TABLE 0
|
||||
#define DEBUG_ABSTYPE 0
|
||||
|
||||
// Class destructor
|
||||
ValueSymbolTable::~ValueSymbolTable() {
|
||||
#ifndef NDEBUG // Only do this in -g mode...
|
||||
bool LeftoverValues = true;
|
||||
for (iterator VI = vmap.begin(), VE = vmap.end(); VI != VE; ++VI)
|
||||
if (!isa<Constant>(VI->second) ) {
|
||||
DOUT << "Value still in symbol table! Type = '"
|
||||
DEBUG(DOUT << "Value still in symbol table! Type = '"
|
||||
<< VI->second->getType()->getDescription() << "' Name = '"
|
||||
<< VI->first << "'\n";
|
||||
<< VI->first << "'\n");
|
||||
LeftoverValues = false;
|
||||
}
|
||||
assert(LeftoverValues && "Values remain in symbol table!");
|
||||
@ -83,29 +81,24 @@ void ValueSymbolTable::insert(Value* V) {
|
||||
assert(V && "Can't insert null Value into symbol table!");
|
||||
assert(V->hasName() && "Can't insert nameless Value into symbol table");
|
||||
|
||||
// Check to see if there is a naming conflict. If so, rename this type!
|
||||
// Check to see if there is a naming conflict. If so, rename this value
|
||||
std::string UniqueName = getUniqueName(V->getName());
|
||||
|
||||
#if DEBUG_SYMBOL_TABLE
|
||||
dump();
|
||||
DOUT << " Inserting value: " << UniqueName << ": " << V->dump() << "\n";
|
||||
#endif
|
||||
DEBUG(DOUT << " Inserting value: " << UniqueName << ": " << *V << "\n");
|
||||
|
||||
// Insert the vmap entry
|
||||
vmap.insert(make_pair(UniqueName, V));
|
||||
V->Name = UniqueName;
|
||||
vmap.insert(make_pair(V->Name, V));
|
||||
}
|
||||
|
||||
// Remove a value
|
||||
bool ValueSymbolTable::erase(Value *V) {
|
||||
bool ValueSymbolTable::remove(Value *V) {
|
||||
assert(V->hasName() && "Value doesn't have name!");
|
||||
iterator Entry = vmap.find(V->getName());
|
||||
if (Entry == vmap.end())
|
||||
return false;
|
||||
|
||||
#if DEBUG_SYMBOL_TABLE
|
||||
dump();
|
||||
DOUT << " Removing Value: " << Entry->second->getName() << "\n";
|
||||
#endif
|
||||
DEBUG(DOUT << " Removing Value: " << Entry->second->getName() << "\n");
|
||||
|
||||
// Remove the value from the plane...
|
||||
vmap.erase(Entry);
|
||||
@ -143,7 +136,7 @@ bool ValueSymbolTable::rename(Value *V, const std::string &name) {
|
||||
vmap.insert(make_pair(V->Name, V));
|
||||
} else {
|
||||
V->Name = name;
|
||||
vmap.insert(VI, make_pair(name, V));
|
||||
vmap.insert(VI, make_pair(V->Name, V));
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -51,7 +51,7 @@
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Intrinsics.h"
|
||||
#include "llvm/PassManager.h"
|
||||
#include "llvm/SymbolTable.h"
|
||||
#include "llvm/ValueSymbolTable.h"
|
||||
#include "llvm/Analysis/Dominators.h"
|
||||
#include "llvm/Support/CFG.h"
|
||||
#include "llvm/Support/InstVisitor.h"
|
||||
@ -175,7 +175,7 @@ namespace { // Anonymous namespace for class
|
||||
|
||||
// Verification methods...
|
||||
void verifyTypeSymbolTable(TypeSymbolTable &ST);
|
||||
void verifyValueSymbolTable(SymbolTable &ST);
|
||||
void verifyValueSymbolTable(ValueSymbolTable &ST);
|
||||
void visitGlobalValue(GlobalValue &GV);
|
||||
void visitGlobalVariable(GlobalVariable &GV);
|
||||
void visitFunction(Function &F);
|
||||
@ -307,20 +307,18 @@ void Verifier::verifyTypeSymbolTable(TypeSymbolTable &ST) {
|
||||
|
||||
// verifySymbolTable - Verify that a function or module symbol table is ok
|
||||
//
|
||||
void Verifier::verifyValueSymbolTable(SymbolTable &ST) {
|
||||
void Verifier::verifyValueSymbolTable(ValueSymbolTable &ST) {
|
||||
|
||||
// Loop over all of the values in all type planes in the symbol table.
|
||||
for (SymbolTable::plane_const_iterator PI = ST.plane_begin(),
|
||||
PE = ST.plane_end(); PI != PE; ++PI)
|
||||
for (SymbolTable::value_const_iterator VI = PI->second.begin(),
|
||||
VE = PI->second.end(); VI != VE; ++VI) {
|
||||
Value *V = VI->second;
|
||||
// Check that there are no void typed values in the symbol table. Values
|
||||
// with a void type cannot be put into symbol tables because they cannot
|
||||
// have names!
|
||||
Assert1(V->getType() != Type::VoidTy,
|
||||
"Values with void type are not allowed to have names!", V);
|
||||
}
|
||||
// Loop over all of the values in the symbol table.
|
||||
for (ValueSymbolTable::const_iterator VI = ST.begin(), VE = ST.end();
|
||||
VI != VE; ++VI) {
|
||||
Value *V = VI->second;
|
||||
// Check that there are no void typed values in the symbol table. Values
|
||||
// with a void type cannot be put into symbol tables because they cannot
|
||||
// have names!
|
||||
Assert1(V->getType() != Type::VoidTy,
|
||||
"Values with void type are not allowed to have names!", V);
|
||||
}
|
||||
}
|
||||
|
||||
// visitFunction - Verify that a function is ok.
|
||||
|
@ -5,7 +5,6 @@
|
||||
%FunTy = type i28(i28)
|
||||
|
||||
declare i28 @"test"(...) ; Test differences of prototype
|
||||
declare i28 @"test"() ; Differ only by vararg
|
||||
|
||||
implementation
|
||||
|
||||
@ -17,18 +16,18 @@ define void @"invoke"(%FunTy *%x) {
|
||||
|
||||
define i28 @"main"(i28 %argc) ; TODO: , sbyte **argv, sbyte **envp)
|
||||
begin
|
||||
%retval = call i28 (i28) *@test(i28 %argc)
|
||||
%retval = call i28 (i28) *@test2(i28 %argc)
|
||||
%two = add i28 %retval, %retval
|
||||
%retval2 = invoke i28 @test(i28 %argc)
|
||||
%retval2 = invoke i28 @test2(i28 %argc)
|
||||
to label %Next unwind label %Error
|
||||
Next:
|
||||
%two2 = add i28 %two, %retval2
|
||||
call void @invoke (%FunTy* @test)
|
||||
call void @invoke (%FunTy* @test2)
|
||||
ret i28 %two2
|
||||
Error:
|
||||
ret i28 -1
|
||||
end
|
||||
|
||||
define i28 @"test"(i28 %i0) {
|
||||
define i28 @"test2"(i28 %i0) {
|
||||
ret i28 %i0
|
||||
}
|
||||
|
10
test/Linker/redefinition.ll
Normal file
10
test/Linker/redefinition.ll
Normal file
@ -0,0 +1,10 @@
|
||||
; Test linking two functions with different prototypes and two globals
|
||||
; in different modules.
|
||||
; RUN: llvm-as %s -o %t.foo1.bc -f
|
||||
; RUN: llvm-as %s -o %t.foo2.bc -f
|
||||
; RUN: echo "define void @foo(i32 %x) { ret void }" | llvm-as -o %t.foo3.bc -f
|
||||
; RUN: llvm-link %t.foo1.bc %t.foo2.bc -o %t.bc 2>&1 | \
|
||||
; RUN: grep "Function is already defined"
|
||||
; RUN: llvm-link %t.foo1.bc %t.foo3.bc -o %t.bc 2>&1 | \
|
||||
; RUN: grep "Function 'foo' defined as both"
|
||||
define void @foo() { ret void }
|
@ -1,3 +0,0 @@
|
||||
Output
|
||||
*.log
|
||||
*.sum
|
@ -1,18 +0,0 @@
|
||||
; Test that: extern int X[] and int X[] = { 1, 2, 3, 4 } are resolved
|
||||
; correctly.
|
||||
;
|
||||
; RUN: llvm-as < %s | opt -funcresolve | llvm-dis | not grep external
|
||||
|
||||
@X = external global [0 x int]
|
||||
@X = global [4 x int] [ int 1, int 2, int 3, int 4 ]
|
||||
|
||||
implementation ; Functions:
|
||||
|
||||
int @foo(int %x) {
|
||||
bb1: ;[#uses=0]
|
||||
store int 5, int* getelementptr ([0 x int]* @X, long 0, long 2)
|
||||
%F = getelementptr [0 x int]* @X, long 0, long 2
|
||||
%val = load int* %F
|
||||
ret int %val
|
||||
}
|
||||
|
@ -1,20 +0,0 @@
|
||||
; Test that: extern int X[] and int X[] = { 1, 2, 3, 4 } are resolved
|
||||
; correctly. This doesn't have constantexprs
|
||||
;
|
||||
; RUN: llvm-as < %s | opt -funcresolve | llvm-dis | not grep external
|
||||
;
|
||||
|
||||
@X = external global [0 x int]
|
||||
@X = global [4 x int] [ int 1, int 2, int 3, int 4 ]
|
||||
|
||||
implementation ; Functions:
|
||||
|
||||
int %foo(int %x) {
|
||||
bb1: ;[#uses=0]
|
||||
%G = getelementptr [0 x int]* @X, long 0, long 1
|
||||
store int 5, int* %G
|
||||
%F = getelementptr [0 x int]* @X, long 0, long 2
|
||||
%val = load int* %F
|
||||
ret int %val
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
; RUN: llvm-upgrade < %s | llvm-as | opt -funcresolve -funcresolve | llvm-dis | not grep declare
|
||||
|
||||
declare void %qsortg(sbyte*, int, int)
|
||||
|
||||
void %test() {
|
||||
call void %qsortg(sbyte* null, int 0, int 0)
|
||||
ret void
|
||||
}
|
||||
|
||||
int %qsortg(sbyte* %base, int %n, int %size) {
|
||||
ret int %n
|
||||
}
|
@ -1,11 +0,0 @@
|
||||
; XFAIL: *
|
||||
;
|
||||
; RUN: llvm-upgrade < %s | llvm-as | opt -funcresolve -instcombine | llvm-dis | not grep '\.\.\.'
|
||||
|
||||
declare int %foo(...)
|
||||
declare int %foo(int)
|
||||
|
||||
void %bar() {
|
||||
call int(...)* %foo(int 7)
|
||||
ret void
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
; RUN: llvm-upgrade < %s | llvm-as | opt -funcresolve -disable-output 2>&1 | not grep WARNING
|
||||
|
||||
%__popcount_tab = external constant [0 x ubyte]
|
||||
%__popcount_tab = constant [4 x ubyte] c"\00\01\01\02"
|
||||
|
||||
declare void %foo(ubyte *)
|
||||
|
||||
void %test() {
|
||||
getelementptr [0 x ubyte]* %__popcount_tab, long 0, long 2
|
||||
getelementptr [4 x ubyte]* %__popcount_tab, long 0, long 2
|
||||
call void %foo(ubyte * getelementptr ([0 x ubyte]* %__popcount_tab, long 0, long 2))
|
||||
ret void
|
||||
}
|
||||
|
@ -1,11 +0,0 @@
|
||||
; RUN: llvm-upgrade < %s | llvm-as | opt -funcresolve -disable-output
|
||||
|
||||
void %foo(int, int) {
|
||||
ret void
|
||||
}
|
||||
declare void %foo(...)
|
||||
|
||||
void %test() {
|
||||
call void(...)* %foo(int 7)
|
||||
ret void
|
||||
}
|
@ -1,7 +0,0 @@
|
||||
; This testcase should not cause a warning!
|
||||
|
||||
; RUN: (as < %s | opt -funcresolve -disable-output) 2>&1 | not grep 'WARNING'
|
||||
|
||||
%X = internal global float 1.0
|
||||
%X = internal global int 1
|
||||
|
@ -1,11 +0,0 @@
|
||||
; RUN: llvm-upgrade < %s | llvm-as | opt -funcresolve | llvm-dis | not grep declare
|
||||
|
||||
%Table = constant int(...)* %foo
|
||||
|
||||
%Table2 = constant [1 x int(...)* ] [ int(...)* %foo ]
|
||||
|
||||
declare int %foo(...)
|
||||
|
||||
int %foo() {
|
||||
ret int 0
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
; RUN: llvm-upgrade < %s | llvm-as | opt -funcresolve | llvm-dis | grep declare
|
||||
|
||||
declare void %test(...)
|
||||
|
||||
int %callee() {
|
||||
call void(...)* %test(int 5)
|
||||
ret int 2
|
||||
}
|
||||
|
||||
internal void %test(int) {
|
||||
ret void
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
; RUN: llvm-upgrade < %s | llvm-as | opt -funcresolve | dis | not grep declare
|
||||
|
||||
declare void %test(int)
|
||||
|
||||
int %callee(int %X) {
|
||||
call void %test(int %X)
|
||||
ret int 2
|
||||
}
|
||||
|
||||
internal void %test(sbyte) {
|
||||
ret void
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
; RUN: llvm-upgrade < %s | llvm-as | opt -funcresolve | llvm-dis | not grep foo
|
||||
|
||||
; The funcresolve pass was resolving the two foo's together in this test,
|
||||
; adding a ConstantPointerRef to one of them. Then because of this
|
||||
; reference, it wasn't able to delete the dead declaration. :(
|
||||
|
||||
declare int %foo(...)
|
||||
declare int %foo(int)
|
||||
|
||||
|
@ -1,12 +0,0 @@
|
||||
; RUN: llvm-upgrade < %s | llvm-as | opt -funcresolve -disable-output 2>&1 | not grep WARNING
|
||||
|
||||
declare int %foo(int *%X)
|
||||
declare int %foo(float *%X)
|
||||
|
||||
implementation
|
||||
|
||||
void %test() {
|
||||
call int %foo(int* null)
|
||||
call int %foo(float* null)
|
||||
ret void
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
; This tests a hack put into place specifically for the C++ libstdc++ library.
|
||||
; It uses an ugly hack which is cleaned up by the funcresolve pass.
|
||||
;
|
||||
; RUN: llvm-as < %s | opt -funcresolve | llvm-dis | grep @X | grep '{'
|
||||
|
||||
@X = external global { i32 }
|
||||
@X = global [ 4 x i8 ] zeroinitializer
|
||||
|
||||
define i32* @test() {
|
||||
%P = getelementptr {i32}* @X, i64 0, i32 0
|
||||
ret i32* %P
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
; RUN: llvm-upgrade < %s | llvm-as | opt -funcresolve -disable-output 2>&1 | not grep WARNING
|
||||
|
||||
|
||||
void %test() {
|
||||
call int(...)* %test()
|
||||
ret void
|
||||
}
|
||||
|
||||
declare int %test(...)
|
||||
|
@ -1,12 +0,0 @@
|
||||
; RUN: llvm-upgrade < %s | llvm-as | opt -funcresolve -instcombine | llvm-dis | grep '\.\.\.' | not grep call
|
||||
|
||||
declare int %foo(...)
|
||||
|
||||
int %foo(int %x, float %y) {
|
||||
ret int %x
|
||||
}
|
||||
|
||||
int %bar() {
|
||||
%x = call int(...)* %foo(double 12.5, int 48)
|
||||
ret int %x
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
load_lib llvm-dg.exp
|
||||
|
||||
llvm-runtest [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,llx,c,cpp,tr}]] $objdir $srcdir $subdir $target_triplet $llvmgcc $llvmgxx $prcontext $llvmgcc_version
|
@ -1,14 +0,0 @@
|
||||
; This shows where the function is called with the prototype indicating a
|
||||
; return type exists, but it really doesn't.
|
||||
; RUN: llvm-upgrade < %s | llvm-as | opt -funcresolve -instcombine | llvm-dis | grep '\.\.\.' | not grep call
|
||||
|
||||
declare int %foo(...)
|
||||
|
||||
void %foo(int %x, float %y) {
|
||||
ret void
|
||||
}
|
||||
|
||||
int %bar() {
|
||||
%x = call int(...)* %foo(double 12.5, int 48)
|
||||
ret int %x
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
; This shows where the function is called with the prototype indicating a
|
||||
; return type doesn't exists, but it really does.
|
||||
;
|
||||
; RUN: llvm-upgrade < %s | llvm-as | opt -funcresolve -instcombine | llvm-dis | grep '\.\.\.' | not grep call
|
||||
|
||||
declare void %foo(...)
|
||||
|
||||
int %foo(int %x, float %y) {
|
||||
ret int %x
|
||||
}
|
||||
|
||||
int %bar() {
|
||||
call void (...)* %foo(double 12.5, int 48)
|
||||
ret int 6
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
; RUN: llvm-upgrade < %s | llvm-as | opt -funcresolve
|
||||
|
||||
declare int %read(...)
|
||||
|
||||
long %read() {
|
||||
ret long 0
|
||||
}
|
||||
|
||||
int %testfunc() {
|
||||
%X = call int(...)* %read()
|
||||
ret int %X
|
||||
}
|
@ -20,7 +20,7 @@
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/Pass.h"
|
||||
#include "llvm/PassManager.h"
|
||||
#include "llvm/SymbolTable.h"
|
||||
#include "llvm/ValueSymbolTable.h"
|
||||
#include "llvm/Analysis/Verifier.h"
|
||||
#include "llvm/Bytecode/Writer.h"
|
||||
#include "llvm/Support/CFG.h"
|
||||
@ -206,9 +206,9 @@ bool ReduceCrashingFunctions::TestFuncs(std::vector<Function*> &Funcs) {
|
||||
// FIXME: bugpoint should add names to all stripped symbols.
|
||||
assert(!Funcs[i]->getName().empty() &&
|
||||
"Bugpoint doesn't work on stripped modules yet PR718!");
|
||||
Function *CMF = M->getFunction(Funcs[i]->getName(),
|
||||
Funcs[i]->getFunctionType());
|
||||
Function *CMF = M->getFunction(Funcs[i]->getName());
|
||||
assert(CMF && "Function not in module?!");
|
||||
assert(CMF->getFunctionType() == Funcs[i]->getFunctionType() && "wrong ty");
|
||||
Functions.insert(CMF);
|
||||
}
|
||||
|
||||
@ -271,8 +271,9 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock*> &BBs) {
|
||||
for (unsigned i = 0, e = BBs.size(); i != e; ++i) {
|
||||
// Convert the basic block from the original module to the new module...
|
||||
const Function *F = BBs[i]->getParent();
|
||||
Function *CMF = M->getFunction(F->getName(), F->getFunctionType());
|
||||
Function *CMF = M->getFunction(F->getName());
|
||||
assert(CMF && "Function not in module?!");
|
||||
assert(CMF->getFunctionType() == F->getFunctionType() && "wrong type?");
|
||||
|
||||
// Get the mapped basic block...
|
||||
Function::iterator CBI = CMF->begin();
|
||||
@ -337,10 +338,10 @@ bool ReduceCrashingBlocks::TestBlocks(std::vector<const BasicBlock*> &BBs) {
|
||||
// module, and that they don't include any deleted blocks.
|
||||
BBs.clear();
|
||||
for (unsigned i = 0, e = BlockInfo.size(); i != e; ++i) {
|
||||
SymbolTable &ST = BlockInfo[i].first->getValueSymbolTable();
|
||||
SymbolTable::plane_iterator PI = ST.find(Type::LabelTy);
|
||||
if (PI != ST.plane_end() && PI->second.count(BlockInfo[i].second))
|
||||
BBs.push_back(cast<BasicBlock>(PI->second[BlockInfo[i].second]));
|
||||
ValueSymbolTable &ST = BlockInfo[i].first->getValueSymbolTable();
|
||||
Value* V = ST.lookup(BlockInfo[i].second);
|
||||
if (V && V->getType() == Type::LabelTy)
|
||||
BBs.push_back(cast<BasicBlock>(V));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -110,7 +110,6 @@ Module *BugDriver::performFinalCleanups(Module *M, bool MayModifySemantics) {
|
||||
I->setLinkage(GlobalValue::ExternalLinkage);
|
||||
|
||||
std::vector<const PassInfo*> CleanupPasses;
|
||||
CleanupPasses.push_back(getPI(createFunctionResolvingPass()));
|
||||
CleanupPasses.push_back(getPI(createGlobalDCEPass()));
|
||||
CleanupPasses.push_back(getPI(createDeadTypeEliminationPass()));
|
||||
|
||||
@ -221,7 +220,7 @@ static void SplitStaticCtorDtor(const char *GlobalName, Module *M1, Module *M2){
|
||||
M1Tors.push_back(std::make_pair(F, Priority));
|
||||
else {
|
||||
// Map to M2's version of the function.
|
||||
F = M2->getFunction(F->getName(), F->getFunctionType());
|
||||
F = M2->getFunction(F->getName());
|
||||
M2Tors.push_back(std::make_pair(F, Priority));
|
||||
}
|
||||
}
|
||||
@ -272,9 +271,10 @@ Module *llvm::SplitFunctionsOutOfModule(Module *M,
|
||||
std::set<std::pair<std::string, const PointerType*> > TestFunctions;
|
||||
for (unsigned i = 0, e = F.size(); i != e; ++i) {
|
||||
TestFunctions.insert(std::make_pair(F[i]->getName(), F[i]->getType()));
|
||||
Function *TNOF = M->getFunction(F[i]->getName(), F[i]->getFunctionType());
|
||||
DEBUG(std::cerr << "Removing function " << F[i]->getName() << "\n");
|
||||
Function *TNOF = M->getFunction(F[i]->getName());
|
||||
assert(TNOF && "Function doesn't exist in module!");
|
||||
assert(TNOF->getFunctionType() == F[i]->getFunctionType() && "wrong type?");
|
||||
DEBUG(std::cerr << "Removing function " << F[i]->getName() << "\n");
|
||||
DeleteFunctionBody(TNOF); // Function is now external in this module!
|
||||
}
|
||||
|
||||
@ -317,7 +317,7 @@ bool BlockExtractorPass::runOnModule(Module &M) {
|
||||
Function *F = BB->getParent();
|
||||
|
||||
// Map the corresponding function in this module.
|
||||
Function *MF = M.getFunction(F->getName(), F->getFunctionType());
|
||||
Function *MF = M.getFunction(F->getName());
|
||||
|
||||
// Figure out which index the basic block is in its function.
|
||||
Function::iterator BBI = MF->begin();
|
||||
|
@ -341,9 +341,11 @@ static bool ExtractLoops(BugDriver &BD,
|
||||
// optimized and loop extracted module.
|
||||
MiscompiledFunctions.clear();
|
||||
for (unsigned i = 0, e = MisCompFunctions.size(); i != e; ++i) {
|
||||
Function *NewF = ToNotOptimize->getFunction(MisCompFunctions[i].first,
|
||||
MisCompFunctions[i].second);
|
||||
Function *NewF = ToNotOptimize->getFunction(MisCompFunctions[i].first);
|
||||
|
||||
assert(NewF && "Function not found??");
|
||||
assert(NewF->getFunctionType() == MisCompFunctions[i].second &&
|
||||
"found wrong function type?");
|
||||
MiscompiledFunctions.push_back(NewF);
|
||||
}
|
||||
|
||||
@ -479,9 +481,10 @@ static bool ExtractBlocks(BugDriver &BD,
|
||||
MiscompiledFunctions.clear();
|
||||
|
||||
for (unsigned i = 0, e = MisCompFunctions.size(); i != e; ++i) {
|
||||
Function *NewF = ProgClone->getFunction(MisCompFunctions[i].first,
|
||||
MisCompFunctions[i].second);
|
||||
Function *NewF = ProgClone->getFunction(MisCompFunctions[i].first);
|
||||
assert(NewF && "Function not found??");
|
||||
assert(NewF->getFunctionType() == MisCompFunctions[i].second &&
|
||||
"Function has wrong type??");
|
||||
MiscompiledFunctions.push_back(NewF);
|
||||
}
|
||||
|
||||
|
@ -212,12 +212,6 @@ int llvm::GenerateBytecode(Module *M, int StripLevel, bool Internalize,
|
||||
// Add an appropriate TargetData instance for this module...
|
||||
addPass(Passes, new TargetData(M));
|
||||
|
||||
// Often if the programmer does not specify proper prototypes for the
|
||||
// functions they are calling, they end up calling a vararg version of the
|
||||
// function that does not get a body filled in (the real function has typed
|
||||
// arguments). This pass merges the two functions.
|
||||
addPass(Passes, createFunctionResolvingPass());
|
||||
|
||||
if (!DisableOptimizations) {
|
||||
// Now that composite has been compiled, scan through the module, looking
|
||||
// for a main function. If main is defined, mark all other functions
|
||||
|
@ -79,7 +79,6 @@ int main(int argc, char **argv) {
|
||||
Passes.add(createFunctionExtractionPass(F, DeleteFn, Relink));
|
||||
if (!DeleteFn)
|
||||
Passes.add(createGlobalDCEPass()); // Delete unreachable globals
|
||||
Passes.add(createFunctionResolvingPass()); // Delete prototypes
|
||||
Passes.add(createDeadTypeEliminationPass()); // Remove dead types...
|
||||
|
||||
std::ostream *Out = 0;
|
||||
|
@ -108,12 +108,6 @@ void Optimize(Module* M) {
|
||||
// Add an appropriate TargetData instance for this module...
|
||||
addPass(Passes, new TargetData(M));
|
||||
|
||||
// Often if the programmer does not specify proper prototypes for the
|
||||
// functions they are calling, they end up calling a vararg version of the
|
||||
// function that does not get a body filled in (the real function has typed
|
||||
// arguments). This pass merges the two functions.
|
||||
addPass(Passes, createFunctionResolvingPass());
|
||||
|
||||
if (!DisableOptimizations) {
|
||||
// Now that composite has been compiled, scan through the module, looking
|
||||
// for a main function. If main is defined, mark all other functions
|
||||
|
@ -925,7 +925,7 @@ goto find_rule; \
|
||||
#define YY_MORE_ADJ 0
|
||||
#define YY_RESTORE_YY_MORE_OFFSET
|
||||
char *yytext;
|
||||
#line 1 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 1 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#define INITIAL 0
|
||||
/*===-- UpgradeLexer.l - Scanner for 1.9 assembly files --------*- C++ -*--===//
|
||||
//
|
||||
@ -940,7 +940,7 @@ char *yytext;
|
||||
//
|
||||
//===----------------------------------------------------------------------===*/
|
||||
#define YY_NEVER_INTERACTIVE 1
|
||||
#line 28 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 28 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#include "UpgradeInternals.h"
|
||||
#include "llvm/Module.h"
|
||||
#include <list>
|
||||
@ -1227,7 +1227,7 @@ YY_DECL
|
||||
register char *yy_cp = NULL, *yy_bp = NULL;
|
||||
register int yy_act;
|
||||
|
||||
#line 189 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 189 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
|
||||
|
||||
#line 1234 "UpgradeLexer.cpp"
|
||||
@ -1323,717 +1323,717 @@ do_action: /* This label is used only to access EOF actions. */
|
||||
{ /* beginning of action switch */
|
||||
case 1:
|
||||
YY_RULE_SETUP
|
||||
#line 191 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 191 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ /* Ignore comments for now */ }
|
||||
YY_BREAK
|
||||
case 2:
|
||||
YY_RULE_SETUP
|
||||
#line 193 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 193 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return BEGINTOK; }
|
||||
YY_BREAK
|
||||
case 3:
|
||||
YY_RULE_SETUP
|
||||
#line 194 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 194 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return ENDTOK; }
|
||||
YY_BREAK
|
||||
case 4:
|
||||
YY_RULE_SETUP
|
||||
#line 195 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 195 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return TRUETOK; }
|
||||
YY_BREAK
|
||||
case 5:
|
||||
YY_RULE_SETUP
|
||||
#line 196 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 196 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return FALSETOK; }
|
||||
YY_BREAK
|
||||
case 6:
|
||||
YY_RULE_SETUP
|
||||
#line 197 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 197 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return DECLARE; }
|
||||
YY_BREAK
|
||||
case 7:
|
||||
YY_RULE_SETUP
|
||||
#line 198 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 198 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return GLOBAL; }
|
||||
YY_BREAK
|
||||
case 8:
|
||||
YY_RULE_SETUP
|
||||
#line 199 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 199 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return CONSTANT; }
|
||||
YY_BREAK
|
||||
case 9:
|
||||
YY_RULE_SETUP
|
||||
#line 200 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 200 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return INTERNAL; }
|
||||
YY_BREAK
|
||||
case 10:
|
||||
YY_RULE_SETUP
|
||||
#line 201 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 201 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return LINKONCE; }
|
||||
YY_BREAK
|
||||
case 11:
|
||||
YY_RULE_SETUP
|
||||
#line 202 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 202 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return WEAK; }
|
||||
YY_BREAK
|
||||
case 12:
|
||||
YY_RULE_SETUP
|
||||
#line 203 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 203 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return APPENDING; }
|
||||
YY_BREAK
|
||||
case 13:
|
||||
YY_RULE_SETUP
|
||||
#line 204 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 204 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return DLLIMPORT; }
|
||||
YY_BREAK
|
||||
case 14:
|
||||
YY_RULE_SETUP
|
||||
#line 205 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 205 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return DLLEXPORT; }
|
||||
YY_BREAK
|
||||
case 15:
|
||||
YY_RULE_SETUP
|
||||
#line 206 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 206 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return EXTERN_WEAK; }
|
||||
YY_BREAK
|
||||
case 16:
|
||||
YY_RULE_SETUP
|
||||
#line 207 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 207 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return EXTERNAL; } /* Deprecated, turn into external */
|
||||
YY_BREAK
|
||||
case 17:
|
||||
YY_RULE_SETUP
|
||||
#line 208 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 208 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return EXTERNAL; }
|
||||
YY_BREAK
|
||||
case 18:
|
||||
YY_RULE_SETUP
|
||||
#line 209 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 209 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return IMPLEMENTATION; }
|
||||
YY_BREAK
|
||||
case 19:
|
||||
YY_RULE_SETUP
|
||||
#line 210 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 210 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return ZEROINITIALIZER; }
|
||||
YY_BREAK
|
||||
case 20:
|
||||
YY_RULE_SETUP
|
||||
#line 211 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 211 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return DOTDOTDOT; }
|
||||
YY_BREAK
|
||||
case 21:
|
||||
YY_RULE_SETUP
|
||||
#line 212 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 212 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return UNDEF; }
|
||||
YY_BREAK
|
||||
case 22:
|
||||
YY_RULE_SETUP
|
||||
#line 213 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 213 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return NULL_TOK; }
|
||||
YY_BREAK
|
||||
case 23:
|
||||
YY_RULE_SETUP
|
||||
#line 214 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 214 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return TO; }
|
||||
YY_BREAK
|
||||
case 24:
|
||||
YY_RULE_SETUP
|
||||
#line 215 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 215 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return EXCEPT; }
|
||||
YY_BREAK
|
||||
case 25:
|
||||
YY_RULE_SETUP
|
||||
#line 216 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 216 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return NOT; } /* Deprecated, turned into XOR */
|
||||
YY_BREAK
|
||||
case 26:
|
||||
YY_RULE_SETUP
|
||||
#line 217 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 217 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return TAIL; }
|
||||
YY_BREAK
|
||||
case 27:
|
||||
YY_RULE_SETUP
|
||||
#line 218 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 218 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return TARGET; }
|
||||
YY_BREAK
|
||||
case 28:
|
||||
YY_RULE_SETUP
|
||||
#line 219 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 219 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return TRIPLE; }
|
||||
YY_BREAK
|
||||
case 29:
|
||||
YY_RULE_SETUP
|
||||
#line 220 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 220 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return DEPLIBS; }
|
||||
YY_BREAK
|
||||
case 30:
|
||||
YY_RULE_SETUP
|
||||
#line 221 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 221 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return ENDIAN; }
|
||||
YY_BREAK
|
||||
case 31:
|
||||
YY_RULE_SETUP
|
||||
#line 222 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 222 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return POINTERSIZE; }
|
||||
YY_BREAK
|
||||
case 32:
|
||||
YY_RULE_SETUP
|
||||
#line 223 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 223 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return DATALAYOUT; }
|
||||
YY_BREAK
|
||||
case 33:
|
||||
YY_RULE_SETUP
|
||||
#line 224 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 224 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return LITTLE; }
|
||||
YY_BREAK
|
||||
case 34:
|
||||
YY_RULE_SETUP
|
||||
#line 225 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 225 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return BIG; }
|
||||
YY_BREAK
|
||||
case 35:
|
||||
YY_RULE_SETUP
|
||||
#line 226 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 226 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return VOLATILE; }
|
||||
YY_BREAK
|
||||
case 36:
|
||||
YY_RULE_SETUP
|
||||
#line 227 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 227 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return ALIGN; }
|
||||
YY_BREAK
|
||||
case 37:
|
||||
YY_RULE_SETUP
|
||||
#line 228 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 228 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return SECTION; }
|
||||
YY_BREAK
|
||||
case 38:
|
||||
YY_RULE_SETUP
|
||||
#line 229 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 229 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return MODULE; }
|
||||
YY_BREAK
|
||||
case 39:
|
||||
YY_RULE_SETUP
|
||||
#line 230 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 230 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return ASM_TOK; }
|
||||
YY_BREAK
|
||||
case 40:
|
||||
YY_RULE_SETUP
|
||||
#line 231 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 231 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return SIDEEFFECT; }
|
||||
YY_BREAK
|
||||
case 41:
|
||||
YY_RULE_SETUP
|
||||
#line 233 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 233 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return CC_TOK; }
|
||||
YY_BREAK
|
||||
case 42:
|
||||
YY_RULE_SETUP
|
||||
#line 234 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 234 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return CCC_TOK; }
|
||||
YY_BREAK
|
||||
case 43:
|
||||
YY_RULE_SETUP
|
||||
#line 235 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 235 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return CSRETCC_TOK; }
|
||||
YY_BREAK
|
||||
case 44:
|
||||
YY_RULE_SETUP
|
||||
#line 236 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 236 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return FASTCC_TOK; }
|
||||
YY_BREAK
|
||||
case 45:
|
||||
YY_RULE_SETUP
|
||||
#line 237 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 237 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return COLDCC_TOK; }
|
||||
YY_BREAK
|
||||
case 46:
|
||||
YY_RULE_SETUP
|
||||
#line 238 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 238 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return X86_STDCALLCC_TOK; }
|
||||
YY_BREAK
|
||||
case 47:
|
||||
YY_RULE_SETUP
|
||||
#line 239 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 239 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return X86_FASTCALLCC_TOK; }
|
||||
YY_BREAK
|
||||
case 48:
|
||||
YY_RULE_SETUP
|
||||
#line 241 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 241 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TY(SBYTE, Type::Int8Ty, Signed); }
|
||||
YY_BREAK
|
||||
case 49:
|
||||
YY_RULE_SETUP
|
||||
#line 242 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 242 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TY(UBYTE, Type::Int8Ty, Unsigned); }
|
||||
YY_BREAK
|
||||
case 50:
|
||||
YY_RULE_SETUP
|
||||
#line 243 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 243 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TY(SHORT, Type::Int16Ty, Signed); }
|
||||
YY_BREAK
|
||||
case 51:
|
||||
YY_RULE_SETUP
|
||||
#line 244 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 244 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TY(USHORT, Type::Int16Ty, Unsigned); }
|
||||
YY_BREAK
|
||||
case 52:
|
||||
YY_RULE_SETUP
|
||||
#line 245 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 245 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TY(INT, Type::Int32Ty, Signed); }
|
||||
YY_BREAK
|
||||
case 53:
|
||||
YY_RULE_SETUP
|
||||
#line 246 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 246 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TY(UINT, Type::Int32Ty, Unsigned); }
|
||||
YY_BREAK
|
||||
case 54:
|
||||
YY_RULE_SETUP
|
||||
#line 247 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 247 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TY(LONG, Type::Int64Ty, Signed); }
|
||||
YY_BREAK
|
||||
case 55:
|
||||
YY_RULE_SETUP
|
||||
#line 248 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 248 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TY(ULONG, Type::Int64Ty, Unsigned); }
|
||||
YY_BREAK
|
||||
case 56:
|
||||
YY_RULE_SETUP
|
||||
#line 249 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 249 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TY(VOID, Type::VoidTy, Signless ); }
|
||||
YY_BREAK
|
||||
case 57:
|
||||
YY_RULE_SETUP
|
||||
#line 250 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 250 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TY(BOOL, Type::Int1Ty, Unsigned ); }
|
||||
YY_BREAK
|
||||
case 58:
|
||||
YY_RULE_SETUP
|
||||
#line 251 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 251 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TY(FLOAT, Type::FloatTy, Signless ); }
|
||||
YY_BREAK
|
||||
case 59:
|
||||
YY_RULE_SETUP
|
||||
#line 252 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 252 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TY(DOUBLE, Type::DoubleTy,Signless); }
|
||||
YY_BREAK
|
||||
case 60:
|
||||
YY_RULE_SETUP
|
||||
#line 253 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 253 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TY(LABEL, Type::LabelTy, Signless ); }
|
||||
YY_BREAK
|
||||
case 61:
|
||||
YY_RULE_SETUP
|
||||
#line 254 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 254 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return TYPE; }
|
||||
YY_BREAK
|
||||
case 62:
|
||||
YY_RULE_SETUP
|
||||
#line 255 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 255 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return OPAQUE; }
|
||||
YY_BREAK
|
||||
case 63:
|
||||
YY_RULE_SETUP
|
||||
#line 257 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 257 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(BinaryOpVal, AddOp, ADD); }
|
||||
YY_BREAK
|
||||
case 64:
|
||||
YY_RULE_SETUP
|
||||
#line 258 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 258 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(BinaryOpVal, SubOp, SUB); }
|
||||
YY_BREAK
|
||||
case 65:
|
||||
YY_RULE_SETUP
|
||||
#line 259 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 259 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(BinaryOpVal, MulOp, MUL); }
|
||||
YY_BREAK
|
||||
case 66:
|
||||
YY_RULE_SETUP
|
||||
#line 260 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 260 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(BinaryOpVal, DivOp, DIV); }
|
||||
YY_BREAK
|
||||
case 67:
|
||||
YY_RULE_SETUP
|
||||
#line 261 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 261 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(BinaryOpVal, UDivOp, UDIV); }
|
||||
YY_BREAK
|
||||
case 68:
|
||||
YY_RULE_SETUP
|
||||
#line 262 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 262 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(BinaryOpVal, SDivOp, SDIV); }
|
||||
YY_BREAK
|
||||
case 69:
|
||||
YY_RULE_SETUP
|
||||
#line 263 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 263 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(BinaryOpVal, FDivOp, FDIV); }
|
||||
YY_BREAK
|
||||
case 70:
|
||||
YY_RULE_SETUP
|
||||
#line 264 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 264 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(BinaryOpVal, RemOp, REM); }
|
||||
YY_BREAK
|
||||
case 71:
|
||||
YY_RULE_SETUP
|
||||
#line 265 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 265 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(BinaryOpVal, URemOp, UREM); }
|
||||
YY_BREAK
|
||||
case 72:
|
||||
YY_RULE_SETUP
|
||||
#line 266 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 266 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(BinaryOpVal, SRemOp, SREM); }
|
||||
YY_BREAK
|
||||
case 73:
|
||||
YY_RULE_SETUP
|
||||
#line 267 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 267 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(BinaryOpVal, FRemOp, FREM); }
|
||||
YY_BREAK
|
||||
case 74:
|
||||
YY_RULE_SETUP
|
||||
#line 268 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 268 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(BinaryOpVal, AndOp, AND); }
|
||||
YY_BREAK
|
||||
case 75:
|
||||
YY_RULE_SETUP
|
||||
#line 269 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 269 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(BinaryOpVal, OrOp , OR ); }
|
||||
YY_BREAK
|
||||
case 76:
|
||||
YY_RULE_SETUP
|
||||
#line 270 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 270 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(BinaryOpVal, XorOp, XOR); }
|
||||
YY_BREAK
|
||||
case 77:
|
||||
YY_RULE_SETUP
|
||||
#line 271 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 271 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(BinaryOpVal, SetNE, SETNE); }
|
||||
YY_BREAK
|
||||
case 78:
|
||||
YY_RULE_SETUP
|
||||
#line 272 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 272 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(BinaryOpVal, SetEQ, SETEQ); }
|
||||
YY_BREAK
|
||||
case 79:
|
||||
YY_RULE_SETUP
|
||||
#line 273 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 273 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(BinaryOpVal, SetLT, SETLT); }
|
||||
YY_BREAK
|
||||
case 80:
|
||||
YY_RULE_SETUP
|
||||
#line 274 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 274 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(BinaryOpVal, SetGT, SETGT); }
|
||||
YY_BREAK
|
||||
case 81:
|
||||
YY_RULE_SETUP
|
||||
#line 275 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 275 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(BinaryOpVal, SetLE, SETLE); }
|
||||
YY_BREAK
|
||||
case 82:
|
||||
YY_RULE_SETUP
|
||||
#line 276 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 276 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(BinaryOpVal, SetGE, SETGE); }
|
||||
YY_BREAK
|
||||
case 83:
|
||||
YY_RULE_SETUP
|
||||
#line 277 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 277 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(BinaryOpVal, ShlOp, SHL); }
|
||||
YY_BREAK
|
||||
case 84:
|
||||
YY_RULE_SETUP
|
||||
#line 278 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 278 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(BinaryOpVal, ShrOp, SHR); }
|
||||
YY_BREAK
|
||||
case 85:
|
||||
YY_RULE_SETUP
|
||||
#line 279 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 279 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(BinaryOpVal, LShrOp, LSHR); }
|
||||
YY_BREAK
|
||||
case 86:
|
||||
YY_RULE_SETUP
|
||||
#line 280 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 280 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(BinaryOpVal, AShrOp, ASHR); }
|
||||
YY_BREAK
|
||||
case 87:
|
||||
YY_RULE_SETUP
|
||||
#line 282 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 282 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(OtherOpVal, ICmpOp, ICMP); }
|
||||
YY_BREAK
|
||||
case 88:
|
||||
YY_RULE_SETUP
|
||||
#line 283 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 283 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(OtherOpVal, FCmpOp, FCMP); }
|
||||
YY_BREAK
|
||||
case 89:
|
||||
YY_RULE_SETUP
|
||||
#line 285 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 285 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return EQ; }
|
||||
YY_BREAK
|
||||
case 90:
|
||||
YY_RULE_SETUP
|
||||
#line 286 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 286 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return NE; }
|
||||
YY_BREAK
|
||||
case 91:
|
||||
YY_RULE_SETUP
|
||||
#line 287 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 287 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return SLT; }
|
||||
YY_BREAK
|
||||
case 92:
|
||||
YY_RULE_SETUP
|
||||
#line 288 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 288 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return SGT; }
|
||||
YY_BREAK
|
||||
case 93:
|
||||
YY_RULE_SETUP
|
||||
#line 289 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 289 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return SLE; }
|
||||
YY_BREAK
|
||||
case 94:
|
||||
YY_RULE_SETUP
|
||||
#line 290 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 290 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return SGE; }
|
||||
YY_BREAK
|
||||
case 95:
|
||||
YY_RULE_SETUP
|
||||
#line 291 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 291 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return ULT; }
|
||||
YY_BREAK
|
||||
case 96:
|
||||
YY_RULE_SETUP
|
||||
#line 292 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 292 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return UGT; }
|
||||
YY_BREAK
|
||||
case 97:
|
||||
YY_RULE_SETUP
|
||||
#line 293 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 293 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return ULE; }
|
||||
YY_BREAK
|
||||
case 98:
|
||||
YY_RULE_SETUP
|
||||
#line 294 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 294 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return UGE; }
|
||||
YY_BREAK
|
||||
case 99:
|
||||
YY_RULE_SETUP
|
||||
#line 295 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 295 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return OEQ; }
|
||||
YY_BREAK
|
||||
case 100:
|
||||
YY_RULE_SETUP
|
||||
#line 296 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 296 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return ONE; }
|
||||
YY_BREAK
|
||||
case 101:
|
||||
YY_RULE_SETUP
|
||||
#line 297 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 297 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return OLT; }
|
||||
YY_BREAK
|
||||
case 102:
|
||||
YY_RULE_SETUP
|
||||
#line 298 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 298 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return OGT; }
|
||||
YY_BREAK
|
||||
case 103:
|
||||
YY_RULE_SETUP
|
||||
#line 299 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 299 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return OLE; }
|
||||
YY_BREAK
|
||||
case 104:
|
||||
YY_RULE_SETUP
|
||||
#line 300 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 300 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return OGE; }
|
||||
YY_BREAK
|
||||
case 105:
|
||||
YY_RULE_SETUP
|
||||
#line 301 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 301 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return ORD; }
|
||||
YY_BREAK
|
||||
case 106:
|
||||
YY_RULE_SETUP
|
||||
#line 302 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 302 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return UNO; }
|
||||
YY_BREAK
|
||||
case 107:
|
||||
YY_RULE_SETUP
|
||||
#line 303 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 303 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return UEQ; }
|
||||
YY_BREAK
|
||||
case 108:
|
||||
YY_RULE_SETUP
|
||||
#line 304 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 304 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return UNE; }
|
||||
YY_BREAK
|
||||
case 109:
|
||||
YY_RULE_SETUP
|
||||
#line 306 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 306 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(OtherOpVal, PHIOp, PHI_TOK); }
|
||||
YY_BREAK
|
||||
case 110:
|
||||
YY_RULE_SETUP
|
||||
#line 307 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 307 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(OtherOpVal, CallOp, CALL); }
|
||||
YY_BREAK
|
||||
case 111:
|
||||
YY_RULE_SETUP
|
||||
#line 308 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 308 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(CastOpVal, CastOp, CAST); }
|
||||
YY_BREAK
|
||||
case 112:
|
||||
YY_RULE_SETUP
|
||||
#line 309 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 309 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(CastOpVal, TruncOp, TRUNC); }
|
||||
YY_BREAK
|
||||
case 113:
|
||||
YY_RULE_SETUP
|
||||
#line 310 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 310 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(CastOpVal, ZExtOp , ZEXT); }
|
||||
YY_BREAK
|
||||
case 114:
|
||||
YY_RULE_SETUP
|
||||
#line 311 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 311 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(CastOpVal, SExtOp, SEXT); }
|
||||
YY_BREAK
|
||||
case 115:
|
||||
YY_RULE_SETUP
|
||||
#line 312 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 312 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(CastOpVal, FPTruncOp, FPTRUNC); }
|
||||
YY_BREAK
|
||||
case 116:
|
||||
YY_RULE_SETUP
|
||||
#line 313 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 313 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(CastOpVal, FPExtOp, FPEXT); }
|
||||
YY_BREAK
|
||||
case 117:
|
||||
YY_RULE_SETUP
|
||||
#line 314 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 314 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(CastOpVal, FPToUIOp, FPTOUI); }
|
||||
YY_BREAK
|
||||
case 118:
|
||||
YY_RULE_SETUP
|
||||
#line 315 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 315 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(CastOpVal, FPToSIOp, FPTOSI); }
|
||||
YY_BREAK
|
||||
case 119:
|
||||
YY_RULE_SETUP
|
||||
#line 316 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 316 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(CastOpVal, UIToFPOp, UITOFP); }
|
||||
YY_BREAK
|
||||
case 120:
|
||||
YY_RULE_SETUP
|
||||
#line 317 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 317 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(CastOpVal, SIToFPOp, SITOFP); }
|
||||
YY_BREAK
|
||||
case 121:
|
||||
YY_RULE_SETUP
|
||||
#line 318 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 318 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(CastOpVal, PtrToIntOp, PTRTOINT); }
|
||||
YY_BREAK
|
||||
case 122:
|
||||
YY_RULE_SETUP
|
||||
#line 319 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 319 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(CastOpVal, IntToPtrOp, INTTOPTR); }
|
||||
YY_BREAK
|
||||
case 123:
|
||||
YY_RULE_SETUP
|
||||
#line 320 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 320 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(CastOpVal, BitCastOp, BITCAST); }
|
||||
YY_BREAK
|
||||
case 124:
|
||||
YY_RULE_SETUP
|
||||
#line 321 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 321 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(OtherOpVal, SelectOp, SELECT); }
|
||||
YY_BREAK
|
||||
case 125:
|
||||
YY_RULE_SETUP
|
||||
#line 322 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 322 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return VANEXT_old; }
|
||||
YY_BREAK
|
||||
case 126:
|
||||
YY_RULE_SETUP
|
||||
#line 323 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 323 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return VAARG_old; }
|
||||
YY_BREAK
|
||||
case 127:
|
||||
YY_RULE_SETUP
|
||||
#line 324 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 324 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(OtherOpVal, VAArg , VAARG); }
|
||||
YY_BREAK
|
||||
case 128:
|
||||
YY_RULE_SETUP
|
||||
#line 325 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 325 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(TermOpVal, RetOp, RET); }
|
||||
YY_BREAK
|
||||
case 129:
|
||||
YY_RULE_SETUP
|
||||
#line 326 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 326 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(TermOpVal, BrOp, BR); }
|
||||
YY_BREAK
|
||||
case 130:
|
||||
YY_RULE_SETUP
|
||||
#line 327 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 327 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(TermOpVal, SwitchOp, SWITCH); }
|
||||
YY_BREAK
|
||||
case 131:
|
||||
YY_RULE_SETUP
|
||||
#line 328 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 328 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(TermOpVal, InvokeOp, INVOKE); }
|
||||
YY_BREAK
|
||||
case 132:
|
||||
YY_RULE_SETUP
|
||||
#line 329 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 329 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return UNWIND; }
|
||||
YY_BREAK
|
||||
case 133:
|
||||
YY_RULE_SETUP
|
||||
#line 330 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 330 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(TermOpVal, UnreachableOp, UNREACHABLE); }
|
||||
YY_BREAK
|
||||
case 134:
|
||||
YY_RULE_SETUP
|
||||
#line 332 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 332 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(MemOpVal, MallocOp, MALLOC); }
|
||||
YY_BREAK
|
||||
case 135:
|
||||
YY_RULE_SETUP
|
||||
#line 333 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 333 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(MemOpVal, AllocaOp, ALLOCA); }
|
||||
YY_BREAK
|
||||
case 136:
|
||||
YY_RULE_SETUP
|
||||
#line 334 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 334 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(MemOpVal, FreeOp, FREE); }
|
||||
YY_BREAK
|
||||
case 137:
|
||||
YY_RULE_SETUP
|
||||
#line 335 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 335 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(MemOpVal, LoadOp, LOAD); }
|
||||
YY_BREAK
|
||||
case 138:
|
||||
YY_RULE_SETUP
|
||||
#line 336 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 336 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(MemOpVal, StoreOp, STORE); }
|
||||
YY_BREAK
|
||||
case 139:
|
||||
YY_RULE_SETUP
|
||||
#line 337 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 337 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(MemOpVal, GetElementPtrOp, GETELEMENTPTR); }
|
||||
YY_BREAK
|
||||
case 140:
|
||||
YY_RULE_SETUP
|
||||
#line 339 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 339 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(OtherOpVal, ExtractElementOp, EXTRACTELEMENT); }
|
||||
YY_BREAK
|
||||
case 141:
|
||||
YY_RULE_SETUP
|
||||
#line 340 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 340 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(OtherOpVal, InsertElementOp, INSERTELEMENT); }
|
||||
YY_BREAK
|
||||
case 142:
|
||||
YY_RULE_SETUP
|
||||
#line 341 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 341 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ RET_TOK(OtherOpVal, ShuffleVectorOp, SHUFFLEVECTOR); }
|
||||
YY_BREAK
|
||||
case 143:
|
||||
YY_RULE_SETUP
|
||||
#line 344 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 344 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{
|
||||
UnEscapeLexed(yytext+1);
|
||||
Upgradelval.StrVal = strdup(yytext+1); // Skip %
|
||||
@ -2042,7 +2042,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 144:
|
||||
YY_RULE_SETUP
|
||||
#line 349 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 349 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{
|
||||
yytext[strlen(yytext)-1] = 0; // nuke colon
|
||||
UnEscapeLexed(yytext);
|
||||
@ -2052,7 +2052,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 145:
|
||||
YY_RULE_SETUP
|
||||
#line 355 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 355 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{
|
||||
yytext[strlen(yytext)-2] = 0; // nuke colon, end quote
|
||||
UnEscapeLexed(yytext+1);
|
||||
@ -2062,7 +2062,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 146:
|
||||
YY_RULE_SETUP
|
||||
#line 362 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 362 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ // Note that we cannot unescape a string constant here! The
|
||||
// string constant might contain a \00 which would not be
|
||||
// understood by the string stuff. It is valid to make a
|
||||
@ -2075,12 +2075,12 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 147:
|
||||
YY_RULE_SETUP
|
||||
#line 373 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 373 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ Upgradelval.UInt64Val = atoull(yytext); return EUINT64VAL; }
|
||||
YY_BREAK
|
||||
case 148:
|
||||
YY_RULE_SETUP
|
||||
#line 374 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 374 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{
|
||||
uint64_t Val = atoull(yytext+1);
|
||||
// +1: we have bigger negative range
|
||||
@ -2092,7 +2092,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 149:
|
||||
YY_RULE_SETUP
|
||||
#line 382 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 382 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{
|
||||
Upgradelval.UInt64Val = HexIntToVal(yytext+3);
|
||||
return yytext[0] == 's' ? ESINT64VAL : EUINT64VAL;
|
||||
@ -2100,7 +2100,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 150:
|
||||
YY_RULE_SETUP
|
||||
#line 387 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 387 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{
|
||||
uint64_t Val = atoull(yytext+1);
|
||||
if ((unsigned)Val != Val)
|
||||
@ -2111,7 +2111,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 151:
|
||||
YY_RULE_SETUP
|
||||
#line 394 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 394 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{
|
||||
uint64_t Val = atoull(yytext+2);
|
||||
// +1: we have bigger negative range
|
||||
@ -2123,16 +2123,16 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 152:
|
||||
YY_RULE_SETUP
|
||||
#line 403 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 403 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ Upgradelval.FPVal = atof(yytext); return FPVAL; }
|
||||
YY_BREAK
|
||||
case 153:
|
||||
YY_RULE_SETUP
|
||||
#line 404 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 404 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ Upgradelval.FPVal = HexToFP(yytext); return FPVAL; }
|
||||
YY_BREAK
|
||||
case YY_STATE_EOF(INITIAL):
|
||||
#line 406 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 406 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{
|
||||
/* Make sure to free the internal buffers for flex when we are
|
||||
* done reading our input!
|
||||
@ -2143,17 +2143,17 @@ case YY_STATE_EOF(INITIAL):
|
||||
YY_BREAK
|
||||
case 154:
|
||||
YY_RULE_SETUP
|
||||
#line 414 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 414 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ /* Ignore whitespace */ }
|
||||
YY_BREAK
|
||||
case 155:
|
||||
YY_RULE_SETUP
|
||||
#line 415 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 415 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
{ return yytext[0]; }
|
||||
YY_BREAK
|
||||
case 156:
|
||||
YY_RULE_SETUP
|
||||
#line 417 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 417 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
YY_FATAL_ERROR( "flex scanner jammed" );
|
||||
YY_BREAK
|
||||
#line 2160 "UpgradeLexer.cpp"
|
||||
@ -3034,5 +3034,5 @@ int main()
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
#line 417 "/proj/llvm/llvm-4/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
#line 417 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeLexer.l"
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -335,7 +335,7 @@
|
||||
|
||||
|
||||
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
|
||||
#line 1435 "/proj/llvm/llvm-1/tools/llvm-upgrade/UpgradeParser.y"
|
||||
#line 1431 "/proj/llvm/llvm-3/tools/llvm-upgrade/UpgradeParser.y"
|
||||
typedef union YYSTYPE {
|
||||
llvm::Module *ModuleVal;
|
||||
llvm::Function *FunctionVal;
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "llvm/InlineAsm.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/SymbolTable.h"
|
||||
#include "llvm/ValueSymbolTable.h"
|
||||
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
@ -312,8 +312,10 @@ static Value *getExistingValue(const Type *Ty, const ValID &D) {
|
||||
LookupName = I->second;
|
||||
else
|
||||
LookupName = Name;
|
||||
SymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
|
||||
V = SymTab.lookup(Ty, LookupName);
|
||||
ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
|
||||
V = SymTab.lookup(LookupName);
|
||||
if (V && V->getType() != Ty)
|
||||
V = 0;
|
||||
}
|
||||
if (!V) {
|
||||
RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
|
||||
@ -322,9 +324,11 @@ static Value *getExistingValue(const Type *Ty, const ValID &D) {
|
||||
LookupName = I->second;
|
||||
else
|
||||
LookupName = Name;
|
||||
V = CurModule.CurrentModule->getValueSymbolTable().lookup(Ty, LookupName);
|
||||
V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName);
|
||||
if (V && V->getType() != Ty)
|
||||
V = 0;
|
||||
}
|
||||
if (V == 0)
|
||||
if (!V)
|
||||
return 0;
|
||||
|
||||
D.destroy(); // Free old strdup'd memory...
|
||||
@ -416,7 +420,7 @@ static Value *getVal(const Type *Ty, const ValID &ID) {
|
||||
// Remember where this forward reference came from. FIXME, shouldn't we try
|
||||
// to recycle these things??
|
||||
CurModule.PlaceHolderInfo.insert(
|
||||
std::make_pair(V, std::make_pair(ID, Upgradelineno-1)));
|
||||
std::make_pair(V, std::make_pair(ID, Upgradelineno)));
|
||||
|
||||
if (inFunctionScope())
|
||||
InsertValue(V, CurFun.LateResolveValues);
|
||||
@ -448,7 +452,7 @@ static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
|
||||
case ValID::NameVal: // Is it a named definition?
|
||||
Name = ID.Name;
|
||||
if (Value *N = CurFun.CurrentFunction->
|
||||
getValueSymbolTable().lookup(Type::LabelTy, Name)) {
|
||||
getValueSymbolTable().lookup(Name)) {
|
||||
if (N->getType() != Type::LabelTy)
|
||||
error("Name '" + Name + "' does not refer to a BasicBlock");
|
||||
BB = cast<BasicBlock>(N);
|
||||
@ -682,16 +686,8 @@ static void setValueName(Value *V, char *NameStr) {
|
||||
assert(inFunctionScope() && "Must be in function scope");
|
||||
|
||||
// Search the function's symbol table for an existing value of this name
|
||||
Value* Existing = 0;
|
||||
SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
|
||||
SymbolTable::plane_const_iterator PI = ST.plane_begin(), PE =ST.plane_end();
|
||||
for ( ; PI != PE; ++PI) {
|
||||
SymbolTable::value_const_iterator VI = PI->second.find(Name);
|
||||
if (VI != PI->second.end()) {
|
||||
Existing = VI->second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
|
||||
Value* Existing = ST.lookup(Name);
|
||||
if (Existing) {
|
||||
// An existing value of the same name was found. This might have happened
|
||||
// because of the integer type planes collapsing in LLVM 2.0.
|
||||
@ -2561,27 +2557,27 @@ FunctionHeaderH
|
||||
if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
|
||||
error("LLVM functions cannot return aggregate types");
|
||||
|
||||
std::vector<const Type*> ParamTypeList;
|
||||
std::vector<const Type*> ParamTyList;
|
||||
|
||||
// In LLVM 2.0 the signatures of three varargs intrinsics changed to take
|
||||
// i8*. We check here for those names and override the parameter list
|
||||
// types to ensure the prototype is correct.
|
||||
if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
|
||||
ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
|
||||
ParamTyList.push_back(PointerType::get(Type::Int8Ty));
|
||||
} else if (FunctionName == "llvm.va_copy") {
|
||||
ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
|
||||
ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
|
||||
ParamTyList.push_back(PointerType::get(Type::Int8Ty));
|
||||
ParamTyList.push_back(PointerType::get(Type::Int8Ty));
|
||||
} else if ($5) { // If there are arguments...
|
||||
for (std::vector<std::pair<PATypeInfo,char*> >::iterator
|
||||
I = $5->begin(), E = $5->end(); I != E; ++I) {
|
||||
const Type *Ty = I->first.T->get();
|
||||
ParamTypeList.push_back(Ty);
|
||||
ParamTyList.push_back(Ty);
|
||||
}
|
||||
}
|
||||
|
||||
bool isVarArg =
|
||||
ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
|
||||
if (isVarArg) ParamTypeList.pop_back();
|
||||
bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy;
|
||||
if (isVarArg)
|
||||
ParamTyList.pop_back();
|
||||
|
||||
// Convert the CSRet calling convention into the corresponding parameter
|
||||
// attribute.
|
||||
@ -2591,7 +2587,7 @@ FunctionHeaderH
|
||||
ParamAttrs.push_back(FunctionType::StructRetAttribute); // first arg
|
||||
}
|
||||
|
||||
const FunctionType *FT = FunctionType::get(RetTy, ParamTypeList, isVarArg,
|
||||
const FunctionType *FT = FunctionType::get(RetTy, ParamTyList, isVarArg,
|
||||
ParamAttrs);
|
||||
const PointerType *PFT = PointerType::get(FT);
|
||||
delete $2.T;
|
||||
@ -2612,18 +2608,37 @@ FunctionHeaderH
|
||||
CurModule.CurrentModule->getFunctionList().remove(Fn);
|
||||
CurModule.CurrentModule->getFunctionList().push_back(Fn);
|
||||
} else if (!FunctionName.empty() && // Merge with an earlier prototype?
|
||||
(Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
|
||||
// If this is the case, either we need to be a forward decl, or it needs
|
||||
// to be.
|
||||
if (!CurFun.isDeclare && !Fn->isDeclaration())
|
||||
error("Redefinition of function '" + FunctionName + "'");
|
||||
(Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
|
||||
if (Fn->getFunctionType() != FT ) {
|
||||
// The existing function doesn't have the same type. Previously this was
|
||||
// permitted because the symbol tables had "type planes" and names were
|
||||
// distinct within a type plane. After PR411 was fixed, this is no
|
||||
// longer the case. To resolve this we must rename this function.
|
||||
// However, renaming it can cause problems if its linkage is external
|
||||
// because it could cause a link failure. We warn about this.
|
||||
std::string NewName = makeNameUnique(FunctionName);
|
||||
warning("Renaming function '" + FunctionName + "' as '" + NewName +
|
||||
"' may cause linkage errors");
|
||||
|
||||
Fn = new Function(FT, GlobalValue::ExternalLinkage, NewName,
|
||||
CurModule.CurrentModule);
|
||||
InsertValue(Fn, CurModule.Values);
|
||||
RenameMapKey Key = std::make_pair(FunctionName,PFT);
|
||||
CurModule.RenameMap[Key] = NewName;
|
||||
} else {
|
||||
// The types are the same. Either the existing or the current function
|
||||
// needs to be a forward declaration. If not, they're attempting to
|
||||
// redefine a function.
|
||||
if (!CurFun.isDeclare && !Fn->isDeclaration())
|
||||
error("Redefinition of function '" + FunctionName + "'");
|
||||
|
||||
// Make sure to strip off any argument names so we can't get conflicts.
|
||||
if (Fn->isDeclaration())
|
||||
for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
|
||||
AI != AE; ++AI)
|
||||
AI->setName("");
|
||||
} else { // Not already defined?
|
||||
// Make sure to strip off any argument names so we can't get conflicts.
|
||||
if (Fn->isDeclaration())
|
||||
for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
|
||||
AI != AE; ++AI)
|
||||
AI->setName("");
|
||||
}
|
||||
} else { // Not already defined?
|
||||
Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
|
||||
CurModule.CurrentModule);
|
||||
|
||||
@ -2654,8 +2669,10 @@ FunctionHeaderH
|
||||
$5->pop_back(); // Delete the last entry
|
||||
}
|
||||
Function::arg_iterator ArgIt = Fn->arg_begin();
|
||||
for (std::vector<std::pair<PATypeInfo,char*> >::iterator
|
||||
I = $5->begin(), E = $5->end(); I != E; ++I, ++ArgIt) {
|
||||
Function::arg_iterator ArgEnd = Fn->arg_end();
|
||||
std::vector<std::pair<PATypeInfo,char*> >::iterator I = $5->begin();
|
||||
std::vector<std::pair<PATypeInfo,char*> >::iterator E = $5->end();
|
||||
for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) {
|
||||
delete I->first.T; // Delete the typeholder...
|
||||
setValueName(ArgIt, I->second); // Insert arg into symtab...
|
||||
InsertValue(ArgIt);
|
||||
|
@ -17,7 +17,7 @@
|
||||
#include "llvm/InlineAsm.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/SymbolTable.h"
|
||||
#include "llvm/ValueSymbolTable.h"
|
||||
#include "llvm/Support/GetElementPtrTypeIterator.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
#include "llvm/Support/MathExtras.h"
|
||||
@ -312,8 +312,10 @@ static Value *getExistingValue(const Type *Ty, const ValID &D) {
|
||||
LookupName = I->second;
|
||||
else
|
||||
LookupName = Name;
|
||||
SymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
|
||||
V = SymTab.lookup(Ty, LookupName);
|
||||
ValueSymbolTable &SymTab = CurFun.CurrentFunction->getValueSymbolTable();
|
||||
V = SymTab.lookup(LookupName);
|
||||
if (V && V->getType() != Ty)
|
||||
V = 0;
|
||||
}
|
||||
if (!V) {
|
||||
RenameMapType::const_iterator I = CurModule.RenameMap.find(Key);
|
||||
@ -322,9 +324,11 @@ static Value *getExistingValue(const Type *Ty, const ValID &D) {
|
||||
LookupName = I->second;
|
||||
else
|
||||
LookupName = Name;
|
||||
V = CurModule.CurrentModule->getValueSymbolTable().lookup(Ty, LookupName);
|
||||
V = CurModule.CurrentModule->getValueSymbolTable().lookup(LookupName);
|
||||
if (V && V->getType() != Ty)
|
||||
V = 0;
|
||||
}
|
||||
if (V == 0)
|
||||
if (!V)
|
||||
return 0;
|
||||
|
||||
D.destroy(); // Free old strdup'd memory...
|
||||
@ -416,7 +420,7 @@ static Value *getVal(const Type *Ty, const ValID &ID) {
|
||||
// Remember where this forward reference came from. FIXME, shouldn't we try
|
||||
// to recycle these things??
|
||||
CurModule.PlaceHolderInfo.insert(
|
||||
std::make_pair(V, std::make_pair(ID, Upgradelineno-1)));
|
||||
std::make_pair(V, std::make_pair(ID, Upgradelineno)));
|
||||
|
||||
if (inFunctionScope())
|
||||
InsertValue(V, CurFun.LateResolveValues);
|
||||
@ -448,7 +452,7 @@ static BasicBlock *getBBVal(const ValID &ID, bool isDefinition = false) {
|
||||
case ValID::NameVal: // Is it a named definition?
|
||||
Name = ID.Name;
|
||||
if (Value *N = CurFun.CurrentFunction->
|
||||
getValueSymbolTable().lookup(Type::LabelTy, Name)) {
|
||||
getValueSymbolTable().lookup(Name)) {
|
||||
if (N->getType() != Type::LabelTy)
|
||||
error("Name '" + Name + "' does not refer to a BasicBlock");
|
||||
BB = cast<BasicBlock>(N);
|
||||
@ -682,16 +686,8 @@ static void setValueName(Value *V, char *NameStr) {
|
||||
assert(inFunctionScope() && "Must be in function scope");
|
||||
|
||||
// Search the function's symbol table for an existing value of this name
|
||||
Value* Existing = 0;
|
||||
SymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
|
||||
SymbolTable::plane_const_iterator PI = ST.plane_begin(), PE =ST.plane_end();
|
||||
for ( ; PI != PE; ++PI) {
|
||||
SymbolTable::value_const_iterator VI = PI->second.find(Name);
|
||||
if (VI != PI->second.end()) {
|
||||
Existing = VI->second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
ValueSymbolTable &ST = CurFun.CurrentFunction->getValueSymbolTable();
|
||||
Value* Existing = ST.lookup(Name);
|
||||
if (Existing) {
|
||||
// An existing value of the same name was found. This might have happened
|
||||
// because of the integer type planes collapsing in LLVM 2.0.
|
||||
@ -2561,27 +2557,27 @@ FunctionHeaderH
|
||||
if (!RetTy->isFirstClassType() && RetTy != Type::VoidTy)
|
||||
error("LLVM functions cannot return aggregate types");
|
||||
|
||||
std::vector<const Type*> ParamTypeList;
|
||||
std::vector<const Type*> ParamTyList;
|
||||
|
||||
// In LLVM 2.0 the signatures of three varargs intrinsics changed to take
|
||||
// i8*. We check here for those names and override the parameter list
|
||||
// types to ensure the prototype is correct.
|
||||
if (FunctionName == "llvm.va_start" || FunctionName == "llvm.va_end") {
|
||||
ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
|
||||
ParamTyList.push_back(PointerType::get(Type::Int8Ty));
|
||||
} else if (FunctionName == "llvm.va_copy") {
|
||||
ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
|
||||
ParamTypeList.push_back(PointerType::get(Type::Int8Ty));
|
||||
ParamTyList.push_back(PointerType::get(Type::Int8Ty));
|
||||
ParamTyList.push_back(PointerType::get(Type::Int8Ty));
|
||||
} else if ($5) { // If there are arguments...
|
||||
for (std::vector<std::pair<PATypeInfo,char*> >::iterator
|
||||
I = $5->begin(), E = $5->end(); I != E; ++I) {
|
||||
const Type *Ty = I->first.T->get();
|
||||
ParamTypeList.push_back(Ty);
|
||||
ParamTyList.push_back(Ty);
|
||||
}
|
||||
}
|
||||
|
||||
bool isVarArg =
|
||||
ParamTypeList.size() && ParamTypeList.back() == Type::VoidTy;
|
||||
if (isVarArg) ParamTypeList.pop_back();
|
||||
bool isVarArg = ParamTyList.size() && ParamTyList.back() == Type::VoidTy;
|
||||
if (isVarArg)
|
||||
ParamTyList.pop_back();
|
||||
|
||||
// Convert the CSRet calling convention into the corresponding parameter
|
||||
// attribute.
|
||||
@ -2591,7 +2587,7 @@ FunctionHeaderH
|
||||
ParamAttrs.push_back(FunctionType::StructRetAttribute); // first arg
|
||||
}
|
||||
|
||||
const FunctionType *FT = FunctionType::get(RetTy, ParamTypeList, isVarArg,
|
||||
const FunctionType *FT = FunctionType::get(RetTy, ParamTyList, isVarArg,
|
||||
ParamAttrs);
|
||||
const PointerType *PFT = PointerType::get(FT);
|
||||
delete $2.T;
|
||||
@ -2612,18 +2608,37 @@ FunctionHeaderH
|
||||
CurModule.CurrentModule->getFunctionList().remove(Fn);
|
||||
CurModule.CurrentModule->getFunctionList().push_back(Fn);
|
||||
} else if (!FunctionName.empty() && // Merge with an earlier prototype?
|
||||
(Fn = CurModule.CurrentModule->getFunction(FunctionName, FT))) {
|
||||
// If this is the case, either we need to be a forward decl, or it needs
|
||||
// to be.
|
||||
if (!CurFun.isDeclare && !Fn->isDeclaration())
|
||||
error("Redefinition of function '" + FunctionName + "'");
|
||||
(Fn = CurModule.CurrentModule->getFunction(FunctionName))) {
|
||||
if (Fn->getFunctionType() != FT ) {
|
||||
// The existing function doesn't have the same type. Previously this was
|
||||
// permitted because the symbol tables had "type planes" and names were
|
||||
// distinct within a type plane. After PR411 was fixed, this is no
|
||||
// longer the case. To resolve this we must rename this function.
|
||||
// However, renaming it can cause problems if its linkage is external
|
||||
// because it could cause a link failure. We warn about this.
|
||||
std::string NewName = makeNameUnique(FunctionName);
|
||||
warning("Renaming function '" + FunctionName + "' as '" + NewName +
|
||||
"' may cause linkage errors");
|
||||
|
||||
Fn = new Function(FT, GlobalValue::ExternalLinkage, NewName,
|
||||
CurModule.CurrentModule);
|
||||
InsertValue(Fn, CurModule.Values);
|
||||
RenameMapKey Key = std::make_pair(FunctionName,PFT);
|
||||
CurModule.RenameMap[Key] = NewName;
|
||||
} else {
|
||||
// The types are the same. Either the existing or the current function
|
||||
// needs to be a forward declaration. If not, they're attempting to
|
||||
// redefine a function.
|
||||
if (!CurFun.isDeclare && !Fn->isDeclaration())
|
||||
error("Redefinition of function '" + FunctionName + "'");
|
||||
|
||||
// Make sure to strip off any argument names so we can't get conflicts.
|
||||
if (Fn->isDeclaration())
|
||||
for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
|
||||
AI != AE; ++AI)
|
||||
AI->setName("");
|
||||
} else { // Not already defined?
|
||||
// Make sure to strip off any argument names so we can't get conflicts.
|
||||
if (Fn->isDeclaration())
|
||||
for (Function::arg_iterator AI = Fn->arg_begin(), AE = Fn->arg_end();
|
||||
AI != AE; ++AI)
|
||||
AI->setName("");
|
||||
}
|
||||
} else { // Not already defined?
|
||||
Fn = new Function(FT, GlobalValue::ExternalLinkage, FunctionName,
|
||||
CurModule.CurrentModule);
|
||||
|
||||
@ -2654,8 +2669,10 @@ FunctionHeaderH
|
||||
$5->pop_back(); // Delete the last entry
|
||||
}
|
||||
Function::arg_iterator ArgIt = Fn->arg_begin();
|
||||
for (std::vector<std::pair<PATypeInfo,char*> >::iterator
|
||||
I = $5->begin(), E = $5->end(); I != E; ++I, ++ArgIt) {
|
||||
Function::arg_iterator ArgEnd = Fn->arg_end();
|
||||
std::vector<std::pair<PATypeInfo,char*> >::iterator I = $5->begin();
|
||||
std::vector<std::pair<PATypeInfo,char*> >::iterator E = $5->end();
|
||||
for ( ; I != E && ArgIt != ArgEnd; ++I, ++ArgIt) {
|
||||
delete I->first.T; // Delete the typeholder...
|
||||
setValueName(ArgIt, I->second); // Insert arg into symtab...
|
||||
InsertValue(ArgIt);
|
||||
|
@ -19,7 +19,6 @@
|
||||
#include "llvm/Instruction.h"
|
||||
#include "llvm/Instructions.h"
|
||||
#include "llvm/Module.h"
|
||||
#include "llvm/SymbolTable.h"
|
||||
#include "llvm/TypeSymbolTable.h"
|
||||
#include "llvm/ADT/StringExtras.h"
|
||||
#include "llvm/ADT/STLExtras.h"
|
||||
|
@ -17,7 +17,6 @@
|
||||
#include "llvm/Linker.h"
|
||||
#include "llvm/Constants.h"
|
||||
#include "llvm/DerivedTypes.h"
|
||||
#include "llvm/SymbolTable.h"
|
||||
#include "llvm/Bytecode/Reader.h"
|
||||
#include "llvm/Bytecode/Writer.h"
|
||||
#include "llvm/Support/CommandLine.h"
|
||||
@ -248,12 +247,6 @@ LTO::optimize(Module *M, std::ostream &Out,
|
||||
// Add an appropriate TargetData instance for this module...
|
||||
Passes.add(new TargetData(*Target->getTargetData()));
|
||||
|
||||
// Often if the programmer does not specify proper prototypes for the
|
||||
// functions they are calling, they end up calling a vararg version of the
|
||||
// function that does not get a body filled in (the real function has typed
|
||||
// arguments). This pass merges the two functions.
|
||||
Passes.add(createFunctionResolvingPass());
|
||||
|
||||
// Internalize symbols if export list is nonemty
|
||||
if (!exportList.empty())
|
||||
Passes.add(createInternalizePass(exportList));
|
||||
|
@ -178,7 +178,6 @@ void AddStandardCompilePasses(PassManager &PM) {
|
||||
PM.add(createVerifierPass()); // Verify that input is correct
|
||||
|
||||
addPass(PM, createLowerSetJmpPass()); // Lower llvm.setjmp/.longjmp
|
||||
addPass(PM, createFunctionResolvingPass()); // Resolve (...) functions
|
||||
|
||||
// If the -strip-debug command line option was specified, do it.
|
||||
if (StripDebug)
|
||||
|
Loading…
Reference in New Issue
Block a user