platform/upstream/llvm.git
6 years ago[ELF] - Simplify removeUnusedSyntheticSections a bit.
George Rimar [Mon, 25 Sep 2017 09:46:33 +0000 (09:46 +0000)]
[ELF] - Simplify removeUnusedSyntheticSections a bit.

Previously`InX::Got` and InX::MipsGot synthetic sections
were not removed if ElfSym::GlobalOffsetTable was defined.
ElfSym::GlobalOffsetTable is a symbol for _GLOBAL_OFFSET_TABLE_.

Patch moves ElfSym::GlobalOffsetTable check out from removeUnusedSyntheticSections.
Also note that there was no point to check ElfSym::GlobalOffsetTable for MIPS case
because InX::MipsGot::empty() always returns false for non-relocatable case, and in case
of relocatable output we do not create special symbols anyways.

Differential revision: https://reviews.llvm.org/D37623

llvm-svn: 314099

6 years ago[ELF] - Report orphan sections if -verbose given.
George Rimar [Mon, 25 Sep 2017 09:41:32 +0000 (09:41 +0000)]
[ELF] - Report orphan sections if -verbose given.

When -verbose is specified, patch outputs names of each input orphan section
assigned to output.

Differential revision: https://reviews.llvm.org/D37517

llvm-svn: 314098

6 years ago[ELF] - LTO: do not optimize away symbols accessed from linkerscript.
George Rimar [Mon, 25 Sep 2017 09:31:43 +0000 (09:31 +0000)]
[ELF] - LTO: do not optimize away symbols accessed from linkerscript.

Previously when BC file had global variable that was accessed from script,
it was optimized away or inlined by IPO.
In this patch I add symbols at left side of assignment expression as LinkerRedefined,
what prevents optimization for them.

Differential revision: https://reviews.llvm.org/D37059

llvm-svn: 314097

6 years ago[CodeGenPrepare][NFC] Rename TargetTransformInfo::expandMemCmp -> TargetTransformInfo...
Clement Courbet [Mon, 25 Sep 2017 06:35:16 +0000 (06:35 +0000)]
[CodeGenPrepare][NFC] Rename TargetTransformInfo::expandMemCmp -> TargetTransformInfo::enableMemCmpExpansion.

Summary:
Right now there are two functions with the same name, one does the work
and the other one returns true if expansion is needed. Rename
TargetTransformInfo::expandMemCmp to make it more consistent with other
members of TargetTransformInfo.

Remove the unused Instruction* parameter.

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

llvm-svn: 314096

6 years agoDo not sort CU vectors.
Rui Ueyama [Mon, 25 Sep 2017 05:30:39 +0000 (05:30 +0000)]
Do not sort CU vectors.

We used to sort and uniquify CU vectors, but looks like CU vectors in
.gdb_index sections created by gold are not guaranteed to be sorted.

llvm-svn: 314095

6 years agoSpeeds up CU vector creation.
Rui Ueyama [Mon, 25 Sep 2017 04:55:27 +0000 (04:55 +0000)]
Speeds up CU vector creation.

We used to use std::set to uniquify CU vector elements, but as we know,
std::set is pretty slow. Fortunately we didn't actually have to use a
std::set here. This patch replaces it with std::vector.

With this patch, lld's -gdb-index overhead when linking a clang debug
build is now about 1 second (8.65 seconds without -gdb-index vs 9.60
seconds with -gdb-index). Since gold takes more than 6 seconds to create
a .gdb_index for the same output, our number isn't that bad.

llvm-svn: 314094

6 years agoFix off-by-one error.
Rui Ueyama [Mon, 25 Sep 2017 03:40:45 +0000 (03:40 +0000)]
Fix off-by-one error.

llvm-svn: 314093

6 years agoDo not use StringTableBuilder to build symbol table for .gdb_index.
Rui Ueyama [Mon, 25 Sep 2017 02:29:51 +0000 (02:29 +0000)]
Do not use StringTableBuilder to build symbol table for .gdb_index.

Previously, we had two levels of hash table lookup. The first hash
lookup uses CachedHashStringRefs as keys and returns offsets in string
table. Then, we did the second hash table lookup to obtain GdbSymbol
pointers. But we can directly map strings to GDbSymbols.

One test file is updated in this patch because we no longer have a '\0'
byte at the start of the string pool, which was automatically inserted
by StringTableBuilder.

This patch speeds up Clang debug build (with -gdb-index) link time by
0.3 seconds.

llvm-svn: 314092

6 years agoCompute string hashes early and cache them.
Rui Ueyama [Mon, 25 Sep 2017 01:42:57 +0000 (01:42 +0000)]
Compute string hashes early and cache them.

This change alone speeds up linking of Clang debug build with -gdb-index
by 1.2 seconds, from 12.5 seconds to 11.3 seconds. (Without -gdb-index,
lld takes 8.5 seconds to link the same input files.)

llvm-svn: 314090

6 years agoRename copy -> copyFrom.
Rui Ueyama [Mon, 25 Sep 2017 00:57:30 +0000 (00:57 +0000)]
Rename copy -> copyFrom.

This patch is to improve code readability.

llvm-svn: 314089

6 years agoMove Config->SymbolRenaming to SymbolTable.
Rui Ueyama [Mon, 25 Sep 2017 00:57:18 +0000 (00:57 +0000)]
Move Config->SymbolRenaming to SymbolTable.

In order to keep track of symbol renaming, we used to have
Config->SymbolRenaming, and whether a symbol is in the map or not
affects its symbol attribute (i.e. "LinkeRedefined" bit).

