Commit Graph

260 Commits

Author SHA1 Message Date
Yaxun Liu b5044fe421 [OpenCL] Allow -std={cl|CL}{|1.1|1.2|2.0} in driver
Fix a regression which forbids using -std=cl|CL1.1|CL1.2|CL2.0 in driver.

Allow -std and -cl-std={cl|CL}{|1.1|1.2|2.0}.

Differential Revision: http://reviews.llvm.org/D20630

llvm-svn: 273015
2016-06-17 17:19:28 +00:00
Yaxun Liu 18e3fd3ad6 [OpenCL] Enable -fblocks by default for OpenCL 2.0 and above.
Reviewed as part of http://reviews.llvm.org/D20444

llvm-svn: 272720
2016-06-14 21:43:01 +00:00
Hal Finkel c07e19b2c1 Add a loop's debug location to its llvm.loop metadata
Getting accurate locations for loops is important, because those locations are
used by the frontend to generate optimization remarks. Currently, optimization
remarks for loops often appear on the wrong line, often the first line of the
loop body instead of the loop itself. This is confusing because that line might
itself be another loop, or might be somewhere else completely if the body was
an inlined function call. This happens because of the way we find the loop's
starting location. First, we look for a preheader, and if we find one, and its
terminator has a debug location, then we use that. Otherwise, we look for a
location on an instruction in the loop header.

The fallback heuristic is not bad, but will almost always find the beginning of
the body, and not the loop statement itself. The preheader location search
often fails because there's often not a preheader, and even when there is a
preheader, depending on how it was formed, it sometimes carries the location of
some preceeding code.

I don't see any good theoretical way to fix this problem. On the other hand,
this seems like a straightforward solution: Put the debug location in the
loop's llvm.loop metadata. When emitting debug information, this commit causes
us to add the debug location as an operand to each loop's llvm.loop metadata.
Thus, we now generate this metadata for all loops (not just loops with
optimization hints) when we're otherwise generating debug information.

The remark test case changes depend on the companion LLVM commit r270771.

llvm-svn: 270772
2016-05-25 21:53:24 +00:00
Steven Wu 2c059a55e2 Change embed-bitcode linkage type
Embedded bitcode should have private linkage instead of appending or external.
Otherwise, it will cause link failure due to duplicated symbols.
Also add llvm.embedded.module and llvm.cmdline to llvm.compiler.used so they
don't get optimized out.

rdar://problem/21555860

llvm-svn: 269679
2016-05-16 18:54:58 +00:00
Steven Wu 27fb5227ec Embed bitcode in object file (clang cc1 part)
Summary:
Teach clang to embed bitcode inside bitcode. When -fembed-bitcode cc1
option is used, clang will embed both the input bitcode and cc1
commandline into the bitcode in special sections before compiling to
the object file.  Using -fembed-bitcode-marker will only introduce a
marker in both sections.

Depends on D17390

Reviewers: rsmith

Subscribers: yaron.keren, vsk, cfe-commits

Differential Revision: http://reviews.llvm.org/D17392

llvm-svn: 269202
2016-05-11 16:26:03 +00:00
Peter Collingbourne 3afb266886 Re-apply r267784, r267824 and r267830.
I have updated the compiler-rt tests.

llvm-svn: 267903
2016-04-28 17:09:37 +00:00
Benjamin Kramer 5556a5cf3b Revert r267784, r267824 and r267830.
It makes compiler-rt tests fail if the gold plugin is enabled.

Revert "Rework interface for bitset-using features to use a notion of LTO visibility."
Revert "Driver: only produce CFI -fvisibility= error when compiling."
Revert "clang/test/CodeGenCXX/cfi-blacklist.cpp: Exclude ms targets. They would be non-cfi."

llvm-svn: 267871
2016-04-28 12:14:47 +00:00
Peter Collingbourne a8b2f7c0d7 Rework interface for bitset-using features to use a notion of LTO visibility.
Bitsets, and the compiler features they rely on (vtable opt, CFI),
only have visibility within the LTO'd part of the linkage unit. Therefore,
only enable these features for classes with hidden LTO visibility. This
notion is based on object file visibility or (on Windows)
dllimport/dllexport attributes.

We provide the [[clang::lto_visibility_public]] attribute to override the
compiler's LTO visibility inference in cases where the class is defined
in the non-LTO'd part of the linkage unit, or where the ABI supports
calling classes derived from abstract base classes with hidden visibility
in other linkage units (e.g. COM on Windows).

