#include "llvm/IR/DataLayout.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
+#include "llvm/IR/Module.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
}
void Mangler::getNameWithPrefix(raw_ostream &OS, const Twine &GVName,
- ManglerPrefixTy PrefixTy) const {
- char Prefix = DL->getGlobalPrefix();
- return getNameWithPrefixImpl(OS, GVName, PrefixTy, *DL, Prefix);
-}
-
-void Mangler::getNameWithPrefix(SmallVectorImpl<char> &OutName,
- const Twine &GVName, const DataLayout &DL) {
- raw_svector_ostream OS(OutName);
+ const DataLayout &DL,
+ ManglerPrefixTy PrefixTy) {
char Prefix = DL.getGlobalPrefix();
- return getNameWithPrefixImpl(OS, GVName, Mangler::Default, DL, Prefix);
+ return getNameWithPrefixImpl(OS, GVName, PrefixTy, DL, Prefix);
}
void Mangler::getNameWithPrefix(SmallVectorImpl<char> &OutName,
- const Twine &GVName,
- ManglerPrefixTy PrefixTy) const {
+ const Twine &GVName, const DataLayout &DL,
+ ManglerPrefixTy PrefixTy) {
raw_svector_ostream OS(OutName);
- char Prefix = DL->getGlobalPrefix();
- return getNameWithPrefixImpl(OS, GVName, PrefixTy, *DL, Prefix);
+ char Prefix = DL.getGlobalPrefix();
+ return getNameWithPrefixImpl(OS, GVName, PrefixTy, DL, Prefix);
}
static bool hasByteCountSuffix(CallingConv::ID CC) {
PrefixTy = Mangler::Private;
}
+ const DataLayout &DL = GV->getParent()->getDataLayout();
if (!GV->hasName()) {
// Get the ID for the global, assigning a new one if we haven't got one
// already.
ID = NextAnonGlobalID++;
// Must mangle the global into a unique ID.
- getNameWithPrefix(OS, "__unnamed_" + Twine(ID), PrefixTy);
+ getNameWithPrefix(OS, "__unnamed_" + Twine(ID), DL, PrefixTy);
return;
}
StringRef Name = GV->getName();
- char Prefix = DL->getGlobalPrefix();
+ char Prefix = DL.getGlobalPrefix();
// Mangle functions with Microsoft calling conventions specially. Only do
// this mangling for x86_64 vectorcall and 32-bit x86.
MSFunc = nullptr; // Don't mangle when \01 is present.
CallingConv::ID CC =
MSFunc ? MSFunc->getCallingConv() : (unsigned)CallingConv::C;
- if (!DL->hasMicrosoftFastStdCallMangling() &&
+ if (!DL.hasMicrosoftFastStdCallMangling() &&
CC != CallingConv::X86_VectorCall)
MSFunc = nullptr;
if (MSFunc) {
Prefix = '\0'; // vectorcall functions have no prefix.
}
- getNameWithPrefixImpl(OS, Name, PrefixTy, *DL, Prefix);
+ getNameWithPrefixImpl(OS, Name, PrefixTy, DL, Prefix);
if (!MSFunc)
return;
// "Pure" variadic functions do not receive @0 suffix.
(!FT->isVarArg() || FT->getNumParams() == 0 ||
(FT->getNumParams() == 1 && MSFunc->hasStructRetAttr())))
- addByteCountSuffix(OS, MSFunc, *DL);
+ addByteCountSuffix(OS, MSFunc, DL);
}
void Mangler::getNameWithPrefix(SmallVectorImpl<char> &OutName,