This patch adds "CanInline" bit to Symbol to aggreagate symbol
information in one place and removed the member from Config since
no one except SymbolTable now uses the table.

llvm-svn: 314088

6 years agoRemove unused member variable.
Rui Ueyama [Sun, 24 Sep 2017 23:12:36 +0000 (23:12 +0000)]
Remove unused member variable.

llvm-svn: 314087

6 years agoRefactor GdbIndexSection. NFC.
Rui Ueyama [Sun, 24 Sep 2017 21:45:35 +0000 (21:45 +0000)]
Refactor GdbIndexSection. NFC.

This patch rewrites a part of GdbIndexSection to address the following
issues in the previous implementation:

 - Previously, some struct declarations were in GdbIndex.h while they
   were not used in GdbIndex.cpp. Such structs are moved to
   SyntheticSection.h.

 - The actual implementation were split into GdbIndexSection and GdbHash
   section, but that separation didn't make much sense. They are now
   unified as GdbIndexSection.

In addition to the above changes, this patch splits functions, rename
variables and remove redundant functions/variables to generally improve
code quality.

llvm-svn: 314084

6 years ago[X86] Make IFMA instructions during isel so we can fold broadcast loads.
Craig Topper [Sun, 24 Sep 2017 19:30:55 +0000 (19:30 +0000)]
[X86] Make IFMA instructions during isel so we can fold broadcast loads.

This required changing the ISD opcode for these instructions to have the commutable operands first and the addend last. This way tablegen can autogenerate the additional patterns for us.

llvm-svn: 314083

6 years ago[X86] Add tests to show missed opportunities to fold broadcast loads into IFMA instru...
Craig Topper [Sun, 24 Sep 2017 19:30:54 +0000 (19:30 +0000)]
[X86] Add tests to show missed opportunities to fold broadcast loads into IFMA instructions when the load is on operand1 of the instrinsic.

We need to enable commuting during isel to catch this since the load folding tables can't handle broadcasts.

llvm-svn: 314082

6 years ago[Polly] Information about generalized matrix multiplication
Roman Gareev [Sun, 24 Sep 2017 19:00:25 +0000 (19:00 +0000)]
[Polly] Information about generalized matrix multiplication

Reviewed-by: Tobias Grosser <tobias@grosser.es>
Differential Revision: https://reviews.llvm.org/D38218

llvm-svn: 314081

6 years ago[X86] Add IFMA instructions to the load folding tables and make them commutable for...
Craig Topper [Sun, 24 Sep 2017 17:28:14 +0000 (17:28 +0000)]
[X86] Add IFMA instructions to the load folding tables and make them commutable for the multiply operands.

llvm-svn: 314080

6 years agoFix implicit-fallthrough warning by adding missing break
Simon Pilgrim [Sun, 24 Sep 2017 15:17:46 +0000 (15:17 +0000)]
Fix implicit-fallthrough warning by adding missing break

llvm-svn: 314079

6 years agoFix signed/unsigned warning
Simon Pilgrim [Sun, 24 Sep 2017 14:00:52 +0000 (14:00 +0000)]
Fix signed/unsigned warning

llvm-svn: 314078

6 years ago[X86][SSE] Add more tests for shuffle combining with extracted vector elements (PR22415)
Simon Pilgrim [Sun, 24 Sep 2017 13:45:49 +0000 (13:45 +0000)]
[X86][SSE] Add more tests for shuffle combining with extracted vector elements (PR22415)

llvm-svn: 314077

6 years ago[X86][SSE] Add support for extending bool vectors bitcasted from scalars
Simon Pilgrim [Sun, 24 Sep 2017 13:42:31 +0000 (13:42 +0000)]
[X86][SSE] Add support for extending bool vectors bitcasted from scalars

This patch acts as a reverse to combineBitcastvxi1 - bitcasting a scalar integer to a boolean vector and extending it 'in place' to the requested legal type.

Currently this doesn't handle AVX512 at all - but the current mask register approach is lacking for some cases.

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

llvm-svn: 314076

6 years ago[ScopDetect/Info] Look through PHIs that follow an error block
Tobias Grosser [Sun, 24 Sep 2017 09:25:30 +0000 (09:25 +0000)]
[ScopDetect/Info] Look through PHIs that follow an error block

In case a PHI node follows an error block we can assume that the incoming value
can only come from the node that is not an error block. As a result, conditions
that seemed non-affine before are now in fact affine.

This is a recommit of r312663 after fixing
test/Isl/CodeGen/phi_after_error_block_outside_of_scop.ll

llvm-svn: 314075

6 years ago[PowerPC] Eliminate compares - add i64 sext/zext handling for SETLE/SETGE
Nemanja Ivanovic [Sun, 24 Sep 2017 05:48:11 +0000 (05:48 +0000)]
[PowerPC] Eliminate compares - add i64 sext/zext handling for SETLE/SETGE

As mentioned in https://reviews.llvm.org/D33718, this simply adds another
pattern to the compare elimination sequence and is committed without a
differential review.

llvm-svn: 314073

6 years ago[AVX-512] Add pattern for selecting masked version of v8i32/v8f32 compare instruction...
Craig Topper [Sun, 24 Sep 2017 05:24:52 +0000 (05:24 +0000)]
[AVX-512] Add pattern for selecting masked version of v8i32/v8f32 compare instructions when VLX isn't available.

We use a v16i32/v16f32 compare instead and truncate the result. We already did this for the unmasked version, but were missing the version with 'and'.

