This is an archive of the discontinued LLVM Phabricator instance.

MIRParser: Accept overloaded intrinsic names w/o type suffixes
ClosedPublic

Authored by rtereshin on Feb 13 2018, 4:17 PM.

Details

Summary

MIRParser: Accept overloaded intrinsic names w/o type suffixes

Function::lookupIntrinsicID is somewhat forgiving as it comes to
overloaded intrinsics' names: it returns an ID as soon as the name
provided has a prefix that matches a registered intrinsic's name w/o
actually checking that the rest of the name encodes all the concrete arg
types, let alone that those types are compatible with the intrinsic's
definition.

That's probably fine and comes in handy in MIR serialization: we don't
care about IR types at MIR level and every intrinsic should be
selectable based on its ID and low-level types (LLTs) of its operands,
including the overloaded ones, so there is no point in serializing
mangled IR types as part of the intrinsic's name.

However, lookupIntrinsicID is somewhat inconsistent in its forgiveness:
if the name provided is actually an exact match, it will refuse to
return the ID if the intrinsic is overloaded. There is probably no
real reason for that and it renders MIRParser incapable to deserialize
MIR MIRPrinter serialized.

This patch fixes this.

Diff Detail

Repository
rL LLVM

Event Timeline

rtereshin created this revision.Feb 13 2018, 4:17 PM

Ping

lib/IR/Function.cpp
528 ↗(On Diff #134144)

This would return not_intrinsic if it's an exact match, but the intrinsic happens to be overloaded.

530 ↗(On Diff #134144)

If it's an exact match, this will return the ID regardless of the intrinsic being overloaded or not.

bogner accepted this revision.Feb 28 2018, 11:34 AM

Looks good, thanks

test/CodeGen/MIR/AArch64/print-parse-overloaded-intrinsics.mir
1–3 ↗(On Diff #134144)

It might be easier to tell what went wrong on failures if we output to a temporary file (ie %t) instead of doing this all in a single pipeline.

9–24 ↗(On Diff #134144)

I guess it makes sense since this is a test for the mir parser, but it's a bit odd to have a mir file that only consists of llvm ir.

This revision is now accepted and ready to land.Feb 28 2018, 11:34 AM
rtereshin marked 4 inline comments as done.Feb 28 2018, 3:47 PM
rtereshin added inline comments.
test/CodeGen/MIR/AArch64/print-parse-overloaded-intrinsics.mir
1–3 ↗(On Diff #134144)

Sure! I'm changing the RUN lines to:

# RUN: llc -mtriple aarch64-- -run-pass irtranslator -simplify-mir %s -o %t \
# RUN:   -verify-machineinstrs; llc -mtriple aarch64-- -run-pass legalizer \
# RUN:   -simplify-mir %t -x mir -o - -verify-machineinstrs | FileCheck %s
9–24 ↗(On Diff #134144)

Apparently, -run-pass command line option isn't defined for IR files, llc fails like follows:

llc: run-pass is for .mir file only.

as discussed offline.

We should probably change that at some point, as well as make it possible to run IR-to-IR passes that are ran by llc anyway separately, in opt manner. Not to encourage people adding more IR-to-IR passes into llc's pipeline, but to make it easier to test and troubleshoot.

This revision was automatically updated to reflect the committed changes.
rtereshin marked 2 inline comments as done.