If the cross-DSO CFI mode is enabled, bitset checks are emitted even for
classes with public LTO visibility, as that mode uses a separate mechanism
to cause bitsets to be exported.

This mechanism replaces the whole-program-vtables blacklist, so remove the
-fwhole-program-vtables-blacklist flag.

Because __declspec(uuid()) now implies [[clang::lto_visibility_public]], the
support for the special attr:uuid blacklist entry is removed.

Differential Revision: http://reviews.llvm.org/D18635

llvm-svn: 267784
2016-04-27 20:39:53 +00:00
Yaxun Liu 382d355359 [OpenCL] Add predefined macros.
OpenCL spec requires __OPENCL_C_VERSION__ to be defined based on -cl-std option. This patch implements that.

The patch also defines __FAST_RELAXED_MATH__ based on -cl-fast-relaxed-math option.

Also fixed a test using -std=c99 for OpenCL program. Limit allowed language standard of OpenCL to be OpenCL standards.

Differential Revision: http://reviews.llvm.org/D19071

llvm-svn: 267590
2016-04-26 19:25:46 +00:00
Yaxun Liu b5e80c3117 Pass -backend-option to LLVM when there is no target machine.
Clang should pass -backend-option to LLVM even though there is no target machine, since LLVM passes are used when emitting LLVM IR.

Differential Revision: http://reviews.llvm.org/D17552

llvm-svn: 266117
2016-04-12 20:22:32 +00:00
Saleem Abdulrasool c066d9cf55 Basic: fix profiling with GNU EABI
The GNU profiling support indicates that the interface is `_mcount` rather than
`mcount`.  Conditionalise the behaviour according to the `-meabi gnu` flag.

Resolves PR27311

llvm-svn: 266039
2016-04-12 03:05:03 +00:00
Saleem Abdulrasool 2a0932fb45 Correct pg instrumentation for AArch64
It seems that there was a miscommunication between Renato and I, and the
original behaviour of AArch64 was to be preserved and not to mirror the new
behaviour.  Restore the original behaviour for AArch64.  Addresses post-commit
review comments from Renato Golin.

llvm-svn: 265899
2016-04-10 14:29:55 +00:00
Saleem Abdulrasool cb12255442 test: add additional tests for SVN r265888
Add test cases for AArch64 as well as that was changed as part of that change.

llvm-svn: 265889
2016-04-10 03:31:09 +00:00
Saleem Abdulrasool 9b5ba547f1 Add support for __gnu_mcount_nc as the pg interface
This adds support to optionally support using `__gnu_mcount_nc` as the mcount
interface rather than `mcount` for Linux and EABI.  The other targets do not
provide an implementation for `__gnu_mcount_nc`.  This can be activated via the
`-meabi gnu` flag.

Resolves PR23969.

llvm-svn: 265888
2016-04-10 03:19:47 +00:00
Adrian Prantl 826824ea3d Use NoDebug compile units to mark debug metadata used only for sample-based
profiling and optimization remarks and indicate that no debug info shall
be emitted for these compile units.

http://reviews.llvm.org/D18808
<rdar://problem/25427165>

llvm-svn: 265862
2016-04-08 22:43:06 +00:00
John Brawn 8e62db3247 Add a PragmaHandler Registry for plugins to add PragmaHandlers to
This allows plugins which add AST passes to also define pragmas to do things
like only enable certain behaviour of the AST pass in files where a certain
pragma is used.

Differential Revision: http://reviews.llvm.org/D18319

llvm-svn: 265295
2016-04-04 14:22:58 +00:00
Nico Weber 149d9522fb clang-cl: Include /FI headers in /showIncludes output.
-H in gcc mode doesn't print -include headers, but they are included in
depfiles written by MMD and friends. Since /showIncludes is what's used instead
of depfiles, printing /FI there seems important (and matches cl.exe).

Instead of giving HeaderIncludeGen more options, just switch on ShowAllHeaders
in clang-cl mode and let clang::InitializePreprocessor() not put -include flags
in the <command line> block. This changes the behavior of -E slightly, and it
removes the <command line> flag from the output triggered by setting the
obscure CC_PRINT_HEADERS=1 env var to true while running clang. Both of these
seem ok to change.

http://reviews.llvm.org/D18401

