Page MenuHomePhabricator

[Clang] Emit error when caller cannot meet target feature requirement from always-inlining callee
ClosedPublic

Authored by qiucf on Feb 7 2023, 1:51 AM.

Details

Summary

Currently clang emits error when both always_inline and target attributes are on callee, but caller doesn't have some feature:

// RUN: %clang_cc1 -triple powerpc64le -target-feature -htm

__attribute__((always_inline))
__attribute__((target("htm")))
void foo() {}

void bar() { foo(); }

// error: always_inline function 'foo' requires target feature 'htm', but would be inlined into function 'bar' that is compiled without support for 'htm'

But when the always_inline attribute is on caller, clang has no diagnose. If any builtin or inline asm really need the feature, backend will crash.

// RUN: %clang_cc1 -triple powerpc64le -target-feature +htm

__attribute__((always_inline))
void foo() {
  // No error, but uncommenting line below triggers ICE
  // __builtin_ttest();
}

__attribute__((target("no-htm")))
void bar() { foo(); }

This patch will fix the second case.

Diff Detail

Event Timeline

qiucf created this revision.Feb 7 2023, 1:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2023, 1:51 AM
qiucf requested review of this revision.Feb 7 2023, 1:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 7 2023, 1:51 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Gentle ping

erichkeane accepted this revision.Tue, Mar 14, 7:25 AM

Thanks for your patience, I was buried trying to get the 16.0 release done. This LGTM!

This revision is now accepted and ready to land.Tue, Mar 14, 7:25 AM
This revision was automatically updated to reflect the committed changes.