Browse Source

[GlobalISel] Fix LLT::unsized to match LLT(LabelTy).

When coming from an IR label type, we set a 0 NumElements, but not
when constructing an LLT using unsized(), causing comparisons to fail.

Pick one variant and fix the other.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277161 91177308-0d34-0410-b5e6-96231b3b80d8
Ahmed Bougacha 9 years ago
parent
commit
ade60aa452
2 changed files with 6 additions and 1 deletions
  1. 1 1
      include/llvm/CodeGen/LowLevelType.h
  2. 5 0
      unittests/CodeGen/LowLevelTypeTest.cpp

+ 1 - 1
include/llvm/CodeGen/LowLevelType.h

@@ -77,7 +77,7 @@ public:
   /// \brief get an unsized but valid low-level type (e.g. for a label).
 
   static LLT unsized() {
-    return LLT{Unsized, 1, 0};
+    return LLT{Unsized, 0, 0};
   }
 
   explicit LLT(TypeKind Kind, uint16_t NumElements, unsigned SizeOrAddrSpace)

+ 5 - 0
unittests/CodeGen/LowLevelTypeTest.cpp

@@ -187,6 +187,8 @@ TEST(LowLevelTypeTest, Invalid) {
 }
 
 TEST(LowLevelTypeTest, Unsized) {
+  LLVMContext C;
+
   const LLT Ty = LLT::unsized();
 
   ASSERT_TRUE(Ty.isValid());
@@ -194,5 +196,8 @@ TEST(LowLevelTypeTest, Unsized) {
   ASSERT_FALSE(Ty.isSized());
   ASSERT_FALSE(Ty.isPointer());
   ASSERT_FALSE(Ty.isVector());
+
+  const Type *IRTy = Type::getLabelTy(C);
+  EXPECT_EQ(Ty, LLT(*IRTy));
 }
 }