This is an archive of the discontinued LLVM Phabricator instance.

[DAGCombiner] Don't merge stores to an illegal integer type
AcceptedPublic

Authored by nemanjai on Aug 13 2023, 6:18 AM.

Details

Summary

The DAG Combiner finds the widest available integer and vector type and chooses the wider of the two for the merge. If vector types can't be used, it produces an integer type that is as wide. Due to the logic, this type is necessarily wider than the widest legal integer type, so if this is being combined after legalization, the back end will crash.

This patch fixes the logic to use a type of vector width only if vectors can be used.

Fixes: https://github.com/llvm/llvm-project/issues/39641

Diff Detail

Event Timeline

nemanjai created this revision.Aug 13 2023, 6:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 13 2023, 6:18 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
nemanjai requested review of this revision.Aug 13 2023, 6:18 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 13 2023, 6:18 AM
Herald added a subscriber: wdng. · View Herald Transcript
nemanjai edited the summary of this revision. (Show Details)Aug 13 2023, 6:19 AM
bogner accepted this revision.Aug 13 2023, 6:17 PM
This revision is now accepted and ready to land.Aug 13 2023, 6:17 PM
arsenm added inline comments.Aug 13 2023, 6:19 PM
llvm/test/CodeGen/PowerPC/merge_stores_post_legalization_crash.ll
16

Test should use opaque pointers

25

Can drop attributes and local_unnamed_addr

nemanjai added inline comments.Aug 18 2023, 4:34 AM
llvm/test/CodeGen/PowerPC/merge_stores_post_legalization_crash.ll
16

Ah, good point. This was added to the bug report before the switch. I'll update it.

25

I kept the attributes on one version so we can test the noimplicitfloat and a regular one in two functions within the same invocation of llc. Would you prefer that I just have one function with no attributes and just use two RUN lines?

arsenm added inline comments.Aug 18 2023, 5:18 AM
llvm/test/CodeGen/PowerPC/merge_stores_post_legalization_crash.ll
25

The attributes that matter should stay, don’t need multiple invocations