[llvm] r355051 - AMDGPU: Enable function calls by default

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 27 16:40:33 PST 2019


Author: arsenm
Date: Wed Feb 27 16:40:32 2019
New Revision: 355051

URL: http://llvm.org/viewvc/llvm-project?rev=355051&view=rev
Log:
AMDGPU: Enable function calls by default

Fixes some crashes on illegal call situations which are unfortunately
still valid IR.

Added:
    llvm/trunk/test/CodeGen/AMDGPU/amdgpu-function-calls-option.ll
Modified:
    llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
    llvm/trunk/test/CodeGen/AMDGPU/amdgpu-inline.ll
    llvm/trunk/test/CodeGen/AMDGPU/call-graph-register-usage.ll
    llvm/trunk/test/CodeGen/AMDGPU/force-alwaysinline-lds-global-address.ll
    llvm/trunk/test/CodeGen/AMDGPU/inline-calls.ll

Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp?rev=355051&r1=355050&r2=355051&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp Wed Feb 27 16:40:32 2019
@@ -122,11 +122,11 @@ static cl::opt<bool, true> LateCFGStruct
   cl::location(AMDGPUTargetMachine::EnableLateStructurizeCFG),
   cl::Hidden);
 
-static cl::opt<bool, true> EnableAMDGPUFunctionCalls(
+static cl::opt<bool, true> EnableAMDGPUFunctionCallsOpt(
   "amdgpu-function-calls",
   cl::desc("Enable AMDGPU function call support"),
   cl::location(AMDGPUTargetMachine::EnableFunctionCalls),
-  cl::init(false),
+  cl::init(true),
   cl::Hidden);
 
 // Enable lib calls simplifications
@@ -361,11 +361,11 @@ void AMDGPUTargetMachine::adjustPassMana
 
   bool EnableOpt = getOptLevel() > CodeGenOpt::None;
   bool Internalize = InternalizeSymbols;
-  bool EarlyInline = EarlyInlineAll && EnableOpt && !EnableAMDGPUFunctionCalls;
+  bool EarlyInline = EarlyInlineAll && EnableOpt && !EnableFunctionCalls;
   bool AMDGPUAA = EnableAMDGPUAliasAnalysis && EnableOpt;
   bool LibCallSimplify = EnableLibCallSimplify && EnableOpt;
 
-  if (EnableAMDGPUFunctionCalls) {
+  if (EnableFunctionCalls) {
     delete Builder.Inliner;
     Builder.Inliner = createAMDGPUFunctionInliningPass();
   }
@@ -426,6 +426,11 @@ R600TargetMachine::R600TargetMachine(con
                                      CodeGenOpt::Level OL, bool JIT)
     : AMDGPUTargetMachine(T, TT, CPU, FS, Options, RM, CM, OL) {
   setRequiresStructuredCFG(true);
+
+  // Override the default since calls aren't ssupported for r600.
+  if (EnableFunctionCalls &&
+      EnableAMDGPUFunctionCallsOpt.getNumOccurrences() == 0)
+    EnableFunctionCalls = false;
 }
 
 const R600Subtarget *R600TargetMachine::getSubtargetImpl(

Added: llvm/trunk/test/CodeGen/AMDGPU/amdgpu-function-calls-option.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/amdgpu-function-calls-option.ll?rev=355051&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/amdgpu-function-calls-option.ll (added)
+++ llvm/trunk/test/CodeGen/AMDGPU/amdgpu-function-calls-option.ll Wed Feb 27 16:40:32 2019
@@ -0,0 +1,27 @@
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -amdgpu-function-calls < %s | FileCheck -check-prefix=CALLS %s
+; RUN: llc -mtriple=amdgcn-amd-amdhsa < %s | FileCheck -check-prefix=CALLS %s
+; RUN: llc -mtriple=amdgcn-amd-amdhsa -amdgpu-function-calls=0 < %s | FileCheck -check-prefix=NOCALLS %s
+; RUN: llc -mtriple=r600-mesa-mesa3d < %s | FileCheck -check-prefix=NOCALLS %s
+; RUN: llc -mtriple=r600-mesa-mesa3d -amdgpu-function-calls=0 < %s | FileCheck -check-prefix=NOCALLS %s
+
+; CALLS-LABEL: callee:
+; CALLS: ;;#ASMSTART
+; CALLS: ;;#ASMEND
+
+; NOCALLS-NOT: callee
+; R600-NOT: callee
+define internal void @callee() {
+  call void asm sideeffect "", ""()
+  ret void
+}
+
+; CALLS-LABEL: kernel:
+; CALLS: s_swappc_b64
+
+; NOCALLS-LABEL: kernel:
+; NOCALLS: ;;#ASMSTART
+; NOCALLS: ;;#ASMEND
+define amdgpu_kernel void @kernel() {
+  call void @callee()
+  ret void
+}

Modified: llvm/trunk/test/CodeGen/AMDGPU/amdgpu-inline.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/amdgpu-inline.ll?rev=355051&r1=355050&r2=355051&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/amdgpu-inline.ll (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/amdgpu-inline.ll Wed Feb 27 16:40:32 2019
@@ -1,5 +1,5 @@
-; RUN: opt -mtriple=amdgcn--amdhsa -data-layout=A5 -O3 -S -amdgpu-function-calls -inline-threshold=1 < %s | FileCheck -check-prefix=GCN -check-prefix=GCN-INL1 %s
-; RUN: opt -mtriple=amdgcn--amdhsa -data-layout=A5 -O3 -S -amdgpu-function-calls < %s | FileCheck -check-prefix=GCN -check-prefix=GCN-INLDEF %s
+; RUN: opt -mtriple=amdgcn--amdhsa -data-layout=A5 -O3 -S -inline-threshold=1 < %s | FileCheck -check-prefix=GCN -check-prefix=GCN-INL1 %s
+; RUN: opt -mtriple=amdgcn--amdhsa -data-layout=A5 -O3 -S < %s | FileCheck -check-prefix=GCN -check-prefix=GCN-INLDEF %s
 
 define coldcc float @foo(float %x, float %y) {
 entry:

Modified: llvm/trunk/test/CodeGen/AMDGPU/call-graph-register-usage.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/call-graph-register-usage.ll?rev=355051&r1=355050&r2=355051&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/call-graph-register-usage.ll (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/call-graph-register-usage.ll Wed Feb 27 16:40:32 2019
@@ -84,7 +84,7 @@ define void @indirect_use_10_vgpr() #0 {
 
 ; GCN-LABEL: {{^}}indirect_2_level_use_10_vgpr:
 ; GCN: is_dynamic_callstack = 0
-; GCN: ; NumVgprs: 10
+; GCN: ; NumVgprs: 33
 define amdgpu_kernel void @indirect_2_level_use_10_vgpr() #0 {
   call void @indirect_use_10_vgpr()
   ret void
@@ -225,6 +225,6 @@ define amdgpu_kernel void @usage_direct_
 }
 
 
-attributes #0 = { nounwind norecurse }
+attributes #0 = { nounwind noinline norecurse }
 attributes #1 = { nounwind noinline norecurse }
 attributes #2 = { nounwind noinline }

Modified: llvm/trunk/test/CodeGen/AMDGPU/force-alwaysinline-lds-global-address.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/force-alwaysinline-lds-global-address.ll?rev=355051&r1=355050&r2=355051&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/force-alwaysinline-lds-global-address.ll (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/force-alwaysinline-lds-global-address.ll Wed Feb 27 16:40:32 2019
@@ -1,5 +1,5 @@
-; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -amdgpu-function-calls -amdgpu-always-inline %s | FileCheck -check-prefixes=CALLS-ENABLED,ALL %s
-; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -amdgpu-function-calls -amdgpu-stress-function-calls -amdgpu-always-inline %s | FileCheck -check-prefixes=STRESS-CALLS,ALL %s
+; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -amdgpu-always-inline %s | FileCheck -check-prefixes=CALLS-ENABLED,ALL %s
+; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -amdgpu-stress-function-calls -amdgpu-always-inline %s | FileCheck -check-prefixes=STRESS-CALLS,ALL %s
 
 target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
 

Modified: llvm/trunk/test/CodeGen/AMDGPU/inline-calls.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/inline-calls.ll?rev=355051&r1=355050&r2=355051&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/inline-calls.ll (original)
+++ llvm/trunk/test/CodeGen/AMDGPU/inline-calls.ll Wed Feb 27 16:40:32 2019
@@ -2,15 +2,15 @@
 ; RUN: llc -march=amdgcn -mcpu=tonga -verify-machineinstrs < %s | FileCheck  %s
 ; RUN: llc -march=r600 -mcpu=redwood -verify-machineinstrs < %s | FileCheck %s
 
-; CHECK-NOT: {{^}}func:
+; ALL-NOT: {{^}}func:
 define internal i32 @func(i32 %a) {
 entry:
   %tmp0 = add i32 %a, 1
   ret i32 %tmp0
 }
 
-; CHECK: {{^}}kernel:
-; CHECK-NOT: call
+; ALL: {{^}}kernel:
+; GCN-NOT: s_swappc_b64
 define amdgpu_kernel void @kernel(i32 addrspace(1)* %out) {
 entry:
   %tmp0 = call i32 @func(i32 1)
@@ -19,10 +19,11 @@ entry:
 }
 
 ; CHECK-NOT: func_alias
+; ALL-NOT: func_alias
 @func_alias = alias i32 (i32), i32 (i32)* @func
 
-; CHECK: {{^}}kernel3:
-; CHECK-NOT: call
+; ALL: {{^}}kernel3:
+; GCN-NOT: s_swappc_b64
 define amdgpu_kernel void @kernel3(i32 addrspace(1)* %out) {
 entry:
   %tmp0 = call i32 @func_alias(i32 1)




More information about the llvm-commits mailing list