1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 20:51:52 +01:00

[IR] Upgrade comment token in objc retain release marker for asm call

Older compiler issued '#' instead of ';'

llvm-svn: 330173
This commit is contained in:
Gerolf Hoflehner 2018-04-17 04:02:24 +00:00
parent 3cf02eb4eb
commit 9f57c649e7
5 changed files with 28 additions and 0 deletions

View File

@ -37,6 +37,10 @@ namespace llvm {
/// intrinsic function with a call to the specified new function.
void UpgradeIntrinsicCall(CallInst *CI, Function *NewFn);
// This upgrades the comment for objc retain release markers in inline asm
// calls
void UpgradeInlineAsmString(std::string *AsmStr);
/// This is an auto-upgrade hook for any old intrinsic function syntaxes
/// which need to have both the function updated as well as all calls updated
/// to the new function. This should only be run in a post-processing fashion

View File

@ -2522,6 +2522,7 @@ Error BitcodeReader::parseConstants() {
for (unsigned i = 0; i != ConstStrSize; ++i)
ConstrStr += (char)Record[3+AsmStrSize+i];
PointerType *PTy = cast<PointerType>(CurTy);
UpgradeInlineAsmString(&AsmStr);
V = InlineAsm::get(cast<FunctionType>(PTy->getElementType()),
AsmStr, ConstrStr, HasSideEffects, IsAlignStack);
break;
@ -2547,6 +2548,7 @@ Error BitcodeReader::parseConstants() {
for (unsigned i = 0; i != ConstStrSize; ++i)
ConstrStr += (char)Record[3+AsmStrSize+i];
PointerType *PTy = cast<PointerType>(CurTy);
UpgradeInlineAsmString(&AsmStr);
V = InlineAsm::get(cast<FunctionType>(PTy->getElementType()),
AsmStr, ConstrStr, HasSideEffects, IsAlignStack,
InlineAsm::AsmDialect(AsmDialect));

View File

@ -1169,6 +1169,19 @@ static bool upgradeAVX512MaskToSelect(StringRef Name, IRBuilder<> &Builder,
return true;
}
/// Upgrade comment in call to inline asm that represents an objc retain release
/// marker.
void llvm::UpgradeInlineAsmString(std::string *AsmStr) {
unsigned long Pos;
if (AsmStr->find("mov\tfp") == 0 &&
AsmStr->find("objc_retainAutoreleaseReturnValue") != std::string::npos &&
(Pos = AsmStr->find("# marker")) != std::string::npos) {
AsmStr->replace(Pos, 1, ";");
}
return;
}
/// Upgrade a call to an old intrinsic. All argument and return casting must be
/// provided to seamlessly integrate with existing context.
void llvm::UpgradeIntrinsicCall(CallInst *CI, Function *NewFn) {

View File

@ -0,0 +1,9 @@
; Test that comment token for objc retain release is upgraded from '#' to ';'
;
; RUN: llvm-dis < %s.bc | FileCheck %s
define void @inlineasm() {
call void asm sideeffect "mov\09fp, fp\09\09# marker for objc_retainAutoreleaseReturnValue", ""()
;CHECK: call void asm sideeffect "mov\09fp, fp\09\09; marker for objc_retainAutoreleaseReturnValue", ""()
ret void
}

Binary file not shown.