[PATCH] R600: Fix always inline pass breaking noinline functions

Tom Stellard tom at stellard.net
Wed Apr 22 08:24:09 PDT 2015


LGTM.

On Tue, Apr 21, 2015 at 01:07:52AM +0000, Matt Arsenault wrote:
> No test since calls are not actually supported yet.
> 
> http://reviews.llvm.org/D9135
> 
> Files:
>   lib/Target/R600/AMDGPUAlwaysInlinePass.cpp
>   test/CodeGen/R600/call.ll
> 
> Index: lib/Target/R600/AMDGPUAlwaysInlinePass.cpp
> ===================================================================
> --- lib/Target/R600/AMDGPUAlwaysInlinePass.cpp
> +++ lib/Target/R600/AMDGPUAlwaysInlinePass.cpp
> @@ -40,7 +40,8 @@
>    std::vector<Function*> FuncsToClone;
>    for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
>      Function &F = *I;
> -    if (!F.hasLocalLinkage() && !F.isDeclaration() && !F.use_empty())
> +    if (!F.hasLocalLinkage() && !F.isDeclaration() && !F.use_empty() &&
> +        !F.hasFnAttribute(Attribute::NoInline))
>        FuncsToClone.push_back(&F);
>    }
>  
> @@ -54,7 +55,7 @@
>  
>    for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
>      Function &F = *I;
> -    if (F.hasLocalLinkage()) {
> +    if (F.hasLocalLinkage() && !F.hasFnAttribute(Attribute::NoInline)) {
>        F.addFnAttr(Attribute::AlwaysInline);
>      }
>    }
> Index: test/CodeGen/R600/call.ll
> ===================================================================
> --- test/CodeGen/R600/call.ll
> +++ test/CodeGen/R600/call.ll
> @@ -7,28 +7,27 @@
>  
>  declare i32 @external_function(i32) nounwind
>  
> -define i32 @defined_function(i32 %x) nounwind noinline {
> -  %y = add i32 %x, 8
> -  ret i32 %y
> -}
> -
> -define void @test_call(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
> +define void @test_call_external(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
>    %b_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
>    %a = load i32, i32 addrspace(1)* %in
>    %b = load i32, i32 addrspace(1)* %b_ptr
> -  %c = call i32 @defined_function(i32 %b) nounwind
> +  %c = call i32 @external_function(i32 %b) nounwind
>    %result = add i32 %a, %c
>    store i32 %result, i32 addrspace(1)* %out
>    ret void
>  }
>  
> -define void @test_call_external(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
> +define i32 @defined_function(i32 %x) nounwind noinline {
> +  %y = add i32 %x, 8
> +  ret i32 %y
> +}
> +
> +define void @test_call(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
>    %b_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
>    %a = load i32, i32 addrspace(1)* %in
>    %b = load i32, i32 addrspace(1)* %b_ptr
> -  %c = call i32 @external_function(i32 %b) nounwind
> +  %c = call i32 @defined_function(i32 %b) nounwind
>    %result = add i32 %a, %c
>    store i32 %result, i32 addrspace(1)* %out
>    ret void
>  }
> -
> 
> EMAIL PREFERENCES
>   http://reviews.llvm.org/settings/panel/emailpreferences/

> Index: lib/Target/R600/AMDGPUAlwaysInlinePass.cpp
> ===================================================================
> --- lib/Target/R600/AMDGPUAlwaysInlinePass.cpp
> +++ lib/Target/R600/AMDGPUAlwaysInlinePass.cpp
> @@ -40,7 +40,8 @@
>    std::vector<Function*> FuncsToClone;
>    for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
>      Function &F = *I;
> -    if (!F.hasLocalLinkage() && !F.isDeclaration() && !F.use_empty())
> +    if (!F.hasLocalLinkage() && !F.isDeclaration() && !F.use_empty() &&
> +        !F.hasFnAttribute(Attribute::NoInline))
>        FuncsToClone.push_back(&F);
>    }
>  
> @@ -54,7 +55,7 @@
>  
>    for (Module::iterator I = M.begin(), E = M.end(); I != E; ++I) {
>      Function &F = *I;
> -    if (F.hasLocalLinkage()) {
> +    if (F.hasLocalLinkage() && !F.hasFnAttribute(Attribute::NoInline)) {
>        F.addFnAttr(Attribute::AlwaysInline);
>      }
>    }
> Index: test/CodeGen/R600/call.ll
> ===================================================================
> --- test/CodeGen/R600/call.ll
> +++ test/CodeGen/R600/call.ll
> @@ -7,28 +7,27 @@
>  
>  declare i32 @external_function(i32) nounwind
>  
> -define i32 @defined_function(i32 %x) nounwind noinline {
> -  %y = add i32 %x, 8
> -  ret i32 %y
> -}
> -
> -define void @test_call(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
> +define void @test_call_external(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
>    %b_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
>    %a = load i32, i32 addrspace(1)* %in
>    %b = load i32, i32 addrspace(1)* %b_ptr
> -  %c = call i32 @defined_function(i32 %b) nounwind
> +  %c = call i32 @external_function(i32 %b) nounwind
>    %result = add i32 %a, %c
>    store i32 %result, i32 addrspace(1)* %out
>    ret void
>  }
>  
> -define void @test_call_external(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
> +define i32 @defined_function(i32 %x) nounwind noinline {
> +  %y = add i32 %x, 8
> +  ret i32 %y
> +}
> +
> +define void @test_call(i32 addrspace(1)* %out, i32 addrspace(1)* %in) {
>    %b_ptr = getelementptr i32, i32 addrspace(1)* %in, i32 1
>    %a = load i32, i32 addrspace(1)* %in
>    %b = load i32, i32 addrspace(1)* %b_ptr
> -  %c = call i32 @external_function(i32 %b) nounwind
> +  %c = call i32 @defined_function(i32 %b) nounwind
>    %result = add i32 %a, %c
>    store i32 %result, i32 addrspace(1)* %out
>    ret void
>  }
> -

> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list