[PATCH] D150368: TargetExtType: guard against the case that there is no layout type

Nicolai Hähnle via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 11 07:34:53 PDT 2023


nhaehnle created this revision.
nhaehnle added reviewers: jcranmer, jdoerfert, nikic, jsilvanus, Flakebi.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
nhaehnle requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This is hit by the verifier when looking at `call` arguments / return
type. There is a test in a subsequent commit.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150368

Files:
  llvm/lib/IR/Type.cpp


Index: llvm/lib/IR/Type.cpp
===================================================================
--- llvm/lib/IR/Type.cpp
+++ llvm/lib/IR/Type.cpp
@@ -217,8 +217,11 @@
   if (auto *VTy = dyn_cast<VectorType>(this))
     return VTy->getElementType()->isSized(Visited);
 
-  if (auto *TTy = dyn_cast<TargetExtType>(this))
-    return TTy->getLayoutType()->isSized(Visited);
+  if (auto *TTy = dyn_cast<TargetExtType>(this)) {
+    if (Type *LTy = TTy->getLayoutType())
+      return LTy->isSized(Visited);
+    return false;
+  }
 
   return cast<StructType>(this)->isSized(Visited);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150368.521307.patch
Type: text/x-patch
Size: 584 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230511/6fd0fed7/attachment.bin>


More information about the llvm-commits mailing list