llvm-svn: 314072

6 years ago[X86] Make sure we still mark the full register as implicitly defined when we shrink...
Craig Topper [Sun, 24 Sep 2017 05:24:51 +0000 (05:24 +0000)]
[X86] Make sure we still mark the full register as implicitly defined when we shrink 256/512 bit zeroing xors to 128-bit.

Not sure if anything really cares, but this seems like the right thing to do.

llvm-svn: 314071

6 years ago[AVR] Implement getCmpLibcallReturnType().
Dylan McKay [Sun, 24 Sep 2017 01:07:26 +0000 (01:07 +0000)]
[AVR] Implement getCmpLibcallReturnType().

This fixes the avr-rust issue (#75) with floating-point comparisons generating broken code.
By default, LLVM assumes these comparisons return 32-bit values, but ours are 8-bit.

Patch By Thomas Backman.

llvm-svn: 314070

6 years ago[Verifier] Stop accepting broken DIGlobalVariable(s).
Davide Italiano [Sun, 24 Sep 2017 01:06:35 +0000 (01:06 +0000)]
[Verifier] Stop accepting broken DIGlobalVariable(s).

The code wasn't yelling at the user when there's a reference
from a DIGlobalVariableExpression. Thanks to Adrian for the
reduced testcase. Fixes PR34672.

llvm-svn: 314069

6 years ago[X86] Regenerate i64 to v2f32 bitcast test
Simon Pilgrim [Sat, 23 Sep 2017 19:18:29 +0000 (19:18 +0000)]
[X86] Regenerate i64 to v2f32 bitcast test

llvm-svn: 314068

6 years agoDon't warn about runtime behavior problems in variable initializers that we
Richard Smith [Sat, 23 Sep 2017 18:27:11 +0000 (18:27 +0000)]
Don't warn about runtime behavior problems in variable initializers that we
know are going to be constant-evaluated.

Any relevant diagnostics should be produced by constant expression evaluation.

llvm-svn: 314067

6 years agoSilence unused variable warning in Release builds.
Benjamin Kramer [Sat, 23 Sep 2017 16:08:48 +0000 (16:08 +0000)]
Silence unused variable warning in Release builds.

llvm-svn: 314066

6 years ago[IslExprBuilder] Do not generate RTC with more than 64 bit
Tobias Grosser [Sat, 23 Sep 2017 15:32:07 +0000 (15:32 +0000)]
[IslExprBuilder] Do not generate RTC with more than 64 bit

Such RTCs may introduce integer wrapping intrinsics with more than 64 bit,
which are translated to library calls on AOSP that are not part of the
runtime and will consequently cause linker errors.

Thanks to Eli Friedman for reporting this issue and reducing the test case.

llvm-svn: 314065

6 years ago[x86] reduce 64-bit mask constant to 32-bits by right shifting
Sanjay Patel [Sat, 23 Sep 2017 14:32:07 +0000 (14:32 +0000)]
[x86] reduce 64-bit mask constant to 32-bits by right shifting

This is a follow-up from D38181 (r314023). We have to put 64-bit
constants into a register using a separate instruction, so we
should try harder to avoid that.

From what I see, we're not likely to encounter this pattern in the
DAG because the upstream setcc combines from this don't (usually?)
produce this pattern. If we fix that, then this will become more
relevant. Since the cost of handling this case is just loosening
the predicate of the existing fold, we might as well do it now.

llvm-svn: 314064

6 years ago[x86] add an add+shift test for follow-up suggestion from D38181; NFC
Sanjay Patel [Sat, 23 Sep 2017 14:24:07 +0000 (14:24 +0000)]
[x86] add an add+shift test for follow-up suggestion from D38181; NFC

llvm-svn: 314063

6 years ago[PowerPC] Eliminate compares - add i32 sext/zext handling for SETULT/SETUGT
Nemanja Ivanovic [Sat, 23 Sep 2017 12:53:03 +0000 (12:53 +0000)]
[PowerPC] Eliminate compares - add i32 sext/zext handling for SETULT/SETUGT

As mentioned in https://reviews.llvm.org/D33718, this simply adds another
pattern to the compare elimination sequence and is committed without a
differential revision.

llvm-svn: 314062

6 years ago[docs] Fix typos in Clang's User's Manual.
Reka Kovacs [Sat, 23 Sep 2017 12:13:32 +0000 (12:13 +0000)]
[docs] Fix typos in Clang's User's Manual.

llvm-svn: 314061

6 years ago[PowerPC] Eliminate compares - add i32 sext/zext handling for SETULE/SETUGE
Nemanja Ivanovic [Sat, 23 Sep 2017 09:50:12 +0000 (09:50 +0000)]
[PowerPC] Eliminate compares - add i32 sext/zext handling for SETULE/SETUGE

As mentioned in https://reviews.llvm.org/D33718, this simply adds another
pattern to the compare elimination sequence and is committed without a
differential revision.

llvm-svn: 314060

6 years ago[X86] Move the getInsertVINSERTImmediate and getExtractVEXTRACTImmediate helper funct...
Craig Topper [Sat, 23 Sep 2017 05:34:07 +0000 (05:34 +0000)]
[X86] Move the getInsertVINSERTImmediate and getExtractVEXTRACTImmediate helper functions over to X86ISelDAGToDAG.cpp

Redefine them to call getI8Imm and return that directly.

llvm-svn: 314059

6 years ago[X86] Remove is the isVINSERT*Index/isVEXTRACT*Index predicates from isel.
Craig Topper [Sat, 23 Sep 2017 05:34:06 +0000 (05:34 +0000)]
[X86] Remove is the isVINSERT*Index/isVEXTRACT*Index predicates from isel.

The only insert_subvector/extract_subvector nodes that make it to isel are guaranteed to match.

llvm-svn: 314058

6 years ago[ubsan] Fix assert.cc test by compiling it as C++
Vitaly Buka [Sat, 23 Sep 2017 05:09:45 +0000 (05:09 +0000)]
[ubsan] Fix assert.cc test by compiling it as C++

llvm-svn: 314057

6 years agoPromote storage-only __fp16 vector operands to float vectors.
Akira Hatanaka [Sat, 23 Sep 2017 05:02:02 +0000 (05:02 +0000)]
Promote storage-only __fp16 vector operands to float vectors.

This commit fixes a bug in the handling of storage-only __fp16 vectors
where clang didn't promote __fp16 vector operands to float vectors.

Conceptually, it performs the following transformation on the AST in
CreateBuiltinBinOp and CreateBuiltinUnaryOp:

(Before)
  typedef __fp16 half4 __attribute__ ((vector_size (8)));
  typedef float float4 __attribute__ ((vector_size (16)));
  half4 hv0, hv1, hv2, hv3;

  hv0 = hv1 + hv2 + hv3;

(After)
  float4 t0 = (float4)hv1 + (float4)hv2;
  float4 t1 = t0 + (float4)hv3;
  hv0 = (half4)t1;

Note that this commit fixes the bug for targets that set
HalfArgsAndReturns to true (ARM and ARM64). Targets using intrinsics
such as llvm.convert.to.fp16 to handle __fp16 are still broken.

rdar://problem/20625184

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

llvm-svn: 314056

6 years ago[PowerPC] Eliminate compares - add i32 sext/zext handling for SETLT/SETGT
Nemanja Ivanovic [Sat, 23 Sep 2017 04:41:34 +0000 (04:41 +0000)]
[PowerPC] Eliminate compares - add i32 sext/zext handling for SETLT/SETGT

As mentioned in https://reviews.llvm.org/D33718, this simply adds another
pattern to the compare elimination sequence and is committed without a
differential revision.

llvm-svn: 314055

6 years agoCorrectly compute linkage for members of internal linkage classes.
Richard Smith [Sat, 23 Sep 2017 04:02:17 +0000 (04:02 +0000)]
Correctly compute linkage for members of internal linkage classes.

We used to give such members no linkage instead of giving them the linkage of
the class.

llvm-svn: 314054

6 years ago[ubsan] Replace CommonSanitizerReportMutex with ScopedErrorReportLock
Vitaly Buka [Sat, 23 Sep 2017 02:47:21 +0000 (02:47 +0000)]
[ubsan] Replace CommonSanitizerReportMutex with ScopedErrorReportLock

Reviewers: eugenis, alekseyshl

Subscribers: kubamracek, llvm-commits

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

llvm-svn: 314053

6 years ago[ubsan] Support signal specific options in ubsan
Vitaly Buka [Sat, 23 Sep 2017 02:47:11 +0000 (02:47 +0000)]
[ubsan] Support signal specific options in ubsan

Summary:
Part of https://github.com/google/sanitizers/issues/637

Standalone ubsan needs signal and sigaction handlers and interceptors.
Plugin mode should rely on parent tool.

Reviewers: eugenis, alekseyshl

Subscribers: kubamracek, llvm-commits, mgorny

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

llvm-svn: 314052

6 years agoCommit missing fixes for tool_file_rename
Reid Kleckner [Sat, 23 Sep 2017 01:04:42 +0000 (01:04 +0000)]
Commit missing fixes for tool_file_rename

llvm-svn: 314051

6 years ago[Support] Rename tool_output_file to ToolOutputFile, NFC
Reid Kleckner [Sat, 23 Sep 2017 01:03:17 +0000 (01:03 +0000)]
[Support] Rename tool_output_file to ToolOutputFile, NFC

This class isn't similar to anything from the STL, so it shouldn't use
the STL naming conventions.

llvm-svn: 314050

6 years ago[CodeGen] Fix build bots which uses old Clang broken in r314046. (NFC)
Eugene Zelenko [Fri, 22 Sep 2017 23:55:32 +0000 (23:55 +0000)]
[CodeGen] Fix build bots which uses old Clang broken in r314046. (NFC)

llvm-svn: 314049

6 years ago[lsan] Add __lsan_default_options
Vitaly Buka [Fri, 22 Sep 2017 23:49:49 +0000 (23:49 +0000)]
[lsan] Add __lsan_default_options

For consistency with asan, msan, tsan and ubsan.

llvm-svn: 314048

6 years agoFix up clang-tidy after clang r314037.
Richard Smith [Fri, 22 Sep 2017 23:47:20 +0000 (23:47 +0000)]
Fix up clang-tidy after clang r314037.

llvm-svn: 314047

6 years ago[CodeGen] Fix some Clang-tidy modernize-use-default-member-init and Include What...
Eugene Zelenko [Fri, 22 Sep 2017 23:46:57 +0000 (23:46 +0000)]
[CodeGen] Fix some Clang-tidy modernize-use-default-member-init and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 314046

6 years agoImplement trampoline step-through for Windows-x86.
Stephane Sezer [Fri, 22 Sep 2017 23:41:41 +0000 (23:41 +0000)]
Implement trampoline step-through for Windows-x86.

Summary:
This is required to be able to step through calls to external functions
that are not properly marked with __declspec(dllimport). When a call
like this is emitted, the linker will inject a trampoline to produce an
indirect call through the IAT.

Reviewers: zturner, jingham

Reviewed By: jingham

Subscribers: sas, jingham, lldb-commits

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

llvm-svn: 314045

6 years ago[X86] [MC] fixed non optimal encoding of instruction memory operand (PR24038).
Konstantin Belochapka [Fri, 22 Sep 2017 23:37:48 +0000 (23:37 +0000)]
[X86] [MC] fixed non optimal encoding of instruction memory operand (PR24038).
Fixed suboptimal encoding of instruction memory operand when assembler is used to select 32 bit fixup rather than 8 bit immediate for encoding memory offset value.
Differential Revision: https://reviews.llvm.org/D38117

llvm-svn: 314044

6 years agoFix uninteneded fallthrough detected by GCC warning
Reid Kleckner [Fri, 22 Sep 2017 23:19:52 +0000 (23:19 +0000)]
Fix uninteneded fallthrough detected by GCC warning

llvm-svn: 314043

6 years ago[Analyzer] Fix minor errors in python scripts.
George Karpenkov [Fri, 22 Sep 2017 22:58:46 +0000 (22:58 +0000)]
[Analyzer] Fix minor errors in python scripts.

llvm-svn: 314042

6 years ago[lsan] Deadly signal handler for lsan
Vitaly Buka [Fri, 22 Sep 2017 22:57:48 +0000 (22:57 +0000)]
[lsan] Deadly signal handler for lsan

Summary: Part of https://github.com/google/sanitizers/issues/637

Reviewers: eugenis, alekseyshl

Subscribers: llvm-commits, dberris, kubamracek, krytarowski

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

llvm-svn: 314041

6 years ago[sanitizer] Replace thread id with GetThreadSelf
Vitaly Buka [Fri, 22 Sep 2017 22:36:21 +0000 (22:36 +0000)]
[sanitizer] Replace thread id with GetThreadSelf

This allows to avoid constructor parameter

llvm-svn: 314040

6 years ago[sanitizer] Move ScopedErrorReportLock into libcdep version
Vitaly Buka [Fri, 22 Sep 2017 22:36:11 +0000 (22:36 +0000)]
[sanitizer] Move ScopedErrorReportLock into libcdep version

llvm-svn: 314039

6 years agoInitial patchset to get the testsuite running against armv7 and arm64 iOS devices.
Jason Molenda [Fri, 22 Sep 2017 22:34:53 +0000 (22:34 +0000)]
Initial patchset to get the testsuite running against armv7 and arm64 iOS devices.
Normal customer devices won't be able to run these devices, we're hoping to get
a public facing bot set up at some point.  Both devices pass the testsuite without
any errors or failures.

I have seen some instability with the armv7 test runs, I may submit additional patches
to address this.  arm64 looks good.

I'll be watching the bots for the rest of today; if any problems are introduced by
this patch I'll revert it - if anyone sees a problem with their bot that I don't
see, please do the same.  I know it's a rather large patch.

One change I had to make specifically for iOS devices was that debugserver can't
create files.  There were several tests that launch the inferior process redirecting
its output to a file, then they retrieve the file.  They were not trying to test
file redirection in these tests, so I rewrote those to write their output to a file
directly.

llvm-svn: 314038

6 years agoDR1113: anonymous namespaces formally give their contents internal linkage.
Richard Smith [Fri, 22 Sep 2017 22:21:44 +0000 (22:21 +0000)]
DR1113: anonymous namespaces formally give their contents internal linkage.

This doesn't affect our code generation in any material way -- we already give
such declarations internal linkage from a codegen perspective -- but it has
some subtle effects on code validity.

We suppress the 'L' (internal linkage) marker for mangled names in anonymous
namespaces, because it is redundant (the information is already carried by the
namespace); this deviates from GCC's behavior if a variable or function in an
anonymous namespace is redundantly declared 'static' (where GCC does include
the 'L'), but GCC's behavior is incoherent because such a declaration can be
validly declared with or without the 'static'.

We still deviate from the standard in one regard here: extern "C" declarations
in anonymous namespaces are still granted external linkage. Changing those does
not appear to have been an intentional consequence of the standard change in
DR1113.

llvm-svn: 314037

6 years ago[test] Enable clang-func-mapping as a test dep with the analyzer
Vedant Kumar [Fri, 22 Sep 2017 22:17:10 +0000 (22:17 +0000)]
[test] Enable clang-func-mapping as a test dep with the analyzer

clang-func-mapping should not be a test dependency when the static
analyzer isn't being built.

llvm-svn: 314036

6 years agoFix unused variable warning in non-debug builds.
Richard Trieu [Fri, 22 Sep 2017 22:16:13 +0000 (22:16 +0000)]
Fix unused variable warning in non-debug builds.

llvm-svn: 314035

6 years agoclang-format plugin: Add missing NL (new line) at EOF (end of file)
Hans Wennborg [Fri, 22 Sep 2017 21:47:39 +0000 (21:47 +0000)]
clang-format plugin: Add missing NL (new line) at EOF (end of file)

clang-format.exe removes trailing new lines at end of file.

However, if no NL is found at EOF one should be added.

Patch by Teodor MICU!

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

llvm-svn: 314033

6 years ago[InstCombine] Teach foldICmpUsingKnownBits to simplify SLE/SGE/ULE/UGE to equality...
Craig Topper [Fri, 22 Sep 2017 21:47:22 +0000 (21:47 +0000)]
[InstCombine] Teach foldICmpUsingKnownBits to simplify SLE/SGE/ULE/UGE to equality comparisons when the min/max ranges intersect in a single value.

This is the inverse of what we do for SGT/SLT/UGT/ULT.

llvm-svn: 314032

6 years ago[InstCombine] Add test cases for known bits simplifications for comparisons that...
Craig Topper [Fri, 22 Sep 2017 21:47:21 +0000 (21:47 +0000)]
[InstCombine] Add test cases for known bits simplifications for comparisons that don't depend on constant RHS. NFC

This shows some missing simplifications for sge/sle/uge/ule relative to their non-equality counterparts.

llvm-svn: 314031

6 years ago[InstCombine] Remove a FIXME from a test that was fixed in r314025.
Craig Topper [Fri, 22 Sep 2017 21:47:20 +0000 (21:47 +0000)]
[InstCombine] Remove a FIXME from a test that was fixed in r314025.

llvm-svn: 314030

6 years ago[CodeGen][ObjC] Build the global block structure before emitting the
Akira Hatanaka [Fri, 22 Sep 2017 21:32:06 +0000 (21:32 +0000)]
[CodeGen][ObjC] Build the global block structure before emitting the
body of global block invoke functions.

This commit fixes an infinite loop in IRGen that occurs when compiling
the following code:

void FUNC2() {
  static void (^const block1)(int) = ^(int a){
    if (a--)
      block1(a);
  };
}

This is how IRGen gets stuck in the infinite loop:

1. GenerateBlockFunction is called to emit the body of "block1".

2. GetAddrOfGlobalBlock is called to get the address of "block1". The
   function calls getAddrOfGlobalBlockIfEmitted to check whether the
   global block has been emitted. If it hasn't been emitted, it then
   tries to emit the body of the block function by calling
   GenerateBlockFunction, which goes back to step 1.

This commit prevents the inifinite loop by building the global block in
GenerateBlockFunction before emitting the body of the block function.

rdar://problem/34541684

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

llvm-svn: 314029

6 years agoFixed broken links in docs.
Ilya Biryukov [Fri, 22 Sep 2017 21:10:37 +0000 (21:10 +0000)]
Fixed broken links in docs.

Replaced references to `llvm.org/klaus` with `git.llvm.org/klaus`.

llvm-svn: 314028

6 years ago[x86] remove over-specified platform from test config
Sanjay Patel [Fri, 22 Sep 2017 21:07:13 +0000 (21:07 +0000)]
[x86] remove over-specified platform from test config

llvm-svn: 314027

6 years ago[PowerPC] Mark P9 scheduling model complete
Stefan Pintilie [Fri, 22 Sep 2017 20:17:25 +0000 (20:17 +0000)]
[PowerPC] Mark P9 scheduling model complete

This patch just adds the missing information to the P9 scheduling model to allow
the model to be marked as complete.

The model has been verified against P9 documentation. The model was verified
with utils/schedcover.py.

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

llvm-svn: 314026

6 years ago[InstCombine] Add constant splat handling to one of the ICMP_SLT/SGT cases in foldICm...
Craig Topper [Fri, 22 Sep 2017 19:54:15 +0000 (19:54 +0000)]
[InstCombine] Add constant splat handling to one of the ICMP_SLT/SGT cases in foldICmpUsingKnownBits.

llvm-svn: 314025

6 years ago[x86] shiftRightAlgebraic -> shiftRightArithmetic; NFC
Sanjay Patel [Fri, 22 Sep 2017 19:49:37 +0000 (19:49 +0000)]
[x86] shiftRightAlgebraic -> shiftRightArithmetic; NFC

x86 re-education camp is in session. The LLVM LangRef agrees with x86 too.
The DAG nodes are undocumented and ambiguous as always. :)

