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

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 11 06:15:49 PST 2022


nikic added a reviewer: nikic.
nikic added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/Reg2Mem.cpp:43
 static bool valueEscapes(const Instruction &Inst) {
+  if (Inst.getType()->isTokenTy()) {
+    return false;
----------------
Check `!Inst.getType()->isSized()` instead. Also drop the `{}` for single-line if.

You can add this to your test case to test a non-token unsized value:
```
%opaque = type opaque

declare %opaque @ret_opaque()
declare void @pass_opaque(%opaque)

define void @test() {
  %x = call %opaque @ret_opaque()
  br label %next

next:
  call void @pass_opaque(%opaque %x)
  ret void
}
```


================
Comment at: llvm/test/Transforms/Reg2Mem/catchswitch-crash.ll:1
+; RUN: opt -passes=reg2mem -disable-output < %s
+
----------------
Use `RUN: opt -passes=reg2mem -S < %s | FileCheck %s` and `update_test_checks.py` to generate check lines.


================
Comment at: llvm/test/Transforms/Reg2Mem/catchswitch-crash.ll:6
+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"
+
----------------
Drop all of these, they shouldn't be necessary.


================
Comment at: llvm/test/Transforms/Reg2Mem/catchswitch-crash.ll:10
+
+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:
----------------
Drop the dso_local and local_unnamed_addr, they shouldn't be necessary.


================
Comment at: llvm/test/Transforms/Reg2Mem/catchswitch-crash.ll:33
+
+!0 = !{!"clang version 14.0.6 (https://github.com/llvm/llvm-project.git f28c006a5895fc0e329fe15fead81e37457cb1d1)"}
----------------
Drop the attributes and metadata, they shouldn't be necessary.


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

https://reviews.llvm.org/D137700



More information about the llvm-commits mailing list