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

Unified Diff: src/PNaClTranslator.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
Index: src/PNaClTranslator.cpp
diff --git a/src/PNaClTranslator.cpp b/src/PNaClTranslator.cpp
index 0c0623112e89dcf5839e4220406c07ef98edd2f7..6b6ff7ddb91c99581f3240cca8f34d18af65f504 100644
--- a/src/PNaClTranslator.cpp
+++ b/src/PNaClTranslator.cpp
@@ -284,10 +284,15 @@ public:
// TODO(kschimpf) Don't get addresses of intrinsic function declarations.
Ice::GlobalDeclaration *Decl = nullptr;
unsigned FcnIDSize = FunctionDeclarationList.size();
+ bool IsUndefined = false;
if (ID < FcnIDSize) {
Decl = FunctionDeclarationList[ID];
+ const auto Func = llvm::cast<Ice::FunctionDeclaration>(Decl);
+ IsUndefined = Func->isProto();
} else if ((ID - FcnIDSize) < VariableDeclarations.size()) {
Decl = VariableDeclarations[ID - FcnIDSize];
+ const auto Var = llvm::cast<Ice::VariableDeclaration>(Decl);
+ IsUndefined = !Var->hasInitializer();
}
std::string Name;
bool SuppressMangling;
@@ -303,9 +308,13 @@ public:
Name = "??";
SuppressMangling = false;
}
- const Ice::RelocOffsetT Offset = 0;
- C = getTranslator().getContext()->getConstantSym(Offset, Name,
- SuppressMangling);
+ if (IsUndefined)
+ C = getTranslator().getContext()->getConstantExternSym(Name);
+ else {
+ const Ice::RelocOffsetT Offset = 0;
+ C = getTranslator().getContext()->getConstantSym(Offset, Name,
+ SuppressMangling);
+ }
ValueIDConstants[ID] = C;
return C;
}

Powered by Google App Engine
This is Rietveld 408576698