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

Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 9 18:02:12 PST 2022


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

Reformat to silent git-clang-format


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


Index: llvm/test/Transforms/Reg2Mem/catchswitch-crash.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/Reg2Mem/catchswitch-crash.ll
@@ -0,0 +1,33 @@
+; RUN: opt -passes=reg2mem -disable-output < %s
+
+; ModuleID = 'bugpoint-reduced-simplified.bc'
+source_filename = "Test.cpp"
+target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-pc-windows-msvc19.29.30140"
+
+declare dso_local void @"?read_mem@@YAXPEAD0_K at Z"() local_unnamed_addr #0
+
+define dso_local void @"?memcpy_seh@@YA_NPEAX_KPEBX1 at Z"() local_unnamed_addr #0 personality i8* bitcast (i32 (...)* @__C_specific_handler to i8*) {
+entry:
+  invoke void @"?read_mem@@YAXPEAD0_K at Z"() #1
+          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 dso_local i32 @__C_specific_handler(...)
+
+attributes #0 = { "tune-cpu"="generic" }
+attributes #1 = { noinline }
+
+!llvm.ident = !{!0}
+
+!0 = !{!"clang version 14.0.6 (https://github.com/llvm/llvm-project.git f28c006a5895fc0e329fe15fead81e37457cb1d1)"}
\ No newline at end of file
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()->isTokenTy()) {
+    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.474404.patch
Type: text/x-patch
Size: 2005 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221110/2dcbd4c9/attachment.bin>


More information about the llvm-commits mailing list