[llvm] r278369 - AMDGPU: Fix crashes on memory functions

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 11 10:31:43 PDT 2016


Author: arsenm
Date: Thu Aug 11 12:31:42 2016
New Revision: 278369

URL: http://llvm.org/viewvc/llvm-project?rev=278369&view=rev
Log:
AMDGPU: Fix crashes on memory functions

Added:
    llvm/trunk/test/CodeGen/AMDGPU/mem-builtins.ll
Modified:
    llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
    llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.h

Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.cpp?rev=278369&r1=278368&r2=278369&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.cpp (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.cpp Thu Aug 11 12:31:42 2016
@@ -116,7 +116,8 @@ AMDGPUSubtarget::AMDGPUSubtarget(const T
     TexVTXClauseSize(0),
 
     FeatureDisable(false),
-    InstrItins(getInstrItineraryForCPU(GPU)) {
+    InstrItins(getInstrItineraryForCPU(GPU)),
+    TSInfo() {
   initializeSubtargetDependencies(TT, GPU, FS);
 }
 

Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.h?rev=278369&r1=278368&r2=278369&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.h (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUSubtarget.h Thu Aug 11 12:31:42 2016
@@ -24,6 +24,7 @@
 #include "SIFrameLowering.h"
 #include "Utils/AMDGPUBaseInfo.h"
 #include "llvm/CodeGen/GlobalISel/GISelAccessor.h"
+#include "llvm/CodeGen/SelectionDAGTargetInfo.h"
 #include "llvm/Target/TargetSubtargetInfo.h"
 
 #define GET_SUBTARGETINFO_HEADER
@@ -108,6 +109,7 @@ protected:
   bool FeatureDisable;
 
   InstrItineraryData InstrItins;
+  SelectionDAGTargetInfo TSInfo;
 
 public:
   AMDGPUSubtarget(const Triple &TT, StringRef GPU, StringRef FS,
@@ -125,6 +127,11 @@ public:
     return &InstrItins;
   }
 
+  // Nothing implemented, just prevent crashes on use.
+  const SelectionDAGTargetInfo *getSelectionDAGInfo() const override {
+    return &TSInfo;
+  }
+
   void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
 
   bool isAmdHsaOS() const {

Added: llvm/trunk/test/CodeGen/AMDGPU/mem-builtins.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AMDGPU/mem-builtins.ll?rev=278369&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AMDGPU/mem-builtins.ll (added)
+++ llvm/trunk/test/CodeGen/AMDGPU/mem-builtins.ll Thu Aug 11 12:31:42 2016
@@ -0,0 +1,54 @@
+; RUN: not llc -march=amdgcn -verify-machineinstrs < %s 2>&1 | FileCheck -check-prefix=ERROR %s
+
+declare i32 @memcmp(i8 addrspace(1)* readonly nocapture, i8 addrspace(1)* readonly nocapture, i64) #0
+declare i8 addrspace(1)* @memchr(i8 addrspace(1)* readonly nocapture, i32, i64) #1
+declare i8* @strcpy(i8* nocapture, i8* readonly nocapture) #0
+declare i32 @strlen(i8* nocapture) #1
+declare i32 @strnlen(i8* nocapture, i32) #1
+declare i32 @strcmp(i8* nocapture, i8* nocapture) #1
+
+
+; ERROR: error: <unknown>:0:0: in function test_memcmp void (i8 addrspace(1)*, i8 addrspace(1)*, i32*): unsupported call to function memcmp
+define void @test_memcmp(i8 addrspace(1)* %x, i8 addrspace(1)* %y, i32* nocapture %p) #0 {
+entry:
+  %cmp = tail call i32 @memcmp(i8 addrspace(1)* %x, i8 addrspace(1)* %y, i64 2)
+  store volatile i32 %cmp, i32 addrspace(1)* undef
+  ret void
+}
+
+; ERROR: error: <unknown>:0:0: in function test_memchr void (i8 addrspace(1)*, i32, i64): unsupported call to function memchr
+define void @test_memchr(i8 addrspace(1)* %src, i32 %char, i64 %len) #0 {
+  %res = call i8 addrspace(1)* @memchr(i8 addrspace(1)* %src, i32 %char, i64 %len)
+  store volatile i8 addrspace(1)* %res, i8 addrspace(1)* addrspace(1)* undef
+  ret void
+}
+
+; ERROR: error: <unknown>:0:0: in function test_strcpy void (i8*, i8*): unsupported call to function strcpy
+define void @test_strcpy(i8* %dst, i8* %src) #0 {
+  %res = call i8* @strcpy(i8* %dst, i8* %src)
+  store volatile i8* %res, i8* addrspace(1)* undef
+  ret void
+}
+
+; ERROR: error: <unknown>:0:0: in function test_strcmp void (i8*, i8*): unsupported call to function strcmp
+define void @test_strcmp(i8* %src0, i8* %src1) #0 {
+  %res = call i32 @strcmp(i8* %src0, i8* %src1)
+  store volatile i32 %res, i32 addrspace(1)* undef
+  ret void
+}
+
+; ERROR: error: <unknown>:0:0: in function test_strlen void (i8*): unsupported call to function strlen
+define void @test_strlen(i8* %src) #0 {
+  %res = call i32 @strlen(i8* %src)
+  store volatile i32 %res, i32 addrspace(1)* undef
+  ret void
+}
+
+; ERROR: error: <unknown>:0:0: in function test_strnlen void (i8*, i32): unsupported call to function strnlen
+define void @test_strnlen(i8* %src, i32 %size) #0 {
+  %res = call i32 @strnlen(i8* %src, i32 %size)
+  store volatile i32 %res, i32 addrspace(1)* undef
+  ret void
+}
+
+attributes #0 = { nounwind }




More information about the llvm-commits mailing list