<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/54766>54766</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            missing initializer for a constant string larger than UINT_MAX
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          msebor
      </td>
    </tr>
</table>

<pre>
    While looking into PR #54739 I noticed that LLVM fails to emit the leading nonzero initializer for a constant character array larger than `UINT_MAX` bytes.  Because of the missing nonzero initializer it also incorrectly folds expressions involving access to it (see below).

The initializer is emitted for an array that's `UINT_MAX` bytes in size or smaller, but the initial string is padded at the end with NULs up to the size of the array, which takes excessively long to compile.

```
$ cat a.c && clang -O2 -S -Wall -emit-llvm -o/dev/stdout a.c
const char a[~0U + 1LU] = "123";

extern char* strrchr (const char*, int);

char* f (void)
{
  return strrchr (a, '3') ;
}

; ModuleID = 'a.c'
source_filename = "a.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

@a = dso_local local_unnamed_addr constant [4294967296 x i8] c"", align 16

; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn uwtable
define dso_local noalias i8* @f() local_unnamed_addr #0 {
entry:
  ret i8* null
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind readnone willreturn uwtable "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.module.flags = !{!0, !1}
!llvm.ident = !{!2}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 7, !"uwtable", i32 2}
!2 = !{!"clang version 15.0.0 (https://github.com/llvm/llvm-project.git 3e9805eb03df76ee30582b35a3d3ad9277d4394e)"}
```
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJytVttu4zYQ_Rr5ZSBDomRLfvBDsmmAANlt0d10-2bQEmWzoUiDpHzp1_dQkm_ptkCBAjJNaubMfYZam_q0_L6VSpAy5l3qDUntDf3yK0Usm-VFtqAX0sbLStTkt9zT6-tvn6nhUjkCo2ilx3vABa8DXBv9p7AGYqSXXEkcqDGWOFVGO8-1p2rLLa88CNxafiLF7QYHSNcUzZO3ly_fVp8ffseW1icv3JToUVS8c4JM0ytrpXP_pAz2cOXCu8pYKyqvTjBA1Y7EcWcFgLAD1L1R-yCDVxVeBl-AjFjphKC1UOYQscU0Sp6i5GFYv0HxnSLXe-8RmN5BPboTohSxwv3QF0ggBzgB4VqulLAR-0TrbojiKJ-ct30uHO14XUMDH-hC13SQfktf3l4ddbtgdng_iByC01sRhB62stqS5-8i-B68lHuBaCgD0QBWpt0h83dOwtDxGY4spwq6-bRCbOZ4qFIc8PhnRvFXir_DBYpDHGKl9i3FJmLPtdhjdb42XQ8dZPX575NPPJo9RsVPyRuEPlL6-hbNnijK8GMsZRnWKHu8NUscUS66B0fsIYTHVlsb0nWVCkLwGvWLzH3An4FNgOyNrAPLQC9GRiIrfAclN8J5EIhcwqICCLpKLZ7uopY90mdTd0q8nP0ogt9A9XRnOluJVYNoa96Ks6s9CxtYfGgCTzX3XPFTCNzIJOI2yh5EvGNFgk3G-iUc0_tj2M3zfonledOUAZSyMtZl2MzPGNC-4vVH_ai7nboYeCznKzB2-l2bg46V1N0x3ujughrXPOE9pHZmpUyFAu7XVaeDu_UKNWyv_Y_k52yRL-YFW8zpSLIM6e9DEZ5P6F-50QRbP4T4udOVR_vSg_fWwQlqO-d31mxCX2MaNBbNqw26vrMu7NxJV_jr9EGicyxmFEaGQAspNWa7O3i-VmJQUotGgnx1QxvYwl0wEdUDP5soxGzxI_8wMBO6lJPQ3p5g4k1xjVJ0p9QPq4jDK4lJgHYdZIUkFI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