llvm-svn: 314024

6 years ago[x86] swap order of srl (and X, C1), C2 when it saves size
Sanjay Patel [Fri, 22 Sep 2017 19:37:21 +0000 (19:37 +0000)]
[x86] swap order of srl (and X, C1), C2 when it saves size

The (non-)obvious win comes from saving 3 bytes by using the 0x83 'and' opcode variant instead of 0x81.
There are also better improvements based on known-bits that allow us to eliminate the mask entirely.

As noted, this could be extended. There are potentially other wins from always shifting first, but doing
that reveals a tangle of problems in other pattern matching. We do this transform generically in
instcombine, but we often have icmp IR that doesn't match that pattern, so we must account for this
in the backend.

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

llvm-svn: 314023

6 years ago[clang] Fix isExternC matcher docs
Alexander Shaposhnikov [Fri, 22 Sep 2017 19:29:38 +0000 (19:29 +0000)]
[clang] Fix isExternC matcher docs

The wording in the documentation for the matcher isExternC
appears to be misleading since this matcher
is applicable to functions and variables as well.
This diff changes the comment and regenerates the html file.

Differential revision: https://reviews.llvm.org/D38151

llvm-svn: 314022

6 years agoFix fuchsia builds broken by r313999
Francis Ricci [Fri, 22 Sep 2017 19:22:08 +0000 (19:22 +0000)]
Fix fuchsia builds broken by r313999