llvm-svn: 264174
2016-03-23 18:00:22 +00:00
John Brawn 6c78974b29 Make it possible for AST plugins to enable themselves by default
Currently when an AST plugin is loaded it must then be enabled by passing
-plugin pluginname or -add-plugin pluginname to the -cc1 command line. This
patch adds a method to PluginASTAction which allows it to declare that the
action happens before, instead of, or after the main AST action, plus the
relevant changes to make the plugin action happen at that time automatically.

Differential Revision: http://reviews.llvm.org/D17959

llvm-svn: 263546
2016-03-15 12:51:40 +00:00
NAKAMURA Takumi ba7d0fe280 Revert r260266 (and r260276), "clang-cl: Enable plugins on Windows"
It doesn't work, at least, i686-win32.

llvm-svn: 260537
2016-02-11 16:43:08 +00:00
Ehsan Akhgari b55b9ff884 Fix the test added in r260266
llvm-svn: 260276
2016-02-09 20:49:24 +00:00
Ehsan Akhgari 48e8d8bcdd clang-cl: Enable plugins on Windows
llvm-svn: 260266
2016-02-09 19:43:13 +00:00
Oliver Stannard 9181785a0c Add backend dignostic printer for unsupported features
Re-commit of r258950 after fixing layering violation.

The related LLVM patch adds a backend diagnostic type for reporting
unsupported features, this adds a printer for them to clang.

In the case where debug location information is not available, I've
changed the printer to report the location as the first line of the
function, rather than the closing brace, as the latter does not give the
user any information. This also affects optimisation remarks.

llvm-svn: 259499
2016-02-02 13:52:52 +00:00
Oliver Stannard 92d4c328d1 Revert r259036, it introduces a cyclic library dependency
llvm-svn: 259043
2016-01-28 13:09:49 +00:00
Oliver Stannard 7a964feccb Add backend dignostic printer for unsupported features
Re-commit of r258950 after fixing layering violation.

Add backend dignostic printer for unsupported features

The related LLVM patch adds a backend diagnostic type for reporting
unsupported features, this adds a printer for them to clang.

In the case where debug location information is not available, I've
changed the printer to report the location as the first line of the
function, rather than the closing brace, as the latter does not give the
user any information. This also affects optimisation remarks.

Differential Revision: http://reviews.llvm.org/D16591

llvm-svn: 259036
2016-01-28 10:07:34 +00:00
NAKAMURA Takumi 628a7a0aef Revert r258951 (and r258950), "Refactor backend diagnostics for unsupported features"
It broke layering violation in LLVMIR.

clang r258950 "Add backend dignostic printer for unsupported features"
llvm  r258951 "Refactor backend diagnostics for unsupported features"

llvm-svn: 259016
2016-01-28 04:41:32 +00:00
Oliver Stannard 5e03a4b837 Add backend dignostic printer for unsupported features
The related LLVM patch adds a backend diagnostic type for reporting
unsupported features, this adds a printer for them to clang.

In the case where debug location information is not available, I've
changed the printer to report the location as the first line of the
function, rather than the closing brace, as the latter does not give the
user any information. This also affects optimisation remarks.

Differential Revision: http://reviews.llvm.org/D16591

llvm-svn: 258950
2016-01-27 17:30:28 +00:00
Tim Northover 67465f80ec Preprocessor: define correct tvOS and watchOS version macros
llvm-svn: 251707
2015-10-30 16:30:30 +00:00
Reid Kleckner afb9aaefe3 Add back null check removed accidentally in r250554
Fixes PR25262

llvm-svn: 250844
2015-10-20 18:45:57 +00:00
Douglas Katzman 3459ce2e5e Stop messing with the 'g' group of options in CompilerInvocation.
With this change, most 'g' options are rejected by CompilerInvocation.
They remain only as Driver options. The new way to request debug info
from cc1 is with "-debug-info-kind={line-tables-only|limited|standalone}"
and "-dwarf-version={2|3|4}". In the absence of a command-line option
to specify Dwarf version, the Toolchain decides it, rather than placing
Toolchain-specific logic in CompilerInvocation.

Also fix a bug in the Windows compatibility argument parsing
in which the "rightmost argument wins" principle failed.

Differential Revision: http://reviews.llvm.org/D13221

llvm-svn: 249655
2015-10-08 04:24:12 +00:00
Dehao Chen 1b68ebf3a0 Fix the sample profile format that breaks in test http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast/builds/505
http://reviews.llvm.org/D13145

