[PATCH] D43178: [FunctionAttrs][ArgumentPromotion][GlobalOpt] Disable some optimisations passes for naked functions
Luke Cheeseman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 14 06:32:13 PST 2018
LukeCheeseman added a comment.
This suggestion makes sense to me. However, I have been looking into optnone and naked and I'm not sure whether they apply in the same way for inter procedural optimisations after reading https://reviews.llvm.org/D1288. An example of this is as follows:
$ cat test.ll
define internal i32 @foo(i32*) #0 {
entry:
%retval = alloca i32, align 4
unreachable
}
attributes #0 = { optnone noinline }
$ /work/llvm/svn+release/bin/opt -deadargelim naked.ll -S
; ModuleID = 'test.ll'
source_filename = "test.ll"
; Function Attrs: noinline optnone
define internal void @foo() #0 {
entry:
%retval = alloca i32, align 4
unreachable
}
attributes #0 = { noinline optnone }
The argument from `foo` has been removed, whereas if we make the function as naked the result is different:
$ /work/llvm/svn+release/bin/opt -deadargelim naked.ll -S
; ModuleID = 'test.ll'
source_filename = "test.ll"
; Function Attrs: naked
define internal i32 @foo(i32*) #0 {
entry:
%retval = alloca i32, align 4
unreachable
}
attributes #0 = { naked }
I'm not sure whether this is a bug in deadargument elimination or is the expected behavior of optnone. Reading the description of optnone I would think it was the latter but this is reading a description from 5 years ago, in which case I'm not sure we would be able to introduce such a helper. The clang documentation <https://clang.llvm.org/docs/AttributeReference.html#optnone-clang-optnone> on optnone is not explicit as to whether the prototypes are subject to change or not.
I'd like to hear your thoughts on this.
Repository:
rL LLVM
https://reviews.llvm.org/D43178
More information about the llvm-commits
mailing list