llvm-svn: 314021

6 years ago[clangd] Updated gold for completion tests after cfe changes.
Ilya Biryukov [Fri, 22 Sep 2017 19:07:45 +0000 (19:07 +0000)]
[clangd] Updated gold for completion tests after cfe changes.

llvm-svn: 314020

6 years agoSet completion priority of destructors and operators to CCP_Unlikely.
Ilya Biryukov [Fri, 22 Sep 2017 19:07:37 +0000 (19:07 +0000)]
Set completion priority of destructors and operators to CCP_Unlikely.

Summary:
It will move destructors and operators to the end of completion list.
Destructors and operators are currently very high on the completion
list, as they have the same priority as member functions. However,
they are clearly not something users usually choose in completion
lists.

Reviewers: arphaman, erikjv, bkramer, krasimir

Reviewed By: arphaman

Subscribers: eraman, klimek, cfe-commits

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

llvm-svn: 314019

6 years ago[InstCombine] Move the call to isSignBitCheck into getDemandedBitsLHSMask instead...
Craig Topper [Fri, 22 Sep 2017 18:57:23 +0000 (18:57 +0000)]
[InstCombine] Move the call to isSignBitCheck into getDemandedBitsLHSMask instead of calling it outside and passing its result through a flag. NFCI

The result of the isSignBitCheck isn't used anywhere else and this allows us to share the m_APInt call in the likely case that it isn't a sign bit check.

