rust-lang / rust

Empowering everyone to build reliable and efficient software.
https://www.rust-lang.org
Other
97.88k stars 12.67k forks source link

Unmerged stack slots under Windows #132014

Open xTachyon opened 3 hours ago

xTachyon commented 3 hours ago

https://godbolt.org/z/1foPhW5PT

Relevant bits:

example::write_characteristics::hd20ef966b954cd90:
        sub     rsp, 200
define void @example::write_characteristics::hd20ef966b954cd90(i16 noundef %c) unnamed_addr {
start:
  %0 = alloca [16 x i8], align 8
  %1 = alloca [16 x i8], align 8
  %2 = alloca [16 x i8], align 8
  %3 = alloca [16 x i8], align 8
  %4 = alloca [16 x i8], align 8
  %5 = alloca [16 x i8], align 8
  %6 = alloca [16 x i8], align 8
  %7 = alloca [16 x i8], align 8
  %8 = alloca [16 x i8], align 8
  %9 = alloca [16 x i8], align 8

I think all the allocas should've been merged in one, or be able to pass a pointer to a global const with the slice.

xTachyon commented 3 hours ago

For the first idea, I'd expect codegen similar to this: https://godbolt.org/z/5M8jG5orf