Chromium Code Reviews| 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) |