[PATCH] D37656: [cfi] Set function attributes for __cfi_* functions.

Eric Christopher via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 21 18:27:46 PDT 2017


echristo added inline comments.


================
Comment at: clang/lib/CodeGen/CGExpr.cpp:2917
+                                CodeGenFunction &CGF, llvm::Function *F,
+                                bool ForceThumb) {
+  StringRef TargetCPU = CGF.getTarget().getTargetOpts().CPU;
----------------
eugenis wrote:
> echristo wrote:
> > 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.
> 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:
> https://clang.llvm.org/docs/ControlFlowIntegrityDesign.html#cfi-slowpath
> 
> 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?
> 
> 
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.


================
Comment at: clang/lib/CodeGen/CGExpr.cpp:2961-2963
+  // attributes as SetLLVMFunctionAttributes sets. In particular, __cfi_check
+  // must use the default calling convention for the platform. ABI-changing
+  // flags like -mhard-float should not affect __cfi_check.
----------------
eugenis wrote:
> echristo wrote:
> > This is odd. Can you explain this a bit more?
> __cfi_check is called from compiler-rt or libdl.so, 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. 
Yeah, I think this falls in on the earlier comment. Should probably add the defaults to a bit of AST or something?


https://reviews.llvm.org/D37656





More information about the llvm-commits mailing list