llvm-svn: 314018

6 years ago[InstCombine] Simplify check for RHS being a splat constant in foldICmpUsingKnownBits...
Craig Topper [Fri, 22 Sep 2017 18:57:22 +0000 (18:57 +0000)]
[InstCombine] Simplify check for RHS being a splat constant in foldICmpUsingKnownBits by just checking Op1Min==Op1Max rather than going through m_APInt.

llvm-svn: 314017

6 years ago[InstCombine] Make cases for ICMP_UGT/ICMP_ULT use similar formatting since they...
Craig Topper [Fri, 22 Sep 2017 18:57:20 +0000 (18:57 +0000)]
[InstCombine] Make cases for ICMP_UGT/ICMP_ULT use similar formatting since they use similar code. NFC

llvm-svn: 314016

6 years ago[sanitizer] Replace AddressSanitizer with correct tool name
Vitaly Buka [Fri, 22 Sep 2017 18:50:18 +0000 (18:50 +0000)]
[sanitizer] Replace AddressSanitizer with correct tool name

llvm-svn: 314015

6 years agoDeflake the "xpc-race.mm" test.
Kuba Mracek [Fri, 22 Sep 2017 18:49:56 +0000 (18:49 +0000)]
Deflake the "xpc-race.mm" test.

llvm-svn: 314014

