Page MenuHomePhabricator

[IR][sanitizer] Add module flag "frame-pointer" and set it for cc1 -mframe-pointer={non-leaf,all}
ClosedPublic

Authored by MaskRay on Wed, Apr 21, 8:48 PM.

Details

Summary

The Linux kernel objtool diagnostic call without frame pointer save/setup
arise in multiple instrumentation passes (asan/tsan/gcov). With the mechanism
introduced in D100251, it's trivial to respect the command line
-m[no-]omit-leaf-frame-pointer/-f[no-]omit-frame-pointer, so let's do it.

Fix: https://github.com/ClangBuiltLinux/linux/issues/1236 (tsan)
Fix: https://github.com/ClangBuiltLinux/linux/issues/1238 (asan)

Diff Detail

Event Timeline

MaskRay created this revision.Wed, Apr 21, 8:48 PM
MaskRay requested review of this revision.Wed, Apr 21, 8:48 PM
Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptWed, Apr 21, 8:48 PM
nickdesaulniers accepted this revision.Wed, Apr 21, 11:17 PM

Nice idea to create Function::createWithDefaultAttr then reuse for multiple purposes!

llvm/lib/IR/Function.cpp
333

we should call this from gcov too to solve https://github.com/ClangBuiltLinux/linux/issues/955.

This revision is now accepted and ready to land.Wed, Apr 21, 11:17 PM
vitalybuka added inline comments.
llvm/include/llvm/IR/Module.h
896

It should be enum, similar to PIELevel.

And probably needs IR documentation update?

vitalybuka added inline comments.Thu, Apr 22, 2:26 AM
llvm/lib/IR/Function.cpp
346

Should these be added into Attribute:: ?

MaskRay updated this revision to Diff 339760.Thu, Apr 22, 12:41 PM
MaskRay marked an inline comment as done.

use enum.
add doc.

MaskRay marked an inline comment as done.Thu, Apr 22, 12:43 PM
MaskRay added inline comments.
llvm/lib/IR/Function.cpp
333
346

The function attribute "frame-pointer" is already used, with a string value. A regular attribute cannot have a string value so it was created as the string form...

The documentation is long overdue, though. I have added a bit documentation.

MaskRay marked an inline comment as done.Thu, Apr 22, 12:44 PM
MaskRay added inline comments.Thu, Apr 22, 12:50 PM
llvm/docs/LangRef.rst
7019

I'll add:

These metadata correspond to a few function attributes with significant code generation behaviors. Function attributes with just optimization purposes should not be listed because the performance impact of these synthesized functions is small.

ychen accepted this revision.Thu, Apr 22, 1:19 PM

LGTM

Chatted offline, vitalybuka said I can go ahead with existing ack.

MaskRay updated this revision to Diff 339833.Thu, Apr 22, 6:04 PM

improve doc

This revision was landed with ongoing or failed builds.Thu, Apr 22, 6:07 PM
This revision was automatically updated to reflect the committed changes.