File tree Expand file tree Collapse file tree 4 files changed +27
-1
lines changed Expand file tree Collapse file tree 4 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -2573,6 +2573,10 @@ class FunctionDecl : public DeclaratorDecl,
25732573 // / the target functionality.
25742574 bool isTargetMultiVersion () const ;
25752575
2576+ // / True if this function is the default version of a multiversioned dispatch
2577+ // / function as a part of the target functionality.
2578+ bool isTargetMultiVersionDefault () const ;
2579+
25762580 // / True if this function is a multiversioned dispatch function as a part of
25772581 // / the target-clones functionality.
25782582 bool isTargetClonesMultiVersion () const ;
Original file line number Diff line number Diff line change @@ -3484,6 +3484,11 @@ bool FunctionDecl::isTargetMultiVersion() const {
34843484 (hasAttr<TargetAttr>() || hasAttr<TargetVersionAttr>());
34853485}
34863486
3487+ bool FunctionDecl::isTargetMultiVersionDefault () const {
3488+ return isMultiVersion () && hasAttr<TargetVersionAttr>() &&
3489+ getAttr<TargetVersionAttr>()->isDefaultVersion ();
3490+ }
3491+
34873492bool FunctionDecl::isTargetClonesMultiVersion () const {
34883493 return isMultiVersion () && hasAttr<TargetClonesAttr>();
34893494}
Original file line number Diff line number Diff line change @@ -1372,7 +1372,8 @@ void Sema::ActOnEndOfTranslationUnit() {
13721372 Diag (DiagD->getLocation (), diag::warn_unneeded_internal_decl)
13731373 << /* function=*/ 0 << DiagD << DiagRange;
13741374 }
1375- } else {
1375+ } else if (!FD->isTargetMultiVersion () ||
1376+ FD->isTargetMultiVersionDefault ()) {
13761377 if (FD->getDescribedFunctionTemplate ())
13771378 Diag (DiagD->getLocation (), diag::warn_unused_template)
13781379 << /* function=*/ 0 << DiagD << DiagRange;
Original file line number Diff line number Diff line change @@ -236,4 +236,20 @@ constexpr int constexpr4() { return 2; }
236236#endif
237237}
238238
239+ __attribute__ ((target_version(" fp16" )))
240+ static int not_used_fmv(void ) { return 1 ; }
241+ __attribute__ ((target_version(" fp16fml" )))
242+ static int not_used_fmv(void ) { return 2 ; }
243+ __attribute__ ((target_version(" default" )))
244+ static int not_used_fmv(void ) { return 0 ; } // expected-warning {{unused function 'not_used_fmv'}}
245+
246+
247+ __attribute__ ((target_version(" fp16" )))
248+ static int definitely_used_fmv(void ) { return 1 ; }
249+ __attribute__ ((target_version(" fp16fml" )))
250+ static int definitely_used_fmv(void ) { return 2 ; }
251+ __attribute__ ((target_version(" default" )))
252+ static int definitely_used_fmv(void ) { return 0 ; }
253+ int definite_user (void ) { return definitely_used_fmv (); }
254+
239255#endif
You can’t perform that action at this time.
0 commit comments