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

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: rebase 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') | no next file with comments »
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 47f8b39aba1c427875b301d555424095760eb287..5316db6a07935fd89372dcc2112172ed0576a8db 100644
--- a/src/IceConverter.cpp
+++ b/src/IceConverter.cpp
@@ -121,9 +121,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
+ report_fatal_error("Unhandled GlobalDeclaration type");
+ 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') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698