This is an archive of the discontinued LLVM Phabricator instance.

Disable frame pointer elimination when using -pg
ClosedPublic

Authored by sisnkemp on Nov 1 2015, 4:12 AM.

Details

Summary

When using -pg in combination with optimizations (e.g. -O3), compiled programs crash in the profiling routine mcount().
This is because mcount (on x86_64 at least) relies on the frame pointer to be valid. See test case to reproduce.

This diff makes sure that the driver does not pass -fomit-frame-pointer or -momit-leaf-frame-pointer to the frontend when -pg is used. Currently, clang gives an error if -fomit-frame-pointer is used in combination with -pg, but -momit-leaf-frame-pointer was forgotten.
Also, disable frame pointer elimination in the frontend when -pg is set.

The behavior is consistent with gcc now: clang produces an error if -fomit-frame-pointer is used with -pg, and silently disables -momit-leaf-frame-pointer when -pg is used.

Diff Detail

Event Timeline

sisnkemp updated this revision to Diff 38842.Nov 1 2015, 4:12 AM
sisnkemp retitled this revision from to Disable frame pointer elimination when using -pg.
sisnkemp updated this object.
sisnkemp added a subscriber: cfe-commits.
sisnkemp updated this revision to Diff 39651.Nov 8 2015, 5:55 AM

Ping. Can somebody please comment on this?

sisnkemp updated this revision to Diff 40230.Nov 15 2015, 1:31 AM
spatel added a subscriber: spatel.

Adding some PGO-active reviewers.

davidxl edited edge metadata.Nov 19 2015, 4:51 PM

Can you also add a test case with option -momit-leaf-frame-pointer?

sisnkemp updated this revision to Diff 40793.Nov 20 2015, 10:17 AM
sisnkemp edited edge metadata.

Added a test with -momit-leaf-frame-pointer as requested by davidxl.

sisnkemp updated this revision to Diff 40794.Nov 20 2015, 10:22 AM
davidxl accepted this revision.Nov 20 2015, 4:36 PM
davidxl edited edge metadata.

Looks good to me.

This revision is now accepted and ready to land.Nov 20 2015, 4:36 PM
sisnkemp updated this revision to Diff 40933.Nov 23 2015, 8:56 AM
sisnkemp edited edge metadata.
RKSimon closed this revision.Nov 25 2015, 1:25 PM
RKSimon added a subscriber: RKSimon.

Committed at rL253886