summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerolf Hoflehner <ghoflehner@apple.com>2018-04-17 04:02:24 +0000
committerGerolf Hoflehner <ghoflehner@apple.com>2018-04-17 04:02:24 +0000
commit1c3a07834e9bdbde110a3ec0faaee9a40e765760 (patch)
treeac081b01ae44574ad17eb0e52dc9a67d53165bde
parent2f6d00612d62c0da948145574c396c53543e21f4 (diff)
downloadbcm5719-llvm-1c3a07834e9bdbde110a3ec0faaee9a40e765760.tar.gz
bcm5719-llvm-1c3a07834e9bdbde110a3ec0faaee9a40e765760.zip
[IR] Upgrade comment token in objc retain release marker for asm call
Older compiler issued '#' instead of ';' llvm-svn: 330173
-rw-r--r--llvm/include/llvm/IR/AutoUpgrade.h4
-rw-r--r--llvm/lib/Bitcode/Reader/BitcodeReader.cpp2
-rw-r--r--llvm/lib/IR/AutoUpgrade.cpp13
-rw-r--r--llvm/test/Bitcode/upgrade-objcretainrelease-asm.ll9
-rw-r--r--llvm/test/Bitcode/upgrade-objcretainrelease-asm.ll.bcbin0 -> 1312 bytes
5 files changed, 28 insertions, 0 deletions
diff --git a/llvm/include/llvm/IR/AutoUpgrade.h b/llvm/include/llvm/IR/AutoUpgrade.h
index a186b05d437..8cf574c6a13 100644
--- a/llvm/include/llvm/IR/AutoUpgrade.h
+++ b/llvm/include/llvm/IR/AutoUpgrade.h
@@ -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
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
index 1a65cee0bf9..9d826aaac65 100644
--- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
+++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp
@@ -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));
diff --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index 78385ac82d3..f3193f5893c 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -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) {
diff --git a/llvm/test/Bitcode/upgrade-objcretainrelease-asm.ll b/llvm/test/Bitcode/upgrade-objcretainrelease-asm.ll
new file mode 100644
index 00000000000..e6a99dde72e
--- /dev/null
+++ b/llvm/test/Bitcode/upgrade-objcretainrelease-asm.ll
@@ -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
+}
diff --git a/llvm/test/Bitcode/upgrade-objcretainrelease-asm.ll.bc b/llvm/test/Bitcode/upgrade-objcretainrelease-asm.ll.bc
new file mode 100644
index 00000000000..eb9986b8a4d
--- /dev/null
+++ b/llvm/test/Bitcode/upgrade-objcretainrelease-asm.ll.bc
Binary files differ
OpenPOWER on IntegriCloud