Page MenuHomePhabricator

[cfi] Set function attributes for __cfi_* functions.
Needs ReviewPublic

Authored by eugenis on Sep 8 2017, 5:57 PM.



Set target_cpu and target_features attributes on cfi_check_fail and
cfi_check. Make cfi_check use Thumb encoding on ARM target.

Event Timeline

eugenis created this revision.Sep 8 2017, 5:57 PM
echristo added inline comments.Sep 21 2017, 5:36 PM

I don't think we should be force setting thumb anywhere, it should be handled on a function by function basis the way we do all of the target attribute stuff.


All of this should be handled in lib/Basic/Targets/ARM.cpp ARMTargetInfo::initFeatureMap ?


This is odd. Can you explain this a bit more?

eugenis added inline comments.Sep 21 2017, 5:57 PM

We want this function to be Thumb even if the rest of the module is ARM. It lets us use 2x less memory in the implementation of __cfi_slowpath here:

This function does not have source, so it can not have target attributes, too.

Are you suggesting faking a piece of AST (FunctionDecl with attached attributes) and then using the regular attribute setting code?


__cfi_check is called from compiler-rt or, so it can not have any fancy calling convention. It must use what's standard on the platform.

OK, __cfi_check has no floating-point parameters, so -mhard-float would not be a problem.

echristo added inline comments.Sep 21 2017, 6:27 PM

Aha. Didn't remember that part of the design.

And yeah, that sounds good. And it doesn't really matter if the function has any source code as to whether or not it has attributes. There's no inheritance structure going on here so every function should have them.


Yeah, I think this falls in on the earlier comment. Should probably add the defaults to a bit of AST or something?

eugenis updated this revision to Diff 116618.Sep 25 2017, 2:38 PM

Switched to SetLLVMFunctionAttributes