Skip to content

Regression: huge .rodata section generated because of constant vector of bool. #55522

@gwenzek

Description

@gwenzek

Given the simple .ll file @0 = internal constant <4 x i1> <i1 true, i1 false, i1 true, i1 false>,
LLVM 14 will generate an object file with 4Gb of rodata

$ rm reduced.o ; cat reduced.ll && ~/Downloads/clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/llc --filetype=obj reduced.ll && size -A reduced.o
@0 = internal constant <4 x i1> <i1 true, i1 false, i1 true, i1 false>
reduced.o  :
section                 size   addr
.text                      0      0
.rodata           4294967297      0
.note.GNU-stack            0      0
Total             4294967297

If I try with vector of i8, I correctly obtain 4 bytes of rodata.

$ rm reduced.o ; cat reduced.ll && ~/Downloads/clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04/bin/llc --filetype=obj reduced.ll && size -A reduced.o
@0 = internal constant <4 x i8> <i8 1, i8 0, i8 1, i8 0>
reduced.o  :
section           size   addr
.text                0      0
.rodata              4      0
.note.GNU-stack      0      0
Total                4

Vectors of i2, and i4 also generate the same issue.

This seems to be a regression from LLVM 13 where this was working fine (I believe the warning is just because my .ll is too dry).

$ rm reduced.o ; cat reduced.ll && ~/Downloads/clang+llvm-13.0.1-x86_64-linux-gnu-ubuntu-18.04/bin/llc --filetype=obj reduced.ll && size -A reduced.o
@0 = internal constant <4 x i1> <i1 true, i1 false, i1 true, i1 false>
~Downloads/clang+llvm-13.0.1-x86_64-linux-gnu-ubuntu-18.04/bin/llc: /lib64/libtinfo.so.5: no version information available (required by ~/Downloads/clang+llvm-13.0.1-x86_64-linux-gnu-ubuntu-18.04/bin/llc)
reduced.o  :
section           size   addr
.text                0      0
.rodata              4      0
.note.GNU-stack      0      0
Total                4

I've tried searching for similar issue but without success.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions