[PATCH] D46541: [CodeGen] Improve diagnostics related to target attributes

Gabor Buella via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon May 7 11:58:04 PDT 2018


GBuella created this revision.
GBuella added reviewers: craig.topper, echristo, dblaikie.
Herald added a subscriber: cfe-commits.

When requirement imposed by __target__ attributes on functions
are not satisfied, prefer printing those requirements, which
are explicitly mentioned in the attributes.

This makes such messages more useful, e.g. printing avx512f instead of avx2
in the following scenario:

  $ cat foo.c
  static inline void __attribute__((__always_inline__, __target__("avx512f")))
  x(void)
  {
  }
  
  int main(void)
  {
  	        x();
  }
  $ clang foo.c
  foo.c:7:2: error: always_inline function 'x' requires target feature 'avx2', but would be inlined into function 'main' that is compiled without support for 'avx2'
          x();
  	^
  1 error generated.

bugzilla: https://bugs.llvm.org/show_bug.cgi?id=37338


Repository:
  rC Clang

https://reviews.llvm.org/D46541

Files:
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  test/CodeGen/target-features-error-2.c
  test/CodeGen/target-features-error.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46541.145511.patch
Type: text/x-patch
Size: 7808 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180507/e35ed21f/attachment.bin>


More information about the cfe-commits mailing list