From 6c1e6bbe0c609489ef49f9d64f1370a43e05c19c Mon Sep 17 00:00:00 2001 From: Luke Cheeseman Date: Thu, 22 Feb 2018 14:42:08 +0000 Subject: [FunctionAttrs][ArgumentPromotion][GlobalOpt] Disable some optimisations passes for naked functions - Fix for bug 36078. - Prevent the functionattrs, function-attrs, globalopt and argpromotion passes from changing naked functions. - These passes can perform some alterations to the functions that should not be applied. An example is removing parameters that are seemingly not used because they are only referenced in the inline assembly. Another example is marking the function as fastcc. llvm-svn: 325788 --- llvm/lib/Transforms/IPO/ArgumentPromotion.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'llvm/lib/Transforms/IPO/ArgumentPromotion.cpp') diff --git a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp index d3a7b0e76fe..461c4e12cbd 100644 --- a/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp +++ b/llvm/lib/Transforms/IPO/ArgumentPromotion.cpp @@ -817,6 +817,12 @@ promoteArguments(Function *F, function_ref AARGetter, unsigned MaxElements, Optional> ReplaceCallSite) { + // Don't perform argument promotion for naked functions; otherwise we can end + // up removing parameters that are seemingly 'not used' as they are referred + // to in the assembly. + if(F->hasFnAttribute(Attribute::Naked)) + return nullptr; + // Make sure that it is local to this module. if (!F->hasLocalLinkage()) return nullptr; -- cgit v1.2.3