llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
27.65k stars 11.37k forks source link

[stack-coloring] Increase in stack size after BB-layout change #54160

Open wolfy1961 opened 2 years ago

wolfy1961 commented 2 years ago

After 1e3c6fc7cb9d we're seeing an increase in stack size in function foo() in the attached example.

Platform: linux native. Compile with: clang -O2.

The stack size increases from 192 to 304, and when looking at an IR dump, we see in the version before the above mentioned commit:

# *** IR Dump Before Merge disjoint stack slots (stack-coloring) ***:
# Machine code for function foo: IsSSA, TracksLiveness
Frame Objects:
  fi#0: size=16, align=8, at location [SP+8]
  fi#1: size=176, align=8, at location [SP+8]
  fi#2: size=112, align=1, at location [SP+8]
...
# *** IR Dump After Merge disjoint stack slots (stack-coloring) ***:
# Machine code for function foo: IsSSA, TracksLiveness
Frame Objects:
  fi#0: size=16, align=8, at location [SP+8]
  fi#1: size=176, align=8, at location [SP+8]
  fi#2: dead

whereas in the version after the change we see

# *** IR Dump Before Merge disjoint stack slots (stack-coloring) ***:
# Machine code for function foo: IsSSA, TracksLiveness
Frame Objects:
  fi#0: size=16, align=8, at location [SP+8]
  fi#1: size=176, align=8, at location [SP+8]
  fi#2: size=112, align=1, at location [SP+8]
...
# *** IR Dump After Merge disjoint stack slots (stack-coloring) ***:
# Machine code for function foo: IsSSA, TracksLiveness
Frame Objects:
  fi#0: size=16, align=8, at location [SP+8]
  fi#1: size=176, align=8, at location [SP+8]
  fi#2: size=112, align=1, at location [SP+8]

The change itself seems to be unrelated, as it affects jump threading, leading to a slightly different layout of BBs throughout the function. t.c.txt (Apparently you can't attach a plain .c file, so I had to call it t.c.txt)

llvmbot commented 2 years ago

@llvm/issue-subscribers-backend-x86