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 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
277 | 277 |
278 if (isIRGenerationDisabled()) { | 278 if (isIRGenerationDisabled()) { |
279 ValueIDConstants[ID] = nullptr; | 279 ValueIDConstants[ID] = nullptr; |
280 return nullptr; | 280 return nullptr; |
281 } | 281 } |
282 | 282 |
283 // If reached, no such constant exists, create one. | 283 // If reached, no such constant exists, create one. |
284 // TODO(kschimpf) Don't get addresses of intrinsic function declarations. | 284 // TODO(kschimpf) Don't get addresses of intrinsic function declarations. |
285 Ice::GlobalDeclaration *Decl = nullptr; | 285 Ice::GlobalDeclaration *Decl = nullptr; |
286 unsigned FcnIDSize = FunctionDeclarationList.size(); | 286 unsigned FcnIDSize = FunctionDeclarationList.size(); |
| 287 bool IsUndefined = false; |
287 if (ID < FcnIDSize) { | 288 if (ID < FcnIDSize) { |
288 Decl = FunctionDeclarationList[ID]; | 289 Decl = FunctionDeclarationList[ID]; |
| 290 const auto Func = llvm::cast<Ice::FunctionDeclaration>(Decl); |
| 291 IsUndefined = Func->isProto(); |
289 } else if ((ID - FcnIDSize) < VariableDeclarations.size()) { | 292 } else if ((ID - FcnIDSize) < VariableDeclarations.size()) { |
290 Decl = VariableDeclarations[ID - FcnIDSize]; | 293 Decl = VariableDeclarations[ID - FcnIDSize]; |
| 294 const auto Var = llvm::cast<Ice::VariableDeclaration>(Decl); |
| 295 IsUndefined = !Var->hasInitializer(); |
291 } | 296 } |
292 std::string Name; | 297 std::string Name; |
293 bool SuppressMangling; | 298 bool SuppressMangling; |
294 if (Decl) { | 299 if (Decl) { |
295 Name = Decl->getName(); | 300 Name = Decl->getName(); |
296 SuppressMangling = Decl->getSuppressMangling(); | 301 SuppressMangling = Decl->getSuppressMangling(); |
297 } else { | 302 } else { |
298 std::string Buffer; | 303 std::string Buffer; |
299 raw_string_ostream StrBuf(Buffer); | 304 raw_string_ostream StrBuf(Buffer); |
300 StrBuf << "Reference to global not defined: " << ID; | 305 StrBuf << "Reference to global not defined: " << ID; |
301 BlockError(StrBuf.str()); | 306 BlockError(StrBuf.str()); |
302 // TODO(kschimpf) Remove error recovery once implementation complete. | 307 // TODO(kschimpf) Remove error recovery once implementation complete. |
303 Name = "??"; | 308 Name = "??"; |
304 SuppressMangling = false; | 309 SuppressMangling = false; |
305 } | 310 } |
306 const Ice::RelocOffsetT Offset = 0; | 311 if (IsUndefined) |
307 C = getTranslator().getContext()->getConstantSym(Offset, Name, | 312 C = getTranslator().getContext()->getConstantExternSym(Name); |
308 SuppressMangling); | 313 else { |
| 314 const Ice::RelocOffsetT Offset = 0; |
| 315 C = getTranslator().getContext()->getConstantSym(Offset, Name, |
| 316 SuppressMangling); |
| 317 } |
309 ValueIDConstants[ID] = C; | 318 ValueIDConstants[ID] = C; |
310 return C; | 319 return C; |
311 } | 320 } |
312 | 321 |
313 /// Returns the number of function declarations in the bitcode file. | 322 /// Returns the number of function declarations in the bitcode file. |
314 unsigned getNumFunctionIDs() const { return FunctionDeclarationList.size(); } | 323 unsigned getNumFunctionIDs() const { return FunctionDeclarationList.size(); } |
315 | 324 |
316 /// Returns the number of global declarations (i.e. IDs) defined in | 325 /// Returns the number of global declarations (i.e. IDs) defined in |
317 /// the bitcode file. | 326 /// the bitcode file. |
318 unsigned getNumGlobalIDs() const { | 327 unsigned getNumGlobalIDs() const { |
(...skipping 2669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2988 | 2997 |
2989 if (TopLevelBlocks != 1) { | 2998 if (TopLevelBlocks != 1) { |
2990 errs() << IRFilename | 2999 errs() << IRFilename |
2991 << ": Contains more than one module. Found: " << TopLevelBlocks | 3000 << ": Contains more than one module. Found: " << TopLevelBlocks |
2992 << "\n"; | 3001 << "\n"; |
2993 ErrorStatus.assign(EC_Bitcode); | 3002 ErrorStatus.assign(EC_Bitcode); |
2994 } | 3003 } |
2995 } | 3004 } |
2996 | 3005 |
2997 } // end of namespace Ice | 3006 } // end of namespace Ice |
OLD | NEW |