This is an archive of the discontinued LLVM Phabricator instance.

[reg2mem]Skip non-sized Instructions
ClosedPublic

Authored by Naville on Nov 9 2022, 1:44 AM.

Diff Detail

Event Timeline

Naville created this revision.Nov 9 2022, 1:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 9 2022, 1:44 AM
Herald added a subscriber: hiraditya. · View Herald Transcript
Naville requested review of this revision.Nov 9 2022, 1:44 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 9 2022, 1:44 AM
nikic added a subscriber: nikic.Nov 9 2022, 2:14 AM

Can you please add a test case?

What about other unsized types? This is probably not a token specific problem.

Can you please add a test case?

What about other unsized types? This is probably not a token specific problem.

hey: I've attached a test case in the original github issue, not sure what else should be done here?

nikic added a comment.Nov 9 2022, 5:49 AM

@Naville It looks like current test coverage is practically non-existent, but you can add your test case to llvm/test/Transforms/Reg2Mem.

Naville updated this revision to Diff 474249.Nov 9 2022, 6:14 AM

Add test case

@nikic Added, anything more needed to do? I say we keep it restricted to token type for now and fix future issues if they appear

Naville updated this revision to Diff 474298.Nov 9 2022, 9:36 AM

Add missing RUN line

Naville updated this revision to Diff 474404.Nov 9 2022, 6:02 PM

Reformat to silent git-clang-format

nikic added a reviewer: nikic.Nov 11 2022, 6:15 AM
nikic added inline comments.
llvm/lib/Transforms/Scalar/Reg2Mem.cpp
43

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
}
llvm/test/Transforms/Reg2Mem/catchswitch-crash.ll
2

Use RUN: opt -passes=reg2mem -S < %s | FileCheck %s and update_test_checks.py to generate check lines.

7

Drop all of these, they shouldn't be necessary.

11

Drop the dso_local and local_unnamed_addr, they shouldn't be necessary.

34

Drop the attributes and metadata, they shouldn't be necessary.

Naville updated this revision to Diff 474979.Nov 12 2022, 8:11 PM

Update test case

@nikic Thanks for the suggestion, fixed and please check

Naville retitled this revision from [reg2mem]Skip token-producing Instructions to [reg2mem]Skip non-sized Instructions.Nov 12 2022, 8:11 PM
nikic added inline comments.Nov 13 2022, 1:11 AM
llvm/test/Transforms/Reg2Mem/catchswitch-crash.ll
2

It looks like something went wrong here and no check lines were generated, which makes the test fail now. I wonder whether this might be related to the weird function names? Maybe replacing them with something like @test would make it work?

Naville updated this revision to Diff 475040.Nov 13 2022, 6:42 PM

Fix broken test case due weird Windows mangling

@nikic Thanks, yeah the Windows name mangling was the issue, guess that's a bug for another day. Updated the test case which now has proper "CHECK*" tags

nikic accepted this revision.Nov 14 2022, 2:00 AM

LGTM

If you don't have commit access, can you tell me which Name <email> to use for the commit?

This revision is now accepted and ready to land.Nov 14 2022, 2:00 AM
Naville marked 6 inline comments as done.EditedNov 14 2022, 2:26 AM
This comment has been deleted.
This revision was landed with ongoing or failed builds.Nov 14 2022, 3:47 AM
This revision was automatically updated to reflect the committed changes.
Naville updated this revision to Diff 477729.Nov 24 2022, 3:46 AM

Add TestCast

Naville updated this revision to Diff 477754.Nov 24 2022, 5:19 AM