llvm-svn: 248869
2015-09-30 01:03:10 +00:00
Evgeniy Stepanov 6b2a61d3a5 Revert "Always_inline codegen rewrite" and 2 follow-ups.
Revert "Update cxx-irgen.cpp test to allow signext in alwaysinline functions."
Revert "[CodeGen] Remove wrapper-free always_inline functions from COMDATs"
Revert "Always_inline codegen rewrite."

Reason for revert: PR24793.

llvm-svn: 247620
2015-09-14 21:35:16 +00:00
Evgeniy Stepanov 93db40a147 Always_inline codegen rewrite.
Current implementation may end up emitting an undefined reference for
an "inline __attribute__((always_inline))" function by generating an
"available_externally alwaysinline" IR function for it and then failing to
inline all the calls. This happens when a call to such function is in dead
code. As the inliner is an SCC pass, it does not process dead code.

Libc++ relies on the compiler never emitting such undefined reference.

With this patch, we emit a pair of
1. internal alwaysinline definition (called F.alwaysinline)
2a. A stub F() { musttail call F.alwaysinline }
  -- or, depending on the linkage --
2b. A declaration of F.

The frontend ensures that F.inlinefunction is only used for direct
calls, and the stub is used for everything else (taking the address of
the function, really). Declaration (2b) is emitted in the case when
"inline" is meant for inlining only (like __gnu_inline__ and some
other cases).

This approach, among other nice properties, ensures that alwaysinline
functions are always internal, making it impossible for a direct call
to such function to produce an undefined symbol reference.

This patch is based on ideas by Chandler Carruth and Richard Smith.

llvm-svn: 247494
2015-09-12 01:07:37 +00:00
Evgeniy Stepanov 67037ee21e Revert "Specify target triple in alwaysinline tests."
Revert "Always_inline codegen rewrite."

Breaks gdb & lldb tests.
Breaks on Fedora 22 x86_64.

llvm-svn: 247491
2015-09-11 23:48:37 +00:00
Evgeniy Stepanov 072e83500e Always_inline codegen rewrite.
Current implementation may end up emitting an undefined reference for
an "inline __attribute__((always_inline))" function by generating an
"available_externally alwaysinline" IR function for it and then failing to
inline all the calls. This happens when a call to such function is in dead
code. As the inliner is an SCC pass, it does not process dead code.

Libc++ relies on the compiler never emitting such undefined reference.

With this patch, we emit a pair of
1. internal alwaysinline definition (called F.alwaysinline)
2a. A stub F() { musttail call F.alwaysinline }
  -- or, depending on the linkage --
2b. A declaration of F.

The frontend ensures that F.inlinefunction is only used for direct
calls, and the stub is used for everything else (taking the address of
the function, really). Declaration (2b) is emitted in the case when
"inline" is meant for inlining only (like __gnu_inline__ and some
other cases).

This approach, among other nice properties, ensures that alwaysinline
functions are always internal, making it impossible for a direct call
to such function to produce an undefined symbol reference.

This patch is based on ideas by Chandler Carruth and Richard Smith.

llvm-svn: 247465
2015-09-11 20:29:07 +00:00
Yaron Keren d2fc591c0b This test requires UTF-8 output to print the UT-8 characters.
llvm-svn: 247410
2015-09-11 13:29:12 +00:00
Ivan Krasin 4c3f237edb Do not include default sanitizer blacklists into -M/-MM/-MD/-MMD output.
Summary:
Do not include default sanitizer blacklists into -M/-MM/-MD/-MMD output.

Introduce a frontend option -fdepfile-entry, and only insert them
for the user-defined sanitizer blacklists. In frontend, grab ExtraDeps
from -fdepfile-entry, instead of -fsanitize-blacklist.

Reviewers: rsmith, pcc

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D12544

llvm-svn: 246700
2015-09-02 20:02:38 +00:00
Tyler Nowicki 8cb274ed0d Improve options printed on vectorization analysis diagnostics.
The LLVM patch changes the analysis diagnostics produced when loops with            
floating-point recurrences or memory operations are identified. The new messages
say "cannot prove it is safe to reorder * operations; allow reordering by       
specifying #pragma clang loop vectorize(enable)". Depending on the type of      
diagnostic the message will include additional options such as ffast-math or    
__restrict__.                                                                   

