LowLevelType: replace a reachable llvm_unreachable with assert
authorFangrui Song <i@maskray.me>
Fri, 18 Aug 2023 21:58:53 +0000 (14:58 -0700)
committerTobias Hieta <tobias@hieta.se>
Mon, 21 Aug 2023 08:05:59 +0000 (10:05 +0200)
assert is more appropriate here and fixes
`runtime error: execution reached an unreachable program point` in a
-DLLVM_USE_SANITIZER=Undefined build (-fno-sanitize-recover=all causes
llc to exit instead of crash (report_fatal_error)) when testing
MachineVerifier/test_g_assert_[sz]ext.mir.

(cherry picked from commit a7e20dd664bbce6e87b1fdad88d719e497902a42)

llvm/include/llvm/CodeGen/LowLevelType.h

index 2924f47..a1e778c 100644 (file)
@@ -238,10 +238,9 @@ public:
         return getFieldValue(VectorSizeFieldInfo);
       else
         return getFieldValue(PointerVectorSizeFieldInfo);
-    } else if (IsPointer)
-      return getFieldValue(PointerSizeFieldInfo);
-    else
-      llvm_unreachable("unexpected LLT");
+    }
+    assert(IsPointer && "unexpected LLT");
+    return getFieldValue(PointerSizeFieldInfo);
   }
 
   constexpr unsigned getAddressSpace() const {