OLD | NEW |
1 //===- subzero/src/PNaClTranslator.cpp - ICE from bitcode -----------------===// | 1 //===- subzero/src/PNaClTranslator.cpp - ICE from bitcode -----------------===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // This file implements the PNaCl bitcode file to Ice, to machine code | 10 // This file implements the PNaCl bitcode file to Ice, to machine code |
(...skipping 1869 matching lines...) Loading... |
1880 default: | 1880 default: |
1881 break; | 1881 break; |
1882 } | 1882 } |
1883 return BlockParserBaseClass::ParseBlock(BlockID); | 1883 return BlockParserBaseClass::ParseBlock(BlockID); |
1884 } | 1884 } |
1885 | 1885 |
1886 /// Parses the module block in the bitcode file. | 1886 /// Parses the module block in the bitcode file. |
1887 class ModuleParser : public BlockParserBaseClass { | 1887 class ModuleParser : public BlockParserBaseClass { |
1888 public: | 1888 public: |
1889 ModuleParser(unsigned BlockID, TopLevelParser *Context) | 1889 ModuleParser(unsigned BlockID, TopLevelParser *Context) |
1890 : BlockParserBaseClass(BlockID, Context) {} | 1890 : BlockParserBaseClass(BlockID, Context), FoundFirstFunctionBlock(false) { |
| 1891 } |
1891 | 1892 |
1892 virtual ~ModuleParser() LLVM_OVERRIDE {} | 1893 virtual ~ModuleParser() LLVM_OVERRIDE {} |
1893 | 1894 |
1894 protected: | 1895 private: |
| 1896 // True if we have parsed a function block. |
| 1897 bool FoundFirstFunctionBlock; |
1895 virtual bool ParseBlock(unsigned BlockID) LLVM_OVERRIDE; | 1898 virtual bool ParseBlock(unsigned BlockID) LLVM_OVERRIDE; |
1896 | 1899 |
1897 virtual void ProcessRecord() LLVM_OVERRIDE; | 1900 virtual void ProcessRecord() LLVM_OVERRIDE; |
1898 }; | 1901 }; |
1899 | 1902 |
1900 class ModuleValuesymtabParser : public ValuesymtabParser { | 1903 class ModuleValuesymtabParser : public ValuesymtabParser { |
1901 ModuleValuesymtabParser(const ModuleValuesymtabParser &) | 1904 ModuleValuesymtabParser(const ModuleValuesymtabParser &) |
1902 LLVM_DELETED_FUNCTION; | 1905 LLVM_DELETED_FUNCTION; |
1903 void operator=(const ModuleValuesymtabParser &) LLVM_DELETED_FUNCTION; | 1906 void operator=(const ModuleValuesymtabParser &) LLVM_DELETED_FUNCTION; |
1904 | 1907 |
(...skipping 38 matching lines...) Loading... |
1943 } | 1946 } |
1944 case naclbitc::GLOBALVAR_BLOCK_ID: { | 1947 case naclbitc::GLOBALVAR_BLOCK_ID: { |
1945 GlobalsParser Parser(BlockID, this); | 1948 GlobalsParser Parser(BlockID, this); |
1946 return Parser.ParseThisBlock(); | 1949 return Parser.ParseThisBlock(); |
1947 } | 1950 } |
1948 case naclbitc::VALUE_SYMTAB_BLOCK_ID: { | 1951 case naclbitc::VALUE_SYMTAB_BLOCK_ID: { |
1949 ModuleValuesymtabParser Parser(BlockID, this); | 1952 ModuleValuesymtabParser Parser(BlockID, this); |
1950 return Parser.ParseThisBlock(); | 1953 return Parser.ParseThisBlock(); |
1951 } | 1954 } |
1952 case naclbitc::FUNCTION_BLOCK_ID: { | 1955 case naclbitc::FUNCTION_BLOCK_ID: { |
| 1956 if (!FoundFirstFunctionBlock) { |
| 1957 getTranslator().nameUnnamedGlobalAddresses(Context->getModule()); |
| 1958 FoundFirstFunctionBlock = true; |
| 1959 } |
1953 FunctionParser Parser(BlockID, this); | 1960 FunctionParser Parser(BlockID, this); |
1954 return Parser.ParseThisBlock(); | 1961 return Parser.ParseThisBlock(); |
1955 } | 1962 } |
1956 default: | 1963 default: |
1957 return BlockParserBaseClass::ParseBlock(BlockID); | 1964 return BlockParserBaseClass::ParseBlock(BlockID); |
1958 } | 1965 } |
1959 } | 1966 } |
1960 | 1967 |
1961 void ModuleParser::ProcessRecord() { | 1968 void ModuleParser::ProcessRecord() { |
1962 const NaClBitcodeRecord::RecordVector &Values = Record.GetValues(); | 1969 const NaClBitcodeRecord::RecordVector &Values = Record.GetValues(); |
(...skipping 114 matching lines...) Loading... |
2077 if (TopLevelBlocks != 1) { | 2084 if (TopLevelBlocks != 1) { |
2078 errs() << IRFilename | 2085 errs() << IRFilename |
2079 << ": Contains more than one module. Found: " << TopLevelBlocks | 2086 << ": Contains more than one module. Found: " << TopLevelBlocks |
2080 << "\n"; | 2087 << "\n"; |
2081 ErrorStatus = true; | 2088 ErrorStatus = true; |
2082 } | 2089 } |
2083 return; | 2090 return; |
2084 } | 2091 } |
2085 | 2092 |
2086 } // end of namespace Ice | 2093 } // end of namespace Ice |
OLD | NEW |