llvm / llvm-project

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

Incorrect inlining cost calculation with new pass manager #41469

Open 130b3519-e3e6-4fca-9572-f7b920a99446 opened 5 years ago

130b3519-e3e6-4fca-9572-f7b920a99446 commented 5 years ago
Bugzilla Link 42124
Version trunk
OS All
Attachments Reduced reproducer
CC @chandlerc,@dwblaikie,@nickdesaulniers,@stephenhines,@yuanfang-chen

Extended Description

aec_port_reset_output_index is a small static method and is only called once. There should be performance gain by inlining the method:

$ clang -c -w -O2 -Rpass=inline aec_port_reduced.c aec_port_reduced.c:46:11: remark: aec_port_reset_output_index inlined into d with (cost=-14955, threshold=225) [-Rpass=inline] aec_port_reset_output_index(); ^

However with the new pass manager:

$ clang -c -w -fexperimental-new-pass-manager -O2 -Rpass-missed=inline aec_port_reduced.c aec_port_reduced.c:46:11: remark: aec_port_reset_output_index not inlined into d because too costly to inline (cost=45, threshold=45) [-Rpass-missed=inline] aec_port_reset_output_index(); ^

stephenhines commented 5 years ago

https://reviews.llvm.org/D63034 was proposed to address this, but still needs some follow-up.