6 years ago[lit.cfg] Avoid concatenating which(clang-func-mapping) if it's missing
Vedant Kumar [Fri, 22 Sep 2017 18:42:28 +0000 (18:42 +0000)]
[lit.cfg] Avoid concatenating which(clang-func-mapping) if it's missing

This un-breaks a lit workflow where you run lit tests from a test
sub-directory within clang without first building clang-func-mapping.

llvm-svn: 314013

6 years agoMove code to a helper function. NFC.
Rafael Espindola [Fri, 22 Sep 2017 18:40:14 +0000 (18:40 +0000)]
Move code to a helper function. NFC.

Part of a patch by Jake Ehrlich!

llvm-svn: 314012

6 years ago[clang] Fix printf fixit for objc specific types
Alexander Shaposhnikov [Fri, 22 Sep 2017 18:36:06 +0000 (18:36 +0000)]
[clang] Fix printf fixit for objc specific types

For the triple thumbv7-apple-ios8.0.0 ssize_t is long and size_t is unsigned long,
while NSInteger is int and NSUinteger is unsigned int. Following
https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Strings/Articles/formatSpecifiers.html
Clang catches it and insert a cast to long, for example
 printf("%zd", getNSInteger())
will be replaced with
 printf("%zd", (long)getNSInteger())
but since the underlying type of ssize_t is long the specifier "%zd" is not getting replaced.
This diff changes this behavior to enable replacing the specifier "%zd" with the correct one.

Differential revision: https://reviews.llvm.org/D38159

Test plan: make check-all

llvm-svn: 314011

6 years agollvm-ar: align the first archive member consistently.
Rafael Espindola [Fri, 22 Sep 2017 18:36:00 +0000 (18:36 +0000)]
llvm-ar: align the first archive member consistently.

Before we were aligning the member after the symbol table to 4 but
other members to 8.

llvm-svn: 314010

6 years agobindings: expose Linkage to the python bindings
Saleem Abdulrasool [Fri, 22 Sep 2017 18:35:09 +0000 (18:35 +0000)]
bindings: expose Linkage to the python bindings

Add Python bindings for the 'clang_getCursorLinkage', and tests to
validate the functionality.

Patch by Masud Rahman!

llvm-svn: 314009

6 years ago[sanitizer] Move report locking code from asan into common
Vitaly Buka [Fri, 22 Sep 2017 18:32:05 +0000 (18:32 +0000)]
[sanitizer] Move report locking code from asan into common

llvm-svn: 314008

6 years ago[asan] Fix unlocking order for CommonSanitizerReportMutex and reporting_thread_tid_
Vitaly Buka [Fri, 22 Sep 2017 18:31:51 +0000 (18:31 +0000)]
[asan] Fix unlocking order for CommonSanitizerReportMutex and reporting_thread_tid_

llvm-svn: 314007

6 years ago[sanitizer] Move CommonSanitizerReportMutex from _print.cc to _common.cc
Vitaly Buka [Fri, 22 Sep 2017 18:31:37 +0000 (18:31 +0000)]
[sanitizer] Move CommonSanitizerReportMutex from _print.cc to _common.cc

