This is an archive of the discontinued LLVM Phabricator instance.

[WIP] Introduce the "implements" string attribute
Needs ReviewPublic

Authored by jdoerfert on Mar 12 2021, 8:46 AM.

Details

Reviewers
tra
wsmoses
bollu
Summary

This is a protoype, RFC will follow.

See https://lists.llvm.org/pipermail/llvm-dev/2021-March/149117.html
for a rational.

Diff Detail

Event Timeline

jdoerfert created this revision.Mar 12 2021, 8:46 AM
jdoerfert requested review of this revision.Mar 12 2021, 8:46 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 12 2021, 8:46 AM
jdoerfert updated this revision to Diff 330259.Mar 12 2021, 8:50 AM

Add the new files as well ;)

Is it worth verifying there isn't more than one implementation for a given function?

Is it worth verifying there isn't more than one implementation for a given function?

I guess we can emit a debug message but there is little we can do in the IR wrt. error reporting. The clang part could check though.

tra added a comment.Mar 12 2021, 11:22 AM

Nice.

And, also, a bit scary as it can potentially be used to replace an arbitrary function, not just a math intrinsic normally mapped to libcall.
I can see how it may be useful to allow function substitution for uses other than libm on GPUs, but it's also going to be way too easy to make a mess. E.g. if/when someone substitutes @llvm.lifetime.start or some other special purpose intrinsic llvm relies on.

Perhaps it would make sense to only allow whitelisted functions?

llvm/test/Transforms/ImplementsAttrResolver/intrinsic_implementation.ll
6

What happens if the function has different signature than that of the intrinsic?

6

We may want to be able provide different implementations based on fast-math flags.
libdevice has few functions that have distinct fast-math implementations.

MaskRay added inline comments.
llvm/lib/Passes/PassBuilder.cpp
283

Omit cl::init(false)

llvm/test/Transforms/ImplementsAttrResolver/intrinsic_implementation.ll
4

This test needs to be ported to ptr now:)

Herald added a project: Restricted Project. · View Herald TranscriptAug 16 2023, 2:49 PM
Herald added subscribers: hoy, ormris. · View Herald Transcript