What code of size does llvm test-suite compare?

I’m using the tool lnt to compare two compilers.

It will compare the compiler time, execution time and code size.

I want to know what code of size does it compare with.

In my experiment, I write a C code by myself and compile to assembly code by LLVM O1 and O3.
The size of O1.s and O3.s is different. But when I generate O1.exe and O3.exe from O1.s O3.s, the size of executable files are the same. (Apparently, the execution time is different.)

What happened in the process?
And what code will llvm test-suite compare to produce the code size result?

I barely know anything about Windows, but on macOS, we get the following options for code size:

        "size": 850008,
        "size.__bss": 4608,
        "size.__common": 96,
        "size.__const": 9160,
        "size.__cstring": 96751,
        "size.__data": 56704,
        "size.__eh_frame": 156,
        "size.__got": 1128,
        "size.__stubs": 1620,
        "size.__text": 496008,
        "size.__unwind_info": 2048

Out of all of these, the one that is usually the most important is size.__text, and sometimes size.__data.

I’m not sure which one LNT loads by default in the UI (I only use compare.py), but I think you probably want size.__text.

But when I generate O1.exe and O3.exe from O1.s O3.s, the size of executable files are the same

This is probably because the change in the assembly is too small:

An executable image consists of several different regions, each of which require different memory protection; so the start of each section must be aligned to a page boundary
(Portable Executable - Wikipedia)

It’s likely that the original code + changed code fit within the same page, so you won’t see a change in total executable size.

(Apparently, on Windows, there’s an optional header (SizeOfCode) which contains the sum of all code sections in an executable. Maybe there’s a way to get at that if you want to double-check what LNT is doing. See: PE Format - Win32 apps | Microsoft Docs)

I want to figure out this problem because I want to know if two executables are different or not.

Thanks for your reply!!

If you want to see if your optimization is actually doing anything, you can also try adding optimization remarks to it. :slight_smile:

1 Like

I see. Thanks!!!