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

Unified Diff: src/IceConverter.cpp

Issue 667763002: Fix handling of relocation names, so that prefix mangling works. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nits. Created 6 years, 2 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 | « src/IceCfg.cpp ('k') | src/IceGlobalInits.h » ('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 a97cb6857008a75aa5d8cca93d3fe58256c80eff..bd6841c4e910e98b694241db4d6f60b2aedf0f46 100644
--- a/src/IceConverter.cpp
+++ b/src/IceConverter.cpp
@@ -114,8 +114,11 @@ public:
// global initializers.
Ice::Constant *convertConstant(const Constant *Const) {
if (const auto GV = dyn_cast<GlobalValue>(Const)) {
- return Ctx->getConstantSym(convertToIceType(GV->getType()), 0,
- GV->getName());
+ Ice::GlobalDeclaration *Decl = getConverter().getGlobalDeclaration(GV);
+ const Ice::RelocOffsetT Offset = 0;
+ return Ctx->getConstantSym(TypeConverter.getIcePointerType(),
+ Offset, Decl->getName(),
+ Decl->getSuppressMangling());
} else if (const auto CI = dyn_cast<ConstantInt>(Const)) {
Ice::Type Ty = convertToIceType(CI->getType());
if (Ty == Ice::IceType_i64) {
@@ -690,21 +693,30 @@ void LLVM2ICEGlobalsConverter::convertGlobalsToIce(
for (Module::const_global_iterator I = Mod->global_begin(),
E = Mod->global_end();
I != E; ++I) {
- if (!I->hasInitializer() && Ctx->getFlags().AllowUninitializedGlobals)
- continue;
const GlobalVariable *GV = I;
- Ice::IceString Name = GV->getName();
- if (!GV->hasInternalLinkage()) {
+
+ Ice::GlobalDeclaration *Var = getConverter().getGlobalDeclaration(GV);
+ Ice::VariableDeclaration* VarDecl = cast<Ice::VariableDeclaration>(Var);
+ VariableDeclarations.push_back(VarDecl);
+
+ if (!GV->hasInternalLinkage() && GV->hasInitializer()) {
std::string Buffer;
raw_string_ostream StrBuf(Buffer);
- StrBuf << "Can't define external global declaration: " << Name;
+ StrBuf << "Can't define external global declaration: " << GV->getName();
report_fatal_error(StrBuf.str());
}
- Ice::GlobalDeclaration *Var = getConverter().getGlobalDeclaration(GV);
- Ice::VariableDeclaration* VarDecl = cast<Ice::VariableDeclaration>(Var);
- VariableDeclarations.push_back(VarDecl);
+ if (!GV->hasInitializer()) {
+ if (Ctx->getFlags().AllowUninitializedGlobals)
+ continue;
+ else {
+ std::string Buffer;
+ raw_string_ostream StrBuf(Buffer);
+ StrBuf << "Global declaration missing initializer: " << GV->getName();
+ report_fatal_error(StrBuf.str());
+ }
+ }
const Constant *Initializer = GV->getInitializer();
if (const auto CompoundInit = dyn_cast<ConstantStruct>(Initializer)) {
@@ -858,9 +870,7 @@ void Converter::installGlobalDeclarations(Module *Mod) {
Var->setName(GV->getName());
Var->setAlignment(GV->getAlignment());
Var->setIsConstant(GV->isConstant());
- // Note: We allow external for cross tests.
- // TODO(kschimpf) Put behind flag AllowUninitializedGlobals.
- Var->setIsInternal(!GV->isExternallyInitialized());
+ Var->setLinkage(GV->getLinkage());
GlobalDeclarationMap[GV] = Var;
}
}
« no previous file with comments | « src/IceCfg.cpp ('k') | src/IceGlobalInits.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698