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

Xiang Li via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 7 19:10:26 PDT 2022


python3kgae created this revision.
python3kgae added reviewers: beanz, MaskRay, tstellar, pete, jdoerfert, sheredom, kuhar, antiagainst, nhaehnle, rnk, nikic.
Herald added subscribers: StephenFan, hiraditya.
Herald added a project: All.
python3kgae requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127268

Files:
  llvm/lib/Target/DirectX/DXILPrepare.cpp
  llvm/test/CodeGen/DirectX/typed_ptr.ll


Index: llvm/test/CodeGen/DirectX/typed_ptr.ll
===================================================================
--- /dev/null
+++ 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
+}
\ No newline at end of file
Index: llvm/lib/Target/DirectX/DXILPrepare.cpp
===================================================================
--- llvm/lib/Target/DirectX/DXILPrepare.cpp
+++ llvm/lib/Target/DirectX/DXILPrepare.cpp
@@ -127,7 +127,7 @@
             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


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127268.435024.patch
Type: text/x-patch
Size: 990 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220608/eb738578/attachment.bin>


More information about the llvm-commits mailing list