Subzero: Fix symbol name mangling. Make flags global.
This cleans up the whole --prefix handling mechanism, so that all mangling is done based on logic in the parser instead of scattered all over the code base. Another nice side effect is that it allows some getName() style functions to return a const string reference instead of a string copy.
Also, moves ClFlags into a static field of GlobalContext, i.e. makes it global, so that these constant flags can be accessed without having to plumb a GlobalContext object. Note that some of the ClFlags and ClFlagsExtra plumbing in the compile server classes could be simplified to directly use the corresponding static fields, but this is left mostly as is for now, for when we do a proper separation between core and supplemental flags.
BUG= none
R=jpp@chromium.org
Review URL: https://codereview.chromium.org/1766233002 .
diff --git a/src/IceConverter.cpp b/src/IceConverter.cpp
index 3871289..e69fd7a 100644
--- a/src/IceConverter.cpp
+++ b/src/IceConverter.cpp
@@ -21,6 +21,7 @@
#include "IceGlobalContext.h"
#include "IceGlobalInits.h"
#include "IceInst.h"
+#include "IceMangling.h"
#include "IceOperand.h"
#include "IceTargetLowering.h"
#include "IceTypes.h"
@@ -101,7 +102,7 @@
VarMap.clear();
NodeMap.clear();
- Func->setFunctionName(F->getName());
+ Func->setFunctionName(Ice::mangleName(F->getName()));
Func->setReturnType(convertToIceType(F->getReturnType()));
Func->setInternal(F->hasInternalLinkage());
Ice::TimerMarker T(Ice::TimerStack::TT_llvmConvert, Func.get());
@@ -141,8 +142,7 @@
return Ctx->getConstantExternSym(Decl->getName());
else {
const Ice::RelocOffsetT Offset = 0;
- return Ctx->getConstantSym(Offset, Decl->getName(),
- Decl->getSuppressMangling());
+ return Ctx->getConstantSym(Offset, Decl->getName());
}
} else if (const auto CI = dyn_cast<ConstantInt>(Const)) {
Ice::Type Ty = convertToIceType(CI->getType());
@@ -889,11 +889,12 @@
E = Mod->global_end();
I != E; ++I) {
const GlobalVariable *GV = I;
- auto *Var = VariableDeclaration::create(Ctx);
- Var->setName(GV->getName());
+ constexpr bool NoSuppressMangling = false;
+ auto *Var =
+ VariableDeclaration::create(Ctx, NoSuppressMangling, GV->getLinkage());
Var->setAlignment(GV->getAlignment());
Var->setIsConstant(GV->isConstant());
- Var->setLinkage(GV->getLinkage());
+ Var->setName(GV->getName());
if (!Var->verifyLinkageCorrect(Ctx)) {
std::string Buffer;
raw_string_ostream StrBuf(Buffer);