Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(25)

Unified Diff: src/IceConverter.cpp

Issue 899483002: Subzero: Track protos + globals w/out initializers as undef too (not just helper funcs) (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: x Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/IceELFObjectWriter.cpp » ('j') | src/IceELFObjectWriter.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « no previous file | src/IceELFObjectWriter.cpp » ('j') | src/IceELFObjectWriter.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698