[llvm] 0327cfe - [llvm-link] fix IRMover returning wrong modified vector type

Nashe Mncube via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 22 03:31:43 PST 2021


Author: Nashe Mncube
Date: 2021-02-22T11:29:42Z
New Revision: 0327cfe2f7620d70cd44082a172e58872ffe4105

URL: https://github.com/llvm/llvm-project/commit/0327cfe2f7620d70cd44082a172e58872ffe4105
DIFF: https://github.com/llvm/llvm-project/commit/0327cfe2f7620d70cd44082a172e58872ffe4105.diff

LOG: [llvm-link] fix IRMover returning wrong modified vector type

Modified scalable vector types weren't correctly returned at link-time.
The previous behaviour was a FixedVectorType was constructed
when expecting a ScalableVectorType. This commit has added a regression
test which re-creates the failure as well as a fix.

Reviewed By: sdesmalen

Differential Revision: https://reviews.llvm.org/D96953

Added: 
    llvm/test/Linker/Inputs/fixed-vector-type-construction.ll
    llvm/test/Linker/scalable-vector-type-construction.ll

Modified: 
    llvm/lib/Linker/IRMover.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Linker/IRMover.cpp b/llvm/lib/Linker/IRMover.cpp
index 4d7c5ef67217..1004e4e7d334 100644
--- a/llvm/lib/Linker/IRMover.cpp
+++ b/llvm/lib/Linker/IRMover.cpp
@@ -298,10 +298,9 @@ Type *TypeMapTy::get(Type *Ty, SmallPtrSet<StructType *, 8> &Visited) {
     return *Entry = ArrayType::get(ElementTypes[0],
                                    cast<ArrayType>(Ty)->getNumElements());
   case Type::ScalableVectorTyID:
-    // FIXME: handle scalable vectors
   case Type::FixedVectorTyID:
-    return *Entry = FixedVectorType::get(
-               ElementTypes[0], cast<FixedVectorType>(Ty)->getNumElements());
+    return *Entry = VectorType::get(ElementTypes[0],
+                                    cast<VectorType>(Ty)->getElementCount());
   case Type::PointerTyID:
     return *Entry = PointerType::get(ElementTypes[0],
                                      cast<PointerType>(Ty)->getAddressSpace());

diff  --git a/llvm/test/Linker/Inputs/fixed-vector-type-construction.ll b/llvm/test/Linker/Inputs/fixed-vector-type-construction.ll
new file mode 100644
index 000000000000..1b6baf579047
--- /dev/null
+++ b/llvm/test/Linker/Inputs/fixed-vector-type-construction.ll
@@ -0,0 +1,4 @@
+%t = type {i32, float}
+define void @foo(<4 x %t*> %x) {
+  ret void
+}

diff  --git a/llvm/test/Linker/scalable-vector-type-construction.ll b/llvm/test/Linker/scalable-vector-type-construction.ll
new file mode 100644
index 000000000000..ae95af510dbb
--- /dev/null
+++ b/llvm/test/Linker/scalable-vector-type-construction.ll
@@ -0,0 +1,7 @@
+; RUN: llvm-link %p/Inputs/fixed-vector-type-construction.ll %s -S -o - | FileCheck %s
+%t = type {i32, float}
+; CHECK: define void @foo(<4 x
+; CHECK; define void @bar(<vscale x 4 x
+define void @bar(<vscale x 4 x %t*> %x) {
+  ret void
+}


        


More information about the llvm-commits mailing list