Chromium Code Reviews| Index: src/IceConverter.cpp |
| diff --git a/src/IceConverter.cpp b/src/IceConverter.cpp |
| index e8ec56d18112f49120c12f10a94a10d321acf8fc..260ab40fc0f93b50e79051ccb0538cae1b41ffc4 100644 |
| --- a/src/IceConverter.cpp |
| +++ b/src/IceConverter.cpp |
| @@ -115,9 +115,20 @@ public: |
| Ice::Constant *convertConstant(const Constant *Const) { |
| if (const auto GV = dyn_cast<GlobalValue>(Const)) { |
| Ice::GlobalDeclaration *Decl = getConverter().getGlobalDeclaration(GV); |
| - const Ice::RelocOffsetT Offset = 0; |
| - return Ctx->getConstantSym(Offset, Decl->getName(), |
| - Decl->getSuppressMangling()); |
| + bool IsUndefined = false; |
| + if (const auto *Func = llvm::dyn_cast<Ice::FunctionDeclaration>(Decl)) |
| + IsUndefined = Func->isProto(); |
| + else if (const auto *Var = llvm::dyn_cast<Ice::VariableDeclaration>(Decl)) |
| + IsUndefined = !Var->hasInitializer(); |
| + else |
| + llvm_unreachable("Unhandled GlobalDeclaration type"); |
|
Jim Stichnoth
2015/02/02 21:57:26
report_fatal_error
jvoung (off chromium)
2015/02/03 01:53:38
Done.
|
| + if (IsUndefined) |
| + return Ctx->getConstantExternSym(Decl->getName()); |
| + else { |
| + const Ice::RelocOffsetT Offset = 0; |
| + return Ctx->getConstantSym(Offset, Decl->getName(), |
| + Decl->getSuppressMangling()); |
| + } |
| } else if (const auto CI = dyn_cast<ConstantInt>(Const)) { |
| Ice::Type Ty = convertToIceType(CI->getType()); |
| return Ctx->getConstantInt(Ty, CI->getSExtValue()); |