summaryrefslogtreecommitdiff
path: root/lib/IR/Mangler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/IR/Mangler.cpp')
-rw-r--r--lib/IR/Mangler.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/lib/IR/Mangler.cpp b/lib/IR/Mangler.cpp
index 03723bfd2ddb..be3086cfcf05 100644
--- a/lib/IR/Mangler.cpp
+++ b/lib/IR/Mangler.cpp
@@ -44,6 +44,9 @@ static void getNameWithPrefixImpl(raw_ostream &OS, const Twine &GVName,
return;
}
+ if (DL.doNotMangleLeadingQuestionMark() && Name[0] == '?')
+ Prefix = '\0';
+
if (PrefixTy == Private)
OS << DL.getPrivateGlobalPrefix();
else if (PrefixTy == LinkerPrivate)
@@ -135,8 +138,13 @@ void Mangler::getNameWithPrefix(raw_ostream &OS, const GlobalValue *GV,
// Mangle functions with Microsoft calling conventions specially. Only do
// this mangling for x86_64 vectorcall and 32-bit x86.
const Function *MSFunc = dyn_cast<Function>(GV);
- if (Name.startswith("\01"))
- MSFunc = nullptr; // Don't mangle when \01 is present.
+
+ // Don't add byte count suffixes when '\01' or '?' are in the first
+ // character.
+ if (Name.startswith("\01") ||
+ (DL.doNotMangleLeadingQuestionMark() && Name.startswith("?")))
+ MSFunc = nullptr;
+
CallingConv::ID CC =
MSFunc ? MSFunc->getCallingConv() : (unsigned)CallingConv::C;
if (!DL.hasMicrosoftFastStdCallMangling() &&
@@ -204,3 +212,13 @@ void llvm::emitLinkerFlagsForGlobalCOFF(raw_ostream &OS, const GlobalValue *GV,
OS << ",data";
}
}
+
+void llvm::emitLinkerFlagsForUsedCOFF(raw_ostream &OS, const GlobalValue *GV,
+ const Triple &T, Mangler &M) {
+ if (!T.isKnownWindowsMSVCEnvironment())
+ return;
+
+ OS << " /INCLUDE:";
+ M.getNameWithPrefix(OS, GV, false);
+}
+