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

Unified Diff: src/IceTranslator.cpp

Issue 567703003: Allow ability to name unnamed global addresses in Subzero. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix nits. Created 6 years, 3 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/IceTranslator.h ('k') | src/PNaClTranslator.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/IceTranslator.cpp
diff --git a/src/IceTranslator.cpp b/src/IceTranslator.cpp
index 59403d284e12e9a9e3da62a0ab63236d1df15ed2..11bc48cc1bac8755ebff83076cd6cab0ff5ddd94 100644
--- a/src/IceTranslator.cpp
+++ b/src/IceTranslator.cpp
@@ -16,7 +16,9 @@
#include "IceCfg.h"
#include "IceClFlags.h"
+#include "IceDefs.h"
#include "IceTargetLowering.h"
+#include "llvm/IR/Module.h"
#include <iostream>
@@ -24,6 +26,46 @@ using namespace Ice;
Translator::~Translator() {}
+namespace {
+static inline void setValueName(llvm::Value *V, const char *Kind,
Jim Stichnoth 2014/09/12 17:20:09 Don't use static. And can you omit inline?
Karl 2014/09/12 17:41:58 Done.
+ const std::string &Prefix, uint32_t &NameIndex,
Jim Stichnoth 2014/09/12 17:20:09 IceString
Karl 2014/09/12 17:41:58 Done.
+ Ice::Ostream &errs) {
Jim Stichnoth 2014/09/12 17:20:09 Remove Ice:: everywhere in this file (or maybe bet
Karl 2014/09/12 17:41:58 Done.
+ if (V->hasName()) {
+ const std::string &Name(V->getName());
+ if (Name.find(Prefix) == 0) {
+ errs << "Warning: Default " << Kind << " prefix '" << Prefix
+ << "' conflicts with name '" << Name << "'.\n";
+ }
+ return;
+ }
Karl 2014/09/12 17:41:59 Added check if NameIndex == 0, then use prefix as
+ std::string Buffer;
+ llvm::raw_string_ostream StrBuf(Buffer);
+ StrBuf << Prefix << NameIndex;
+ V->setName(StrBuf.str());
+ ++NameIndex;
+}
+}
Jim Stichnoth 2014/09/12 17:20:09 // end of anonymous namespace
Karl 2014/09/12 17:41:59 Done.
+
+void Translator::nameUnnamedGlobalAddresses(llvm::Module *Mod) {
+ const std::string &GlobalPrefix = Flags.DefaultGlobalPrefix;
Jim Stichnoth 2014/09/12 17:20:09 IceString
Karl 2014/09/12 17:41:58 Done.
+ Ice::Ostream &errs = Ctx->getStrDump();
+ if (!GlobalPrefix.empty()) {
+ uint32_t NameIndex = 0;
+ for (llvm::Module::global_iterator I = Mod->global_begin(),
+ E = Mod->global_end();
+ I != E; ++I) {
+ setValueName(I, "global", GlobalPrefix, NameIndex, errs);
+ }
+ }
+ const std::string &FunctionPrefix = Flags.DefaultFunctionPrefix;
Jim Stichnoth 2014/09/12 17:20:09 IceString
Karl 2014/09/12 17:41:58 Done.
+ if (FunctionPrefix.empty())
+ return;
+ uint32_t NameIndex = 0;
+ for (llvm::Module::iterator I = Mod->begin(), E = Mod->end(); I != E; ++I) {
+ setValueName(I, "function", FunctionPrefix, NameIndex, errs);
+ }
+}
+
void Translator::translateFcn(Ice::Cfg *Fcn) {
Func.reset(Fcn);
if (Ctx->getFlags().DisableInternal)
« no previous file with comments | « src/IceTranslator.h ('k') | src/PNaClTranslator.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698