Open ornata opened 3 years ago
llvm-extracted functions which produce a code size increase
I extracted one of the functions with a significant increase using llvm-extract --recursive
.
This seems to give a similar code size increase:
$ build/bin/clang -O3 -arch arm64 -flegacy-pass-manager -c /tmp/func.bc -o /tmp/old-pm
$ build/bin/clang -O3 -arch arm64 -fno-legacy-pass-manager -c /tmp/func.bc -o /tmp/new-pm
$ ~/llvm-project/build/bin/llvm-size /tmp/old-pm /tmp/new-pm
__TEXT __DATA __OBJC others dec hex
43884 0 0 248527 292411 4763b /tmp/old-pm
54632 0 0 321642 376274 5bdd2 /tmp/new-pm
And if you pass -Rpass-missed=inline -Rpass=inline
to clang, it shows significant inlining differences.
(For reference, the function is _ZN5Pooma11newRelationIN3EOS5pg_igE5FieldI22UniformRectilinearMeshI10MeshTraitsILi3Ed21UniformRectilinearTag12CartesianTagLi3EEEd10MultiPatchI7GridTag6RemoteI5BrickEEESG_SG_S3_IS9_d16ConstantFunctionEEEvRKT_RKT0_RKT1_RKT2_RKT3_
)
Compiling with -fno-inline removes the code size issue:
test-suite...ark/tramp3d-v4/tramp3d-v4.test 592532 592548 0.0%
(It's only 16 B bigger)
Haven't gotten around to measuring perf yet, but yeah, it could be a reasonable tradeoff for -O3
.
And also measuring performance would be interesting to see if the extra inlining helped or not.
Yeah it's likely due to inlining changes, I've also noticed Chrome's code size go up for files compiled with -O2
/-O3
. Could you try running with -fno-inline-functions
? Also, running with -Os
should be fairly similar in terms of code size.
Extended Description
1) Using LNT, compile CTMark at
-O3
for AArch64 with + without the new PM. (I used-C target-arm64-iphoneos-internal.cmake
+--cflags -O3 --cxxflags -O3
) 2) Usellvm-test-suite/utils/compare.py
to comparesize.__text
Although this is
-O3
, and size generally isn't a concern there, this is a pretty big jump in code size. It might be worth looking into if it is not expected. I think that a lot of this is due to inlining changes.The following functions grew a lot in size:
(Format: function_name old_pm_size new_pm_size diff)
Then looking at the remarks: