Commit Graph

458 Commits

Author SHA1 Message Date
Wenlei He 7c8a6936bf [Remarks] Add callsite locations to inline remarks
Summary:
Add call site location info into inline remarks so we can differentiate inline sites.
This can be useful for inliner tuning. We can also reconstruct full hierarchical inline
tree from parsing such remarks. The messege of inline remark is also tweaked so we can
differentiate SampleProfileLoader inline from CGSCC inline.

Reviewers: wmi, davidxl, hoy

Subscribers: hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D82213
2020-06-20 23:32:10 -07:00
Leonard Chan 2f6bb2a692 [clang][Attribute] Fix noderef attribute false-negatives
`noderef` was failing to trigger warnings in some cases related to c++ style
casting. This patch addresses them.

Differential Revision: https://reviews.llvm.org/D77836
2020-06-10 12:20:54 -07:00
Leonard Chan ef37444058 [Lexer] Fix invalid suffix diagnostic for fixed-point literals
Committing on behalf of nagart, who authored this patch.

Differential Revision: https://reviews.llvm.org/D80412
2020-05-27 16:16:56 -07:00
jasonliu 7f5d91d3ff [clang][AIX] Implement ABIInfo and TargetCodeGenInfo for AIX
Summary:
Created AIXABIInfo and AIXTargetCodeGenInfo for AIX ABI.

Reviewed By: Xiangling_L, ZarkoCA

Differential Revision: https://reviews.llvm.org/D79035
2020-05-19 15:00:48 +00:00
Alexandre Rames 05eedf1f5b [clang][VerifyDiagnosticConsumer] Support filename wildcards
Differential Revision: https://reviews.llvm.org/D72100
2020-05-14 15:15:49 -07:00
Bevin Hansson e4ca64f1ae [Fixed Point] Add triples to test cases.
This was causing some test failures.
2020-04-08 16:31:36 +02:00
Bevin Hansson 313461f6d8 [CodeGen] Emit IR for compound assignment with fixed-point operands.
Reviewers: rjmccall, leonardchan

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73184
2020-04-08 14:33:04 +02:00
Bevin Hansson 39baaabf6d [CodeGen] Emit IR for fixed-point unary operators.
Reviewers: rjmccall, leonardchan

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73183
2020-04-08 14:33:04 +02:00
Bevin Hansson 0b9922e67a [CodeGen] Emit IR for fixed-point multiplication and division.
Reviewers: rjmccall, leonardchan

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73182
2020-04-08 14:33:04 +02:00
Fangrui Song d0d076fed9 [Driver] Flip the CC1 default of -fdiagnostics-show-option
The driver enables -fdiagnostics-show-option by default, so flip the CC1
default to reduce the lengths of common CC1 command lines.

