[PATCH] D137700: [reg2mem]Skip token-producing Instructions

Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 12 20:11:08 PST 2022


Naville updated this revision to Diff 474979.
Naville added a comment.

Update test case


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137700/new/

https://reviews.llvm.org/D137700

Files:
  llvm/lib/Transforms/Scalar/Reg2Mem.cpp
  llvm/test/Transforms/Reg2Mem/catchswitch-crash.ll
  llvm/test/Transforms/Reg2Mem/non-token-test.ll


Index: llvm/test/Transforms/Reg2Mem/non-token-test.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/Reg2Mem/non-token-test.ll
@@ -0,0 +1,23 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+;RUN: opt -passes=reg2mem -S < %s | FileCheck %s
+%opaque = type opaque
+
+declare %opaque @ret_opaque()
+declare void @pass_opaque(%opaque)
+
+define void @test() {
+; CHECK-LABEL: @test(
+; CHECK-NEXT:    %"reg2mem alloca point" = bitcast i32 0 to i32
+; CHECK-NEXT:    [[X:%.*]] = call [[OPAQUE:%.*]] @ret_opaque()
+; CHECK-NEXT:    br label [[NEXT:%.*]]
+; CHECK:       next:
+; CHECK-NEXT:    call void @pass_opaque([[OPAQUE]] [[X]])
+; CHECK-NEXT:    ret void
+;
+  %x = call %opaque @ret_opaque()
+  br label %next
+
+next:
+  call void @pass_opaque(%opaque %x)
+  ret void
+}
Index: llvm/test/Transforms/Reg2Mem/catchswitch-crash.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/Reg2Mem/catchswitch-crash.ll
@@ -0,0 +1,21 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
+;RUN: opt -passes=reg2mem -S < %s | FileCheck %s
+declare void @"?read_mem@@YAXPEAD0_K at Z"()
+
+define void @"?memcpy_seh@@YA_NPEAX_KPEBX1 at Z"() personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) {
+entry:
+  invoke void @"?read_mem@@YAXPEAD0_K at Z"()
+  to label %cleanup unwind label %catch.dispatch
+
+catch.dispatch:                                   ; preds = %entry
+  %0 = catchswitch within none [label %__except] unwind to caller
+
+__except:                                         ; preds = %catch.dispatch
+  %1 = catchpad within %0 [i8* null]
+  unreachable
+
+cleanup:                                          ; preds = %entry
+  ret void
+}
+
+declare i32 @__C_specific_handler(...)
Index: llvm/lib/Transforms/Scalar/Reg2Mem.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/Reg2Mem.cpp
+++ llvm/lib/Transforms/Scalar/Reg2Mem.cpp
@@ -40,6 +40,9 @@
 STATISTIC(NumPhisDemoted, "Number of phi-nodes demoted");
 
 static bool valueEscapes(const Instruction &Inst) {
+  if (!Inst.getType()->isSized())
+    return false;
+
   const BasicBlock *BB = Inst.getParent();
   for (const User *U : Inst.users()) {
     const Instruction *UI = cast<Instruction>(U);


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137700.474979.patch
Type: text/x-patch
Size: 2382 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221113/acfadb6d/attachment.bin>


More information about the llvm-commits mailing list