[llvm] 77cc690 - AArch64: fix bitcode upgrade of @llvm.neon.addp.

Tim Northover via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 14 05:43:53 PST 2020


Author: Tim Northover
Date: 2020-01-14T13:41:32Z
New Revision: 77cc690bae310f4cba0a34f2da8a37a7c9a10a82

URL: https://github.com/llvm/llvm-project/commit/77cc690bae310f4cba0a34f2da8a37a7c9a10a82
DIFF: https://github.com/llvm/llvm-project/commit/77cc690bae310f4cba0a34f2da8a37a7c9a10a82.diff

LOG: AArch64: fix bitcode upgrade of @llvm.neon.addp.

We were upgrading it to faddp, but a version taking two type parameters instead
of one. This then got upgraded a second time to the version with just one
parameter, but occasionally (for reasons I don't understand) this unusual
two-stage process corrupted a use-list, leading to a crash when the two faddp
declarations didn't match.

Added: 
    llvm/test/Bitcode/aarch64-addp-upgrade.bc
    llvm/test/Bitcode/aarch64-addp-upgrade.ll

Modified: 
    llvm/lib/IR/AutoUpgrade.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/AutoUpgrade.cpp b/llvm/lib/IR/AutoUpgrade.cpp
index ecd1a12c2e5c..6e2beeb839b6 100644
--- a/llvm/lib/IR/AutoUpgrade.cpp
+++ b/llvm/lib/IR/AutoUpgrade.cpp
@@ -585,11 +585,10 @@ static bool UpgradeIntrinsicFunction1(Function *F, Function *&NewFn) {
     if (Name.startswith("aarch64.neon.addp")) {
       if (F->arg_size() != 2)
         break; // Invalid IR.
-      auto fArgs = F->getFunctionType()->params();
-      VectorType *ArgTy = dyn_cast<VectorType>(fArgs[0]);
-      if (ArgTy && ArgTy->getElementType()->isFloatingPointTy()) {
+      VectorType *Ty = dyn_cast<VectorType>(F->getReturnType());
+      if (Ty && Ty->getElementType()->isFloatingPointTy()) {
         NewFn = Intrinsic::getDeclaration(F->getParent(),
-                                          Intrinsic::aarch64_neon_faddp, fArgs);
+                                          Intrinsic::aarch64_neon_faddp, Ty);
         return true;
       }
     }

diff  --git a/llvm/test/Bitcode/aarch64-addp-upgrade.bc b/llvm/test/Bitcode/aarch64-addp-upgrade.bc
new file mode 100644
index 000000000000..a359b445f175
Binary files /dev/null and b/llvm/test/Bitcode/aarch64-addp-upgrade.bc 
diff er

diff  --git a/llvm/test/Bitcode/aarch64-addp-upgrade.ll b/llvm/test/Bitcode/aarch64-addp-upgrade.ll
new file mode 100644
index 000000000000..4e78996aa0b6
--- /dev/null
+++ b/llvm/test/Bitcode/aarch64-addp-upgrade.ll
@@ -0,0 +1,18 @@
+; RUN: llvm-dis %p/aarch64-addp-upgrade.bc -o - | FileCheck %s
+
+; Bitcode was generated from file below, which may or may not even assemble any
+; more.
+
+; CHECK: call <2 x float> @llvm.aarch64.neon.faddp.v2f32(<2 x float> %lhs, <2 x float> %rhs)
+define <2 x float> @test_addp(<2 x float> %lhs, <2 x float> %rhs) {
+  %res = call <2 x float> @llvm.aarch64.neon.addp.v2f32(<2 x float> %lhs, <2 x float> %rhs)
+  ret <2 x float> %res
+}
+
+; CHECK: call <2 x float> @llvm.aarch64.neon.faddp.v2f32(<2 x float> %lhs, <2 x float> %rhs)
+define <2 x float> @test_addp1(<2 x float> %lhs, <2 x float> %rhs) {
+  %res = call <2 x float> @llvm.aarch64.neon.addp.v2f32(<2 x float> %lhs, <2 x float> %rhs)
+  ret <2 x float> %res
+}
+
+declare <2 x float> @llvm.aarch64.neon.addp.v2f32(<2 x float>, <2 x float>)


        


More information about the llvm-commits mailing list