This change also makes ParseDiagnosticArgs() consistently enable
-fdiagnostics-show-option by default.
2020-03-31 21:59:27 -07:00
Fangrui Song 4805901930 [Driver] Don't pass -fmessage-length=0 to CC1
-fmessage-length=0 is common (unless the environment variable COLUMNS
is set and exported. This simplifies a common CC1 command line.
2020-03-31 17:12:08 -07:00
John Brawn 3f03c12a51 Add an attribute plugin example
Differential Revision: https://reviews.llvm.org/D31343
2020-03-25 14:33:44 +00:00
Sjoerd Meijer 3d9a0445cc Recommit #2 "[Driver] Default to -fno-common for all targets"
After a first attempt to fix the test-suite failures, my first recommit
caused the same failures again. I had updated CMakeList.txt files of
tests that needed -fcommon, but it turns out that there are also
Makefiles which are used by some bots, so I've updated these Makefiles
now too.

See the original commit message for more details on this change:
0a9fc9233e
2020-03-09 19:57:03 +00:00
Sjoerd Meijer f35d112efd Revert "Recommit "[Driver] Default to -fno-common for all targets""
This reverts commit 2c36c23f34.

Still problems in the test-suite, which I really thought I had fixed...
2020-03-09 10:37:28 +00:00
Sjoerd Meijer 2c36c23f34 Recommit "[Driver] Default to -fno-common for all targets"
This includes fixes for:
- test-suite: some benchmarks need to be compiled with -fcommon, see D75557.
- compiler-rt: one test needed -fcommon, and another a change, see D75520.
2020-03-09 10:07:37 +00:00
Ruyman 118b057f12 [SYCL] Driver option to select SYCL version
Summary:
User can select the version of SYCL the compiler will
use via the flag -sycl-std, similar to -cl-std.

The flag defines the LangOpts.SYCLVersion option to the
version of SYCL. The default value is undefined.
If driver is building SYCL code, flag is set to the default SYCL
version (1.2.1)

The preprocessor uses this variable to define CL_SYCL_LANGUAGE_VERSION macro,
which should be defined according to SYCL 1.2.1 standard.

Only valid value at this point for the flag is 1.2.1.

Co-Authored-By: David Wood <Q0KPU0H1YOEPHRY1R2SN5B5RL@david.davidtw.co>
Signed-off-by: Ruyman Reyes <ruyman@codeplay.com>

Subscribers: ebevhan, Anastasia, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72857
2020-03-07 18:28:54 +03:00
Sjoerd Meijer 4e363563fa Revert "[Driver] Default to -fno-common for all targets"
This reverts commit 0a9fc9233e.

Going to look at the asan failures.

I find the failures in the test suite weird, because they look
like compile time test and I don't understand how that can be
failing, but will have a brief look at that too.
2020-03-03 10:00:36 +00:00
Sjoerd Meijer 0a9fc9233e [Driver] Default to -fno-common for all targets
This makes -fno-common the default for all targets because this has performance
and code-size benefits and is more language conforming for C code.
Additionally, GCC10 also defaults to -fno-common and so we get consistent
behaviour with GCC.

With this change, C code that uses tentative definitions as definitions of a
variable in multiple translation units will trigger multiple-definition linker
errors. Generally, this occurs when the use of the extern keyword is neglected
in the declaration of a variable in a header file. In some cases, no specific
translation unit provides a definition of the variable. The previous behavior
can be restored by specifying -fcommon.

As GCC has switched already, we benefit from applications already being ported
and existing documentation how to do this. For example:
- https://gcc.gnu.org/gcc-10/porting_to.html
- https://wiki.gentoo.org/wiki/Gcc_10_porting_notes/fno_common

Differential revision: https://reviews.llvm.org/D75056
2020-03-03 09:15:07 +00:00
Alexey Bader 740ed617f7 Revert "[SYCL] Driver option to select SYCL version"
This reverts commit bd97704eaa.

It broke tests on mac: http://45.33.8.238/mac/9011/step_7.txt
2020-02-27 16:23:54 +03:00
Ruyman bd97704eaa [SYCL] Driver option to select SYCL version
Summary:
User can select the version of SYCL the compiler will
use via the flag -sycl-std, similar to -cl-std.

The flag defines the LangOpts.SYCLVersion option to the
version of SYCL. The default value is undefined.
If driver is building SYCL code, flag is set to the default SYCL
version (1.2.1)

The preprocessor uses this variable to define CL_SYCL_LANGUAGE_VERSION macro,
which should be defined according to SYCL 1.2.1 standard.

Only valid value at this point for the flag is 1.2.1.

Co-Authored-By: David Wood <Q0KPU0H1YOEPHRY1R2SN5B5RL@david.davidtw.co>
Signed-off-by: Ruyman Reyes <ruyman@codeplay.com>

Subscribers: ebevhan, Anastasia, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72857

Signed-off-by: Alexey Bader <alexey.bader@intel.com>
2020-02-27 15:08:42 +03:00
Nico Weber bcda1269c4 clang-cl: Add a `/showIncludes:user` flag.
This flag is like /showIncludes, but it only includes user headers and
omits system headers (similar to MD and MMD). The motivation is that
projects that already track system includes though other means can use
this flag to get consistent behavior on Windows and non-Windows, and it
saves tools that output /showIncludes output (e.g. ninja) some work.

implementation-wise, this makes `HeaderIncludesCallback` honor the
existing `IncludeSystemHeaders` bit, and changes the three clients of
`HeaderIncludesCallback` (`/showIncludes`, `-H`, `CC_PRINT_HEADERS=1`)
to pass `-sys-header-deps` to set that bit -- except for
`/showIncludes:user`, which doesn't pass it.

Differential Revision: https://reviews.llvm.org/D75093
2020-02-25 09:43:52 -05:00
Jan Korous 986202fad4 [clang][test][NFC] Use more widely supported sanitizer for file dependency tests
The tests aren't concerned at all by the actual sanitizer - only by blacklist being reported as a dependency.
We're unfortunately limited by platform support for any particular sanitizer but we can at least use one that is widely supported.

Post-commit review:
https://reviews.llvm.org/D72729
2020-01-14 12:55:11 -08:00
Karl-Johan Karlsson 073cdb2390 [clang][test] Minor fixes in testcase absolute-paths-symlinks.c
This is a follow up commit to address post-commit comment in D70527.
2019-12-26 09:33:21 +01:00
Karl-Johan Karlsson e8efac4b15 [clang] Fix the canonicalization of paths in -fdiagnostics-absolute-paths
In the current implementation of clang the canonicalization of paths in
diagnostic messages (when using -fdiagnostics-absolute-paths) only works
if the symbolic link is in the directory part of the filename, not if
the file itself is a symbolic link to another file.

This patch adds support to canonicalize the complete path including the
file.

Reviewers: rsmith, hans, rnk, ikudrin

Reviewed By: rnk

Differential Revision: https://reviews.llvm.org/D70527
2019-12-20 09:16:33 +01:00
Teresa Johnson c8e0bb3b2c [LTO] Support for embedding bitcode section during LTO
Summary:
This adds support for embedding bitcode in a binary during LTO. The libLTO gains supports the `-lto-embed-bitcode` flag. The option allows users of the LTO library to embed a bitcode section. For example, LLD can pass the option via `ld.lld -mllvm=-lto-embed-bitcode`.

This feature allows doing something comparable to `clang -c -fembed-bitcode`, but on the (LTO) linker level. Having bitcode alongside native code has many use-cases. To give an example, the MacOS linker can create a `-bitcode_bundle` section containing bitcode. Also, having this feature built into LLVM is an alternative to 3rd party tools such as [[ https://github.com/travitch/whole-program-llvm | wllvm ]] or [[ https://github.com/SRI-CSL/gllvm | gllvm ]]. As with these tools, this feature simplifies creating "whole-program" llvm bitcode files, but in contrast to wllvm/gllvm it does not rely on a specific llvm frontend/driver.

Patch by Josef Eisl <josef.eisl@oracle.com>

Reviewers: #llvm, #clang, rsmith, pcc, alexshap, tejohnson

Reviewed By: tejohnson

Subscribers: tejohnson, mehdi_amini, inglorion, hiraditya, aheejin, steven_wu, dexonsmith, dang, cfe-commits, llvm-commits, #llvm, #clang

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D68213
2019-12-12 12:34:19 -08:00
Alexey Bader cb30ad728f [SYCL] Add support for auxiliary triple specification to Frontend
Summary:
Add host predefined macros to compilation for SYCL device, which is
required for pre-processing host specific includes (e.g. system
headers).

Reviewers: ABataev, jdoerfert

Subscribers: ebevhan, Anastasia, cfe-commits, keryell, Naghasan, Fznamznon

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71286

Signed-off-by: Alexey Bader <alexey.bader@intel.com>
2019-12-11 12:40:43 +03:00
Leonard Chan e278c138a9 [Sema] Add MacroQualified case for FunctionTypeUnwrapper
This is a fix for PR43315. An assertion error is hit for this minimal example:

```
//clang -cc1 -triple x86_64-- -S tstVMStructRC-min.cpp
int (a b)();  // Assertion `Chunk.Kind == DeclaratorChunk::Function' failed.
```

This is because we do not cover the case in the FunctionTypeUnwrapper where it
receives a MacroQualifiedType. We have not run into this earlier because this
is a unique case where the __attribute__ contains both __cdecl__ and
__regparm__ (in that order), and we are compiling for x86_64. Changing the
architecture or the order of __cdecl__ and __regparm__ does not raise the
assertion.

Differential Revision: https://reviews.llvm.org/D67992
2019-11-12 16:22:13 -08:00
Dávid Bolvanský 5c50109bb5 Fixed more -Wreturn-type tests 2019-11-09 18:13:51 +01:00
Dávid Bolvanský 1da13237a4 [Diagnostics] Try to improve warning message for -Wreturn-type
Summary: I agree with https://easyaspi314.github.io/gcc-vs-clang.html?fbclid=IwAR1VA0qxiWVUusOQUv5z7JESS7ZpeJy-UqAI5mnJscofGLqXcqeErIUB2gU, current warning message is not very good. We should try to improve it..

Reviewers: rsmith, aaron.ballman, easyaspi314

Reviewed By: aaron.ballman

Subscribers: arphaman, Quuxplusone, mehdi_amini, hiraditya, cfe-commits, llvm-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D69762
2019-11-09 17:54:58 +01:00
Jan Korous d52cff8836 Revert "Reland "[clang] Report sanitizer blacklist as a dependency in cc1""
This reverts commit cae4a28864.
2019-11-08 14:28:30 -08:00
Jan Korous cae4a28864 Reland "[clang] Report sanitizer blacklist as a dependency in cc1"
This reverts commit 3182027282.
2019-11-08 13:55:00 -08:00
Jan Korous 6d28588cc0 Reland "[clang] Report sanitizer blacklist as a dependency in cc1"
This reverts commit 9b8413ac6e.
2019-11-08 13:54:28 -08:00
Abel Kocsis 9b8413ac6e Revert "Revert "Revert "[clang] Report sanitizer blacklist as a dependency in cc1"""
This reverts commit 3182027282.
2019-11-08 14:08:15 +01:00
Abel Kocsis 3182027282 Revert "Revert "[clang] Report sanitizer blacklist as a dependency in cc1""
This reverts commit 6b45e1bc11.
2019-11-08 14:00:44 +01:00
Jeremy Morse 6b45e1bc11 Revert "[clang] Report sanitizer blacklist as a dependency in cc1"
This reverts commit 03b84e4f6d.

This breaks dfsan tests with a linking failure, in for example this build:

  http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux/builds/24312

Reverting this patch locally makes those tests succeed.
2019-11-08 12:07:42 +00:00
Jan Korous 03b84e4f6d [clang] Report sanitizer blacklist as a dependency in cc1
Previously these were reported from the driver which blocked clang-scan-deps from getting the full set of dependencies from cc1 commands.

Also the default sanitizer blacklist that is added in driver was never reported as a dependency. I introduced -fsanitize-system-blacklist cc1 option to keep track of which blacklists were user-specified and which were added by driver and clang -MD now also reports system blacklists as dependencies.

Differential Revision: https://reviews.llvm.org/D69290
2019-11-07 14:06:43 -08:00
Evandro Menezes 215da6606c [clang][llvm] Obsolete Exynos M1 and M2 2019-10-30 15:02:59 -05:00
Yaxun (Sam) Liu 68f5ca4e19 [HIP] Add option -fgpu-allow-device-init
Add this option to allow device side class type global variables
with non-trivial ctor/dtor. device side init/fini functions will
be emitted, which will be executed by HIP runtime when
the fat binary is loaded/unloaded.

This feature is to facilitate implementation of device side
sanitizer which requires global vars with non-trival ctors.

By default this option is disabled.

Differential Revision: https://reviews.llvm.org/D69268
2019-10-22 16:06:20 -04:00
Reid Kleckner 5e866e411c Add -fgnuc-version= to control __GNUC__ and other GCC macros
I noticed that compiling on Windows with -fno-ms-compatibility had the
side effect of defining __GNUC__, along with __GNUG__, __GXX_RTTI__, and
a number of other macros for GCC compatibility. This is undesirable and
causes Chromium to do things like mix __attribute__ and __declspec,
which doesn't work. We should have a positive language option to enable
GCC compatibility features so that we can experiment with
-fno-ms-compatibility on Windows. This change adds -fgnuc-version= to be
that option.

My issue aside, users have, for a long time, reported that __GNUC__
doesn't match their expectations in one way or another. We have
encouraged users to migrate code away from this macro, but new code
continues to be written assuming a GCC-only environment. There's really
nothing we can do to stop that. By adding this flag, we can allow them
to choose their own adventure with __GNUC__.

This overlaps a bit with the "GNUMode" language option from -std=gnu*.
The gnu language mode tends to enable non-conforming behaviors that we'd
rather not enable by default, but the we want to set things like
__GXX_RTTI__ by default, so I've kept these separate.

Helps address PR42817

Reviewed By: hans, nickdesaulniers, MaskRay

Differential Revision: https://reviews.llvm.org/D68055

llvm-svn: 374449
2019-10-10 21:04:25 +00:00
Teresa Johnson 2024ea148c Fix buildbot failure from r373217 (don't match metadata id exactly)
Fix this failure by ignoring the id of the metadata being checked:
    http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/3046/consoleFull#-21332887158254eaf0-7326-4999-85b0-388101f2d404

llvm-svn: 373237
2019-09-30 17:26:48 +00:00
Teresa Johnson 57dbfe194c [Clang] Use -main-file-name for source filename if not set
-main-file-name is currently used to set the source name used in debug
information.

If the source filename is "-" and -main-file-name is set, then use the
filename also for source_filename and ModuleID of the output.

The argument is generally used outside the internal clang calls when
running clang in a wrapper like icecc which gives the source via stdin
but still wants to get a object file with the original source filename
both in debug info and IR code.

Patch by: the_jk (Joel Klinghed)

Differential Revision: https://reviews.llvm.org/D67592

llvm-svn: 373217
2019-09-30 15:05:35 +00:00
Fangrui Song e6d423fe03 [test] Use %clang_cc1 instead of %clang -cc1
llvm-svn: 373043
2019-09-27 05:37:06 +00:00
Lubos Lunak 3425a89676 fix build, adjust test also for Windows path separator
Introduced in 1e9c1d2b7b.

llvm-svn: 372263
2019-09-18 21:41:45 +00:00
Lubos Lunak 1e9c1d2b7b actually also compile output in tests for -frewrite-includes
Checking that the created output matches something is nice, but
this should also check whether the output makes sense.

Differential Revision: https://reviews.llvm.org/D63979

llvm-svn: 372250
2019-09-18 19:12:14 +00:00
Lubos Lunak 533434fc72 make -frewrite-includes also rewrite conditions in #if/#elif
Those conditions may use __has_include, which needs to be rewritten.
The existing code has already tried to rewrite just __has_include,
but it didn't work with macro expansion, so e.g. Qt's
"#define QT_HAS_INCLUDE(x) __has_include(x)" didn't get handled
properly. Since the preprocessor run knows what each condition evaluates
to, just rewrite the entire condition. This of course requires that
the -frewrite-include pass has the same setup as the following
compilation, but that has always been the requirement.

Differential Revision: https://reviews.llvm.org/D63508

llvm-svn: 372248
2019-09-18 19:09:41 +00:00
Lubos Lunak a507a5ec8f do not emit -Wunused-macros warnings in -frewrite-includes mode (PR15614)
-frewrite-includes calls PP.SetMacroExpansionOnlyInDirectives() to avoid
macro expansions that are useless in that mode, but this can lead
to -Wunused-macros false positives. As -frewrite-includes does not emit
normal warnings, block -Wunused-macros too.

Differential Revision: https://reviews.llvm.org/D65371

llvm-svn: 372026
2019-09-16 19:18:37 +00:00
Manoj Gupta 41d9d5092a Reland r371785: Add -Wpoison-system-directories warning
When using clang as a cross-compiler, we should not use system
headers to do the compilation.
This CL adds support of a new warning flag -Wpoison-system-directories which
emits warnings if --sysroot is set and headers from common host system location
are used.
By default the warning is disabled.

The intention of the warning is to catch bad includes which are usually
generated by third party build system not targeting cross-compilation.
Such cases happen in Chrome OS when someone imports a new package or upgrade
one to a newer version from upstream.

This is reland of r371785 with a fix to test file.

Patch by: denik (Denis Nikitin)

llvm-svn: 371878
2019-09-13 18:00:51 +00:00
Manoj Gupta 38f6b3fd8d Revert r371785.
r371785 is causing fails on clang-hexagon-elf buildbots.

llvm-svn: 371799
2019-09-13 00:28:37 +00:00
Manoj Gupta 4fe2732161 Add -Wpoison-system-directories warning
When using clang as a cross-compiler, we should not use system
headers to do the compilation.
This CL adds support of a new warning flag -Wpoison-system-directories which
emits warnings if --sysroot is set and headers from common host system location
are used.
By default the warning is disabled.

The intention of the warning is to catch bad includes which are usually
generated by third party build system not targeting cross-compilation.
Such cases happen in Chrome OS when someone imports a new package or upgrade
one to a newer version from upstream.

Patch by: denik (Denis Nikitin)

llvm-svn: 371785
2019-09-12 22:36:13 +00:00
Reid Kleckner 38e033bf33 Re-land Remove REQUIRES:shell from tests that pass for me on Windows
This reverts r371497 (git commit 3d7e9ab7b9)

Reorder `not` with `env` in these two tests so they pass:
  Driver/rewrite-map-in-diagnostics.c
  Index/crash-recovery-modules.m.

This will not be necessary after D66531 lands.

llvm-svn: 371552
2019-09-10 20:15:45 +00:00