Mingming Liu via llvm-dev
2021-Nov-18 18:33 UTC
[llvm-dev] Strip IR metadata information in a unit test
Thanks for the pointer! I'm a little confused how the custom script (specified by --test arg <https://github.com/llvm-mirror/llvm/blob/master/tools/llvm-reduce/llvm-reduce.cpp#L38>) tells llvm-reduce if something is interesting in the IR. Is it a common practice to wrap "llvm-lit <IR>" into a shell script to simplify IR for a unit test? On Thu, Nov 18, 2021 at 9:23 AM Philip Reames <listmail at philipreames.com> wrote:> See llvm-reduce. > > Philip > On 11/18/21 9:14 AM, Mingming Liu via llvm-dev wrote: > > Hi, > > When modifying IR for the purpose of a unit test (e.g., in > https://github.com/llvm/llvm-project/tree/main/llvm/test/Transforms/SROA), > the IR generated by OPT may have metadata that's not used by the tested > pass. > > Are there some general suggestions on how to strip metadata? Is this > mostly empirical by analyzing how the metadata takes effect in the e2e > compiling process (i.e., outside of one pass)? Any form of pointers / > related threads in the past would be enlightening! > > From this perspective stripping unused metadata manually could be > error prone (e.g., for a more complex IR, or a test IR consisting of 10+ > functions). > > -- > Thanks, > Mingming > > _______________________________________________ > LLVM Developers mailing listllvm-dev at lists.llvm.orghttps://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-- Thanks, Mingming -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20211118/1806d840/attachment.html>
Michael Kruse via llvm-dev
2021-Nov-18 18:42 UTC
[llvm-dev] Strip IR metadata information in a unit test
Am Do., 18. Nov. 2021 um 12:34 Uhr schrieb Mingming Liu via llvm-dev <llvm-dev at lists.llvm.org>:> I'm a little confused how the custom script (specified by --test arg) tells llvm-reduce if something is interesting in the IR. > > Is it a common practice to wrap "llvm-lit <IR>" into a shell script to simplify IR for a unit test?Yes, it is expected that you write your own "interesting-ness" script. However I don't think you can use llvm-lit (which requires a `RUN:` command comment in the file that llvm-reduce does not emit). Instead, take the command that llvm-lit would execute (Execute with -v flag) and instead of the test file (%s in the `RUN: ` command), pass $1 to the opt/llc executable within your script. Check whether it has failed with `%?`. Michael