llvm-svn: 314006

6 years ago[XRay] support conditional return on PPC.
Tim Shen [Fri, 22 Sep 2017 18:30:02 +0000 (18:30 +0000)]
[XRay] support conditional return on PPC.

Summary: Conditional returns were not taken into consideration at all. Implement them by turning them into jumps and normal returns. This means there is a slightly higher performance penalty for conditional returns, but this is the best we can do, and it still disturbs little of the rest.

Reviewers: dberris, echristo

Subscribers: sanjoy, nemanjai, hiraditya, kbarton, llvm-commits

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

llvm-svn: 314005

6 years ago[TableGen] Replace InfoByHwMode::getAsString with writeToStream
Krzysztof Parzyszek [Fri, 22 Sep 2017 18:29:37 +0000 (18:29 +0000)]
[TableGen] Replace InfoByHwMode::getAsString with writeToStream

Also add operator<< for use with raw_ostream to InfoByHwMode and its
derived classes.

Recommitting r313989 with the fix for unresolved references: explicitly
define the operator<< in namespace llvm.

llvm-svn: 314004

6 years ago[TargetTransformInfo] Handle intrinsic call in getInstructionLatency()
Guozhi Wei [Fri, 22 Sep 2017 18:25:53 +0000 (18:25 +0000)]
[TargetTransformInfo] Handle intrinsic call in getInstructionLatency()

Usually an intrinsic is a simple target instruction, it should have a small latency. A real function call has much larger latency. So handle the intrinsic call in function getInstructionLatency().

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

llvm-svn: 314003

6 years ago[Coverage] Add an option to emit limited coverage info
Vedant Kumar [Fri, 22 Sep 2017 18:23:04 +0000 (18:23 +0000)]
[Coverage] Add an option to emit limited coverage info

Add an option to emit limited coverage info for unused decls. It's just a
cl::opt for now to allow us to experiment quickly.

When building llc, this results in an 84% size reduction in the llvm_covmap
section, and a similar size reduction in the llvm_prf_names section. In
practice I expect the size reduction to be roughly quadratic with the size of
the program.

The downside is that coverage for headers will no longer be complete. This will
make the line/function/region coverage metrics incorrect, since they will be
artificially high. One mitigation would be to somehow disable those metrics
when using limited-coverage=true.

This is related to: llvm.org/PR34533 (make SourceBasedCodeCoverage scale)

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

llvm-svn: 314002

6 years agoFix windows buildbot broken by r313999
Francis Ricci [Fri, 22 Sep 2017 18:17:26 +0000 (18:17 +0000)]
Fix windows buildbot broken by r313999

llvm-svn: 314001

6 years agollvm-ar: Don't add an unnecessary alignment in gnu mode.
Rafael Espindola [Fri, 22 Sep 2017 18:16:13 +0000 (18:16 +0000)]
llvm-ar: Don't add an unnecessary alignment in gnu mode.

This is mostly for getting stricter testing in preparation for future
changes.

llvm-svn: 314000

6 years agoRemoved platform-specific ifdefs from sanitizer_procmaps.h
Francis Ricci [Fri, 22 Sep 2017 17:48:24 +0000 (17:48 +0000)]
Removed platform-specific ifdefs from sanitizer_procmaps.h

Summary: Removed platform-specific ifdefs for linux, mac, freebsd and netbsd from sanitizer_procmaps.h

Patch by Yicheng Wang <yichengfb@fb.com>

Reviewers: kcc, kubamracek, alekseyshl, fjricci, vitalybuka

Reviewed By: fjricci, vitalybuka

Subscribers: vitalybuka, emaste, krytarowski, llvm-commits

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

llvm-svn: 313999

6 years ago [Falkor] Add falkor CPU to host detection
Balaram Makam [Fri, 22 Sep 2017 17:46:36 +0000 (17:46 +0000)]
[Falkor] Add falkor CPU to host detection

    This returns "falkor" for Falkor CPU.

llvm-svn: 313998

6 years ago[index] Generate class & metaclass manglings for objc
Dave Lee [Fri, 22 Sep 2017 16:58:57 +0000 (16:58 +0000)]
[index] Generate class & metaclass manglings for objc

Summary:
ObjC classes have two associated symbols, one for the class and one for the
metaclass.

This change overloads `CodegenNameGenerator::getAllManglings` to produce both
class and metaclass symbols.

While this function is called by `clang_Cursor_getCXXManglings`, it's only
called for CXXRecordDecl and CXXMethodDecl, and so libclang's behavior is
unchanged.

Reviewers: arphaman, abdulras, alexshap, compnerd

Reviewed By: compnerd

Subscribers: compnerd

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

llvm-svn: 313997

6 years agoRemove trailing whitespace. NFCI.
Simon Pilgrim [Fri, 22 Sep 2017 16:57:28 +0000 (16:57 +0000)]
Remove trailing whitespace. NFCI.

llvm-svn: 313996

6 years ago[OPENMP] Handle re-declaration of captured variables in CodeGen.
Alexey Bataev [Fri, 22 Sep 2017 16:56:13 +0000 (16:56 +0000)]
[OPENMP] Handle re-declaration of captured variables in CodeGen.

If the captured variable has re-declaration we may end up with the
situation where the captured variable is the re-declaration while the
referenced variable is the canonical declaration (or vice versa). In
this case we may generate wrong code. Patch fixes this situation.

llvm-svn: 313995