From 8292bdf73551c66ce2b9f22629c1a06628b5f777 Mon Sep 17 00:00:00 2001 From: Ahmed Bougacha Date: Fri, 29 Jul 2016 16:11:02 +0000 Subject: [PATCH] [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. llvm-svn: 277161 --- llvm/include/llvm/CodeGen/LowLevelType.h | 2 +- llvm/unittests/CodeGen/LowLevelTypeTest.cpp | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/llvm/include/llvm/CodeGen/LowLevelType.h b/llvm/include/llvm/CodeGen/LowLevelType.h index 165a171..7d97570 100644 --- a/llvm/include/llvm/CodeGen/LowLevelType.h +++ b/llvm/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) diff --git a/llvm/unittests/CodeGen/LowLevelTypeTest.cpp b/llvm/unittests/CodeGen/LowLevelTypeTest.cpp index 37245bc..e1161cb 100644 --- a/llvm/unittests/CodeGen/LowLevelTypeTest.cpp +++ b/llvm/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)); } } -- 2.7.4