[llvm] CodeGen: Fix lookThruCopyLike crash on an undef register (PR #216598)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 16 13:18:47 PDT 2026


================
@@ -608,7 +608,7 @@ TargetRegisterInfo::lookThruCopyLike(Register SrcReg,
                                      const MachineRegisterInfo *MRI) const {
   while (true) {
     const MachineInstr *MI = MRI->getVRegDef(SrcReg);
-    if (!MI->isCopyLike())
+    if (!MI || !MI->isCopyLike())
       return SrcReg;
 
     Register CopySrcReg;
----------------
arsenm wrote:

<!--__GRAPHITE_HTML_TAG_START__--><p class='graphite__hidden'><i>[Re: line +634]</i></p><!--__GRAPHITE_HTML_TAG_END__-->
The case down here is also a problem, but needs a separate test
<!--__GRAPHITE_HTML_TAG_START__--><p class='graphite__hidden'>See this comment inline on <a href="https://app.graphite.com/github/pr/llvm/llvm-project/216598?utm_source=unchanged-line-comment">Graphite</a>.</p><!--__GRAPHITE_HTML_TAG_END__-->

https://github.com/llvm/llvm-project/pull/216598


More information about the llvm-commits mailing list