[llvm] 12ca031 - [DirectX][Fail crash in DXILPrepareModule pass when input has typed ptr.

Xiang Li via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 7 21:11:30 PDT 2022


Author: python3kgae
Date: 2022-06-07T21:11:24-07:00
New Revision: 12ca031b0d1b5390698d15efea8ff4a829173f4b

URL: https://github.com/llvm/llvm-project/commit/12ca031b0d1b5390698d15efea8ff4a829173f4b
DIFF: https://github.com/llvm/llvm-project/commit/12ca031b0d1b5390698d15efea8ff4a829173f4b.diff

LOG: [DirectX][Fail crash in DXILPrepareModule pass when input has typed ptr.

Check supportsTypedPointers instead of hasSetOpaquePointersValue when query if has typed ptr.

Reviewed By: beanz

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

Added: 
    llvm/test/CodeGen/DirectX/typed_ptr.ll

Modified: 
    llvm/lib/Target/DirectX/DXILPrepare.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Target/DirectX/DXILPrepare.cpp b/llvm/lib/Target/DirectX/DXILPrepare.cpp
index 73420e3094f5..14d970e6b69a 100644
--- a/llvm/lib/Target/DirectX/DXILPrepare.cpp
+++ b/llvm/lib/Target/DirectX/DXILPrepare.cpp
@@ -127,7 +127,7 @@ class DXILPrepareModule : public ModulePass {
             continue;
           }
           // Only insert bitcasts if the IR is using opaque pointers.
-          if (!M.getContext().hasSetOpaquePointersValue())
+          if (M.getContext().supportsTypedPointers())
             continue;
 
           // Emtting NoOp bitcast instructions allows the ValueEnumerator to be

diff  --git a/llvm/test/CodeGen/DirectX/typed_ptr.ll b/llvm/test/CodeGen/DirectX/typed_ptr.ll
new file mode 100644
index 000000000000..5a9610cf87af
--- /dev/null
+++ b/llvm/test/CodeGen/DirectX/typed_ptr.ll
@@ -0,0 +1,10 @@
+; RUN: opt -S -dxil-prepare < %s | FileCheck %s
+target triple = "dxil-unknown-unknown"
+
+; Make sure not crash when has typed ptr.
+; CHECK:@test
+
+define i64 @test(i64* %p) {
+  %v = load i64, i64* %p
+  ret i64 %v
+}


        


More information about the llvm-commits mailing list