[llvm] [PHIElimination] Reuse existing COPY in predecessor basic block (PR #131837)
Martin Storsjö via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 2 22:27:38 PDT 2025
mstorsjo wrote:
> > I haven't pinpointed exactly what goes wrong yet, but I've narrowed it down further.
> > The incorrect code generation happens with this much smaller input source, https://martin.st/temp/y4m_parse_tags-preproc.c, compiled with `clang-good -target armv7-w64-mingw32 y4m_parse_tags-preproc.c -c -O2 -o y4m_parse_tags.c.o`. The faulty code generation leads to a crash that looks like this:
> > ```
> > * thread #1, stop reason = Exception 0xc0000005 encountered at address 0x433e5c: Access violation reading location 0x00000000
> > frame #0: 0x00433e5c vpxenc.exe`y4m_parse_tags + 40
> > vpxenc.exe`y4m_parse_tags:
> > -> 0x433e5c <+40>: ldrb r0, [r1]
> > 0x433e5e <+42>: cmp r0, #0x20
> > 0x433e60 <+44>: beq 0x433e5a ; <+38>
> > 0x433e62 <+46>: cmp r0, #0x0
> > ```
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> > I see such instructions among the changed instructions in the output (if diffing the output with `-S` before/after this change), but I'm not yet sure what's wrong.
> > If someone can have a look at what changes in the code generation pipeline this PR triggers on this kinda small input, which may be causing it, that'd be appreciated!
>
> I think this helped me identify the bug in my PR- which didn't take into account that an operand to the PHI can appear more than once in the operand list. Check this PR: #146806
Thanks! It does seem to fix my issue. (I don’t think I can comment on the fix itself other than that.)
BTW, I noticed that the email address on your previous commit, f5c62ee0fa0466382cb11f6fad80d323b0fca057, is a GitHub hidden address - see [LLVM Developer Policy](https://llvm.org/docs/DeveloperPolicy.html#email-addresses) and [LLVM Discourse](https://discourse.llvm.org/t/hidden-emails-on-github-should-we-do-something-about-it) - it can be changed for future commits at [Keep my email addresses private](https://github.com/settings/emails).
https://github.com/llvm/llvm-project/pull/131837
More information about the llvm-commits
mailing list