This is an archive of the discontinued LLVM Phabricator instance.

[Target] Diagnose mismatch in required CPU for always_inline functions
AbandonedPublic

Authored by craig.topper on May 3 2018, 3:32 PM.

Details

Summary

If an always inline function requests a different CPU than its caller we should probably error.

If the callee CPU has features that the caller CPU doesn't we would already error for the feature mismatch, but it prints a misleading error about the first feature that mismatches.
If the callee CPU feature list a subset of the caller features we wouldn't error at all.

We also only error right now if the callee as a target attribute, but don't check anything if only the caller has a target attribute. This is consistent with our previous checking behavior, but we might want to fix that. I've left a TODO.

I've simplified some of GetCPUAndFeaturesAttributes since I needed to return the CPU string from getFunctionFeatureMap for the other callers anyway. This also saves us a second parse of the target attribute when adding attributes.

Diff Detail

Event Timeline

craig.topper created this revision.May 3 2018, 3:32 PM

I like the idea of a front end warning, but had believed that a subset of cpu features should be allowed to be inlined into something that's a superset and it sounds like you don't agree? Your thoughts here?

-eric

From the backend codegen perspective it would be fine if the callees instruction features were a subset. So it really depends on why the user wrote the different arch on the callee in the first place. If they did it because of one of the various tuning flags in the backend that we set based on CPU name that information would be lost during the inlining. Maybe a warning would be more appropriate. My main goal was to give the user something more to go on when the instruction set features weren't a subset so we didn't just give them some random feature name that mismatched first.

Experiments with gcc showed that it throws an error for CPU name mismatch. Strangely it even gave an error if one function had a target attribute with an arch= and the command line had the same -march.

craig.topper abandoned this revision.Oct 20 2018, 12:41 PM