llvm-svn: 246189
2015-08-27 18:58:34 +00:00
Ivan Krasin 9cc0420211 Remove test cases, which rely on the default sanitizer blacklists.
Summary:
The default blacklists may vary across different architectures and
configurations. It was not wise to include into http://reviews.llvm.org/D11968

Reviewers: chapuni, pcc

Subscribers: cfe-commits, pcc

Differential Revision: http://reviews.llvm.org/D12021

llvm-svn: 244985
2015-08-13 23:37:28 +00:00
NAKAMURA Takumi a137bf9386 clang/test/Frontend/dependency-gen.c: Add explicit -target x86_64-linux-gnu for -fsanitize.
llvm-svn: 244970
2015-08-13 22:17:34 +00:00
Yaron Keren b768f77ed6 Disable failing check in bots from r244867.
llvm-svn: 244869
2015-08-13 06:12:49 +00:00
Ivan Krasin 1193f2cbc0 Add sanitizer blacklists to the rules generated with -M/-MM/-MD/-MMD.
Summary:
Clang sanitizers, such as AddressSanitizer, ThreadSanitizer, MemorySanitizer,
Control Flow Integrity and others, use blacklists to specify which types / functions
should not be instrumented to avoid false positives or suppress known failures.

This change adds the blacklist filenames to the list of dependencies of the rules,
generated with -M/-MM/-MD/-MMD. This lets CMake/Ninja recognize that certain
C/C++/ObjC files need to be recompiled (if a blacklist is updated).

Reviewers: pcc

Subscribers: rsmith, honggyu.kim, pcc, cfe-commits

Differential Revision: http://reviews.llvm.org/D11968

llvm-svn: 244867
2015-08-13 04:04:37 +00:00
Tyler Nowicki 26cee3d929 Make the analysis reporting test with x86 to fix the hexagon build.
llvm-svn: 244561
2015-08-11 01:54:48 +00:00
Tyler Nowicki 65061a293b Print vectorization analysis when loop hint is specified.
This patche and a related llvm patch solve the problem of having to explicitly enable analysis when specifying a loop hint pragma to get the diagnostics. Passing AlwasyPrint as the pass name (see below) causes the front-end to print the diagnostic if the user has specified '-Rpass-analysis' without an '=<target-pass>’. Users of loop hints can pass that compiler option without having to specify the pass and they will get diagnostics for only those loops with loop hints.

llvm-svn: 244556
2015-08-11 01:10:08 +00:00
Tyler Nowicki 034baf6154 Append options for vectorization when pointer checking threshold is exceeded.
Following one of the appended options will allow the loop to be vectorized. We do not include a command line option for modifying the pointer checking threshold because there is no clang-level interface for this currently.

llvm-svn: 244526
2015-08-10 23:05:16 +00:00
Tyler Nowicki 020dd79fb7 Make frontend floating-point commutivity test X86 specific to avoid cost-model related problems on arm-thumb and hexagon.
llvm-svn: 244517
2015-08-10 22:17:40 +00:00
Tyler Nowicki 40e5d08a74 Remove non-ascii characters.
llvm-svn: 244506
2015-08-10 21:18:01 +00:00
Tyler Nowicki 8a0925cb62 Append options for floating-point commutivity when related diagnostics are produced.
With this patch clang appends the command line options that would allow vectorization when floating-point commutativity is required. Specifically those are enabling fast-math or specifying a loop hint. 

llvm-svn: 244492
2015-08-10 19:56:40 +00:00
Adrian Prantl bc068586ac Revert "Revert r241620 and follow-up commits" and move the initialization
of the llvm targets from clang/CodeGen into ClangCheck.cpp and CIndex.cpp.

llvm-svn: 241653
2015-07-08 01:00:30 +00:00
Adrian Prantl 142ec39739 Revert r241620 and follow-up commits while investigating linux buildbot failures.
llvm-svn: 241642
2015-07-07 23:19:46 +00:00
Adrian Prantl e50371b948 Wrap clang modules and pch files in an object file container.
This patch adds ObjectFilePCHContainerOperations uses the LLVM backend
to put the contents of a PCH into a __clangast section inside a COFF, ELF,
or Mach-O object file container.

This is done to facilitate module debugging by makeing it possible to
store the debug info for the types defined by a module alongside the AST.

rdar://problem/20091852

llvm-svn: 241620
2015-07-07 20:11:29 +00:00