[llvm] 930e8de - AMDGPU: Add s-memrealtime and s-memtime-inst to RemoveIncompatibleFunctions

Changpeng Fang via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 22 10:23:32 PDT 2023


Author: Changpeng Fang
Date: 2023-08-22T10:22:41-07:00
New Revision: 930e8dea417879679f3fb92dcff3aa43510558e1

URL: https://github.com/llvm/llvm-project/commit/930e8dea417879679f3fb92dcff3aa43510558e1
DIFF: https://github.com/llvm/llvm-project/commit/930e8dea417879679f3fb92dcff3aa43510558e1.diff

LOG: AMDGPU: Add s-memrealtime and s-memtime-inst to RemoveIncompatibleFunctions

Summary:
 Under -O0, device-libs may still emit these instructions under conditions.
So we need to remove them with warning if not compatible.

Fixes: SWDEV-417219

Reviewers:
  arsenm, Pierre-vh and b-sumner

Differential Revision:
  https://reviews.llvm.org/D158316

Added: 
    llvm/test/CodeGen/AMDGPU/remove-incompatible-s-time.ll

Modified: 
    llvm/lib/Target/AMDGPU/AMDGPURemoveIncompatibleFunctions.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/AMDGPU/AMDGPURemoveIncompatibleFunctions.cpp b/llvm/lib/Target/AMDGPU/AMDGPURemoveIncompatibleFunctions.cpp
index c8ea309e3cb924..e387e16d0cf15d 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPURemoveIncompatibleFunctions.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPURemoveIncompatibleFunctions.cpp
@@ -105,6 +105,8 @@ constexpr unsigned FeaturesToCheck[] = {
     AMDGPU::FeatureDot7Insts,
     AMDGPU::FeatureDot8Insts,
     AMDGPU::FeatureExtendedImageInsts,
+    AMDGPU::FeatureSMemRealTime,
+    AMDGPU::FeatureSMemTimeInst
 };
 
 FeatureBitset expandImpliedFeatures(const FeatureBitset &Features) {

diff  --git a/llvm/test/CodeGen/AMDGPU/remove-incompatible-s-time.ll b/llvm/test/CodeGen/AMDGPU/remove-incompatible-s-time.ll
new file mode 100644
index 00000000000000..3ced15b1acc334
--- /dev/null
+++ b/llvm/test/CodeGen/AMDGPU/remove-incompatible-s-time.ll
@@ -0,0 +1,72 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -march=amdgcn -mcpu=gfx1030 -stop-after=amdgpu-remove-incompatible-functions\
+; RUN:   -pass-remarks=amdgpu-remove-incompatible-functions %s -o - 2>%t | FileCheck -check-prefixes=COMPATIBLE,REALTIME,MEMTIME %s
+; RUN: FileCheck -allow-empty --check-prefixes=WARN-REALTIME,WARN-MEMTIME %s < %t
+; RUN: llc -march=amdgcn -mcpu=gfx1030 -verify-machineinstrs < %s
+
+; RUN: llc -march=amdgcn -mcpu=gfx1102 -stop-after=amdgpu-remove-incompatible-functions\
+; RUN:   -pass-remarks=amdgpu-remove-incompatible-functions %s -o - 2>%t | FileCheck -check-prefixes=INCOMPATIBLE,NOREALTIME,NOMEMTIME %s
+; RUN: FileCheck --check-prefixes=WARN-NOREALTIME,WARN-NOMEMTIME %s < %t
+; RUN: llc -march=amdgcn -mcpu=gfx1102 -verify-machineinstrs < %s
+
+; Note: This test checks the IR, but also has a run line to codegen the file just to check we
+; do not crash when trying to select those functions.
+
+; WARN-REALTIME-NOT: removing function 'needs_s_memrealtime':
+; WARN-MEMTIME-NOT:  removing function 'needs_s_memtime':
+; WARN-NOREALTIME:   removing function 'needs_s_memrealtime': +s-memrealtime is not supported on the current target
+; WARN-NOMEMTIME:    removing function 'needs_s_memtime': +s-memtime-inst is not supported on the current target
+
+; COMPATIBLE:       @GVRefs  {{.*}} [ptr @needs_s_memrealtime, ptr @needs_s_memtime]
+; INCOMPATIBLE:     @GVRefs {{.*}} zeroinitializer
+ at GVRefs = internal global [2 x ptr] [
+  ptr @needs_s_memrealtime,
+  ptr @needs_s_memtime
+]
+
+; REALTIME:    @ConstantExpr0 = internal global i64 ptrtoint (ptr @needs_s_memrealtime to i64)
+; NOREALTIME:  @ConstantExpr0 = internal global i64 0
+ at ConstantExpr0 = internal global i64 ptrtoint (ptr @needs_s_memrealtime to i64)
+
+; MEMTIME:     @ConstantExpr1 = internal global i64 ptrtoint (ptr @needs_s_memtime to i64)
+; NOMEMTIME:   @ConstantExpr1 = internal global i64 0
+ at ConstantExpr1 = internal global i64 ptrtoint (ptr @needs_s_memtime to i64)
+
+; REALTIME:         define i64 @needs_s_memrealtime
+; NOREALTIME-NOT:   define i64 @needs_s_memrealtime
+define i64 @needs_s_memrealtime() #0 {
+  %t = tail call i64 @llvm.amdgcn.s.memrealtime()
+  ret i64 %t
+}
+
+; IR: define void @s_memrealtime_caller(
+define i64 @s_memrealtime_caller() {
+  ; REALTIME: call i64 @needs_s_memrealtime(
+  ; NOREALTIME: call i64 null
+  %t = call i64 @needs_s_memrealtime()
+  ; IR: ret i64 %t
+  ret i64 %t
+}
+
+; MEMTIME:         define i64 @needs_s_memtime
+; NOMEMTIME-NOT:   define i64 @needs_s_memtime
+define i64 @needs_s_memtime() #1 {
+  %t = tail call i64 @llvm.amdgcn.s.memtime()
+  ret i64 %t
+}
+
+; IR: define void @s_memtime_caller(
+define i64 @s_memtime_caller() {
+  ; MEMTIME: call i64 @needs_s_memtime(
+  ; NOMEMTIME: call i64 null
+  %t = call i64 @needs_s_memtime()
+  ; IR: ret i64 %t
+  ret i64 %t
+}
+
+
+declare i64 @llvm.amdgcn.s.memrealtime()
+declare i64 @llvm.amdgcn.s.memtime()
+
+attributes #0 = { "target-features"="+s-memrealtime"}
+attributes #1 = { "target-features"="+s-memtime-inst"}


        


More information about the llvm-commits mailing list