Bug 271992 - backport fix for LLVM bug 61396
Summary: backport fix for LLVM bug 61396
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: misc (show other bugs)
Version: CURRENT
Hardware: arm Any
: --- Affects Some People
Assignee: freebsd-arm (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-06-14 12:36 UTC by John F. Carr
Modified: 2023-06-28 18:46 UTC (History)
3 users (show)

See Also:


Attachments
backport of LLVM commit 962c306a11d0a21c884c12e18825b8a41ba1bd7d (1.83 KB, text/plain)
2023-06-14 12:36 UTC, John F. Carr
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description John F. Carr 2023-06-14 12:36:24 UTC
Created attachment 242772 [details]
backport of LLVM commit 962c306a11d0a21c884c12e18825b8a41ba1bd7d

LLVM 15 and 16 have a codegen bug that causes gcc to be miscompiled on 32 bit ARM.  See LLVM issue 61255 reported by Mark Millard, which turned out to have the same root cause as issue 61396.  This is fixed in llvm-devel but not in any release.

With the attached diff to the FreeBSD copy of llvm-project I am able to build lang/gcc11, gcc12, gcc13, and gcc-devel in an armv7 jail.  Without the fix the ports builds hang because gcc built by llvm goes into an infinite loop.


References:

https://github.com/llvm/llvm-project/issues/61255
https://github.com/llvm/llvm-project/commit/962c306a11d0a21c884c12e18825b8a41ba1bd7d
Comment 1 commit-hook freebsd_committer freebsd_triage 2023-06-19 18:34:41 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=dbbaf77801a8f30e49731395e85757f339f345bf

commit dbbaf77801a8f30e49731395e85757f339f345bf
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-06-19 18:32:40 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-06-19 18:33:33 +0000

    Apply llvm fix for hanging gcc builds on 32-bit arm

    Merge commit 962c306a11d0 from llvm-project (by Florian Hahn):

      [LV] Don't consider pointer as uniform if it is also stored.

      Update isVectorizedMemAccessUse to also check if the pointer is stored.
      This prevents LV to incorrectly consider a pointer as uniform if it is
      used as both pointer and stored by the same StoreInst.

      Fixes #61396.

    PR:             271992
    Reported by:    John F. Carr <jfc@mit.edu>
    MFC after:      3 days

 .../llvm/lib/Transforms/Vectorize/LoopVectorize.cpp      | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
Comment 2 commit-hook freebsd_committer freebsd_triage 2023-06-19 18:44:43 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=50593575e96b94f5de485c6216a870db44e487e0

commit 50593575e96b94f5de485c6216a870db44e487e0
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2023-06-19 18:44:06 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2023-06-19 18:44:06 +0000

    devel/llvm16: update to 16.0.6 release

    Change the lite flavor to default to BE_FREEBSD rather than BE_NATIVE to
    allow its use in cross-build CI pipelines.

    Backport fix for LLVM bug 61396. [0]  This fixes miscompilation of gcc
    on 32-bit arm.

    PR:             271992 [0]
    Reported by:    jfc@mit.edu [0]

 devel/llvm16/Makefile                             |  4 +--
 devel/llvm16/distinfo                             |  6 ++--
 devel/llvm16/files/patch-backport-962c306a1 (new) | 42 +++++++++++++++++++++++
 3 files changed, 47 insertions(+), 5 deletions(-)
Comment 3 commit-hook freebsd_committer freebsd_triage 2023-06-19 18:44:45 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=f67260aafd1cfb5eb91cfc72df80a00ef8b87e13

commit f67260aafd1cfb5eb91cfc72df80a00ef8b87e13
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2023-06-19 18:44:05 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2023-06-19 18:44:05 +0000

    devel/llvm15: arm fixes, lite default change

    Change the lite flavor to default to BE_FREEBSD rather than BE_NATIVE to
    allow its use in cross-build CI pipelines.

    Backport fix for LLVM bug 61396. [0]  This fixes miscompilation of gcc
    on 32-bit arm.

    Remove an obsolete patch which breaks arm64. [1]

    PR:             271992 [0], 271616 [1]
    Reported by:    jfc@mit.edu [0,1]

 devel/llvm15/Makefile                             |  4 +-
 devel/llvm15/files/patch-backport-962c306a1 (new) | 42 ++++++++++
 devel/llvm15/files/patch-freebsd-r352318 (gone)   | 93 -----------------------
 3 files changed, 44 insertions(+), 95 deletions(-)
Comment 4 commit-hook freebsd_committer freebsd_triage 2023-06-23 23:38:48 UTC
A commit in branch 2023Q2 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=5e81b0383c515efab7ffba838969f2cbb2656082

commit 5e81b0383c515efab7ffba838969f2cbb2656082
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2023-06-19 18:44:06 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2023-06-23 21:01:43 +0000

    devel/llvm16: update to 16.0.6 release

    Change the lite flavor to default to BE_FREEBSD rather than BE_NATIVE to
    allow its use in cross-build CI pipelines.

    Backport fix for LLVM bug 61396. [0]  This fixes miscompilation of gcc
    on 32-bit arm.

    PR:             271992 [0]
    Reported by:    jfc@mit.edu [0]

    (cherry picked from commit 50593575e96b94f5de485c6216a870db44e487e0)

 devel/llvm16/Makefile                             |  4 +--
 devel/llvm16/distinfo                             |  6 ++--
 devel/llvm16/files/patch-backport-962c306a1 (new) | 42 +++++++++++++++++++++++
 3 files changed, 47 insertions(+), 5 deletions(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2023-06-23 23:38:49 UTC
A commit in branch 2023Q2 references this bug:

URL: https://cgit.FreeBSD.org/ports/commit/?id=880ad3b00f273d47831d183ac44f3b3074d0875a

commit 880ad3b00f273d47831d183ac44f3b3074d0875a
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2023-06-19 18:44:05 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2023-06-23 21:01:37 +0000

    devel/llvm15: arm fixes, lite default change

    Change the lite flavor to default to BE_FREEBSD rather than BE_NATIVE to
    allow its use in cross-build CI pipelines.

    Backport fix for LLVM bug 61396. [0]  This fixes miscompilation of gcc
    on 32-bit arm.

    Remove an obsolete patch which breaks arm64. [1]

    PR:             271992 [0], 271616 [1]
    Reported by:    jfc@mit.edu [0,1]

    (cherry picked from commit f67260aafd1cfb5eb91cfc72df80a00ef8b87e13)

 devel/llvm15/Makefile                             |  4 +-
 devel/llvm15/files/patch-backport-962c306a1 (new) | 42 ++++++++++
 devel/llvm15/files/patch-freebsd-r352318 (gone)   | 93 -----------------------
 3 files changed, 44 insertions(+), 95 deletions(-)
Comment 6 commit-hook freebsd_committer freebsd_triage 2023-06-28 18:01:58 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=1706d72e36a03da4e5c2bd166362dabf8f2b1d6a

commit 1706d72e36a03da4e5c2bd166362dabf8f2b1d6a
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-06-19 18:32:40 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-06-28 17:59:58 +0000

    Apply llvm fix for hanging gcc builds on 32-bit arm

    Merge commit 962c306a11d0 from llvm-project (by Florian Hahn):

      [LV] Don't consider pointer as uniform if it is also stored.

      Update isVectorizedMemAccessUse to also check if the pointer is stored.
      This prevents LV to incorrectly consider a pointer as uniform if it is
      used as both pointer and stored by the same StoreInst.

      Fixes #61396.

    PR:             271992
    Reported by:    John F. Carr <jfc@mit.edu>
    MFC after:      3 days

    (cherry picked from commit dbbaf77801a8f30e49731395e85757f339f345bf)

 .../llvm/lib/Transforms/Vectorize/LoopVectorize.cpp      | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
Comment 7 commit-hook freebsd_committer freebsd_triage 2023-06-28 18:16:00 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=2846052cd44ec28a99af774127f578d626d6f368

commit 2846052cd44ec28a99af774127f578d626d6f368
Author:     Dimitry Andric <dim@FreeBSD.org>
AuthorDate: 2023-06-19 18:32:40 +0000
Commit:     Dimitry Andric <dim@FreeBSD.org>
CommitDate: 2023-06-28 18:00:06 +0000

    Apply llvm fix for hanging gcc builds on 32-bit arm

    Merge commit 962c306a11d0 from llvm-project (by Florian Hahn):

      [LV] Don't consider pointer as uniform if it is also stored.

      Update isVectorizedMemAccessUse to also check if the pointer is stored.
      This prevents LV to incorrectly consider a pointer as uniform if it is
      used as both pointer and stored by the same StoreInst.

      Fixes #61396.

    PR:             271992
    Reported by:    John F. Carr <jfc@mit.edu>
    MFC after:      3 days

    (cherry picked from commit dbbaf77801a8f30e49731395e85757f339f345bf)

 .../llvm/lib/Transforms/Vectorize/LoopVectorize.cpp      | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)