platform/upstream/llvm.git
4 years ago[AMDGPU] Fix typo.
Michael Liao [Fri, 26 Jul 2019 17:13:59 +0000 (17:13 +0000)]
[AMDGPU] Fix typo.

llvm-svn: 367131

4 years ago[llvm-objcopy] Add support for --add-section for COFF
Sergey Dmitriev [Fri, 26 Jul 2019 17:06:41 +0000 (17:06 +0000)]
[llvm-objcopy] Add support for --add-section for COFF

This patch enables support for --add-section=... option for COFF objects.

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

llvm-svn: 367130

4 years ago[CMake] Fix find_python_libs_windows
Jonas Devlieghere [Fri, 26 Jul 2019 16:32:49 +0000 (16:32 +0000)]
[CMake] Fix find_python_libs_windows

Exporting PYTHON_INCLUDE_DIR to the Python scope somehow got lost in my
last change. Add it back again. This should fix the Windows bot!

llvm-svn: 367127

4 years ago[ELF] Simplify with dyn_cast_or_null. NFC
Fangrui Song [Fri, 26 Jul 2019 16:29:15 +0000 (16:29 +0000)]
[ELF] Simplify with dyn_cast_or_null. NFC

llvm-svn: 367126

4 years ago[CMake] Print Python version on Windows
Jonas Devlieghere [Fri, 26 Jul 2019 16:15:19 +0000 (16:15 +0000)]
[CMake] Print Python version on Windows

Trying to figure out what's causing the Windows bot to fail.

llvm-svn: 367125

4 years ago[AArch64][SVE2] Rename bitperm feature to sve2-bitperm
Cullen Rhodes [Fri, 26 Jul 2019 15:57:50 +0000 (15:57 +0000)]
[AArch64][SVE2] Rename bitperm feature to sve2-bitperm

Summary:
The bitperm feature flag is now prefixed with SVE2, as it is for all other SVE2
extensions

Patch by Maciej Gabka.

Reviewers: sdesmalen, rovka, chill, SjoerdMeijer, rengolin

Reviewed By: SjoerdMeijer, rengolin

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

llvm-svn: 367124

4 years ago[llvm] [lit/tests] Replace 'env -u' with more portable construct
Michal Gorny [Fri, 26 Jul 2019 15:39:05 +0000 (15:39 +0000)]
[llvm] [lit/tests] Replace 'env -u' with more portable construct

Set environment variables to empty values rather than attempting
to unset them via 'env -u', in order to fix NetBSD test regression
caused by r366980.  POSIX does not guarantee that env(1) supports '-u'
option, and indeed NetBSD env(1) does not support it.

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

llvm-svn: 367123

4 years ago[llvm] [FileCheck] Use FILECHECK_DUMP_INPUT_ON_FAILURE only when non-empty
Michal Gorny [Fri, 26 Jul 2019 15:38:57 +0000 (15:38 +0000)]
[llvm] [FileCheck] Use FILECHECK_DUMP_INPUT_ON_FAILURE only when non-empty

Enable dumping output only if FILECHECK_DUMP_INPUT_ON_FAILURE is set to
a non-empty value.  This is necessary to support disabling it via
POSIX-compliant env(1) that does not support '-u' argument,
and therefore fix regression caused by r366980.

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

llvm-svn: 367122

4 years ago[clangd] Support extraction of binary "subexpressions" like a + [[b + c]].
Sam McCall [Fri, 26 Jul 2019 15:29:52 +0000 (15:29 +0000)]
[clangd] Support extraction of binary "subexpressions" like a + [[b + c]].

Summary:
These aren't formally subexpressions in C++, in this case + is left-associative.
However informally +, *, etc are usually (mathematically) associative and users
consider these subexpressions.

We detect these and in simple cases support extracting the partial expression.
As well as builtin associative operators, we assume that overloads of them
are associative and support those too.

Reviewers: SureYeaah

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 367121

4 years agoFix a bug in std::chrono::abs where it would fail when the duration's period had...
Marshall Clow [Fri, 26 Jul 2019 15:10:46 +0000 (15:10 +0000)]
Fix a bug in std::chrono::abs where it would fail when the duration's period had not been reduced.s

llvm-svn: 367120

4 years ago[ARM] Set default alignment to 64bits
Simi Pallipurath [Fri, 26 Jul 2019 15:05:19 +0000 (15:05 +0000)]
[ARM] Set default alignment to 64bits

The maximum alignment used by ARM arch
is 64bits, not 128.

This could cause overaligned memory
access for 128 bit neon vector that
have unpredictable behaviour.

This fixes: https://bugs.llvm.org/show_bug.cgi?id=42668

Patch by: Diogo Sampaio(diogo.sampaio@arm.com)

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

Change-Id: I5a62b766491f15dd51e4cfe6625929db897f67e3
llvm-svn: 367119

4 years agoRevert r367091, it caused PR42777.
Nico Weber [Fri, 26 Jul 2019 14:58:42 +0000 (14:58 +0000)]
Revert r367091, it caused PR42777.

llvm-svn: 367118

4 years ago[ELF] Detemplate maybeReportUndefined and copySectionsIntoPartitions
Fangrui Song [Fri, 26 Jul 2019 14:57:53 +0000 (14:57 +0000)]
[ELF] Detemplate maybeReportUndefined and copySectionsIntoPartitions

llvm-svn: 367117

4 years ago[OPENMP]Add support for analysis of reduction variables.
Alexey Bataev [Fri, 26 Jul 2019 14:50:05 +0000 (14:50 +0000)]
[OPENMP]Add support for analysis of reduction variables.

Summary:
Reduction variables are the variables, for which the private copies
must be created in the OpenMP regions. Then they are initialized with
the predefined values depending on the reduction operation. After exit
from the OpenMP region the original variable is updated using the
reduction value and the value of the original reduction variable.

Reviewers: NoQ

Subscribers: guansong, jdoerfert, caomhin, kkwli0, cfe-commits

Tags: #clang

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

llvm-svn: 367116

4 years ago[CMake] Loosen Python version check and ignore patch version
Jonas Devlieghere [Fri, 26 Jul 2019 14:26:33 +0000 (14:26 +0000)]
[CMake] Loosen Python version check and ignore patch version

Some versions of macOS report a different patch version for the system
provided interpreter and libraries.

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

llvm-svn: 367115

4 years ago[ARM][ParallelDSP] Combine structs
Sam Parker [Fri, 26 Jul 2019 14:11:40 +0000 (14:11 +0000)]
[ARM][ParallelDSP] Combine structs

Combine OpChain and BinOpChain structs as OpChain is a base class to
BinOpChain that is never used.

llvm-svn: 367114

4 years ago[Clangd] Disable ExtractVariable for all types of assignments
Shaurya Gupta [Fri, 26 Jul 2019 14:08:27 +0000 (14:08 +0000)]
[Clangd] Disable ExtractVariable for all types of assignments

Reviewers: sammccall, kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 367113

4 years ago[clangd] Fix background index not triggering on windows due to case mismatch.
Sam McCall [Fri, 26 Jul 2019 14:07:11 +0000 (14:07 +0000)]
[clangd] Fix background index not triggering on windows due to case mismatch.

Summary:
This isn't a general fix to all paths where we assume case-sensitivity, it's
a minimally-invasive fix targeting the llvm 9 branch.

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

llvm-svn: 367112

4 years ago[PowerPC] Add getCRSaveOffset to improve readability. [NFC]
Sean Fertile [Fri, 26 Jul 2019 14:02:17 +0000 (14:02 +0000)]
[PowerPC] Add getCRSaveOffset to improve readability. [NFC]

In preperation for AIX support in FrameLowering: replace a number of literal
'8' that represent the stack offset of the condition register save area with
a member in PPCFrameLowering.

Patch by Chris Bowler.

llvm-svn: 367111

4 years ago[lldb][NFC] Remove eDiagnosticOriginGo
Raphael Isemann [Fri, 26 Jul 2019 14:00:13 +0000 (14:00 +0000)]
[lldb][NFC] Remove eDiagnosticOriginGo

This enum value is unused as we removed Go support.

llvm-svn: 367110

4 years agogn build: Merge r367043
Nico Weber [Fri, 26 Jul 2019 13:27:19 +0000 (13:27 +0000)]
gn build: Merge r367043

llvm-svn: 367109

4 years agogn build: Merge r366956
Nico Weber [Fri, 26 Jul 2019 13:24:56 +0000 (13:24 +0000)]
gn build: Merge r366956

llvm-svn: 367108

4 years ago[MIPS GlobalISel] Fix check for void return during lowerCall
Petar Avramovic [Fri, 26 Jul 2019 13:19:37 +0000 (13:19 +0000)]
[MIPS GlobalISel] Fix check for void return during lowerCall

Void return used to have unsigned with value 0 for virtual register
but with addition of Register class and changes to arguments to lowerCall
this is no longer valid.
Check for void return by inspecting the Ty field in OrigRet.

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

llvm-svn: 367107

4 years agoDWARF: Improve type safety or range lists parsing
Pavel Labath [Fri, 26 Jul 2019 13:15:28 +0000 (13:15 +0000)]
DWARF: Improve type safety or range lists parsing

Delete the abstract GetOffset function, which is only defined for
rnglists entries. Instead fix up entries which refer to the range list
classes so that one can statically know that he is dealing with the
rnglists section and call the function that way.

llvm-svn: 367106

4 years ago[AMDGPU] Move WQM/WWM intrinsic instruction selection to AMDGPUISelDAGToDAG
Carl Ritson [Fri, 26 Jul 2019 13:11:44 +0000 (13:11 +0000)]
[AMDGPU] Move WQM/WWM intrinsic instruction selection to AMDGPUISelDAGToDAG

Reviewers: arsenm, nhaehnle

Reviewed By: arsenm

Subscribers: kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, t-tye, hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 367105

4 years ago[MIPS GlobalISel] Select inttoptr and ptrtoint
Petar Avramovic [Fri, 26 Jul 2019 13:08:06 +0000 (13:08 +0000)]
[MIPS GlobalISel] Select inttoptr and ptrtoint

Select G_INTTOPTR and G_PTRTOINT for MIPS32.

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

llvm-svn: 367104

4 years agoMake the CXXABIs respect the target's default calling convention.
Erich Keane [Fri, 26 Jul 2019 12:36:12 +0000 (12:36 +0000)]
Make the CXXABIs respect the target's default calling convention.

SPIR targets need to have all functions be SPIR calling convention,
however the CXXABIs were just returning CC_C in all non-'this-CC' cases.

https://reviews.llvm.org/D65294

llvm-svn: 367103

4 years ago[lldb] Don't dynamically allocate the posix option validator.
Raphael Isemann [Fri, 26 Jul 2019 11:46:21 +0000 (11:46 +0000)]
[lldb] Don't dynamically allocate the posix option validator.

We dynamically allocate the option validator which means we
can't mark this list of OptionDefinitions as constexpr. It's also
more complicated than necessary.

llvm-svn: 367102

4 years ago[InstCombine] remove flop from lerp patterns
Sanjay Patel [Fri, 26 Jul 2019 11:19:18 +0000 (11:19 +0000)]
[InstCombine] remove flop from lerp patterns

(Y * (1.0 - Z)) + (X * Z) -->
Y - (Y * Z) + (X * Z) -->
Y + Z * (X - Y)

This is part of solving:
https://bugs.llvm.org/show_bug.cgi?id=42716

Factoring eliminates an instruction, so that should be a good canonicalization.
The potential conversion to FMA would be handled by the backend based on target
capabilities.

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

llvm-svn: 367101

4 years ago[X86][SSE] Replace PMULDQ GetDemandedBits combine with SimplifyMultipleUseDemandedBit...
Simon Pilgrim [Fri, 26 Jul 2019 11:10:20 +0000 (11:10 +0000)]
[X86][SSE] Replace PMULDQ GetDemandedBits combine with SimplifyMultipleUseDemandedBits handler.

This removes a GetDemandedBits user and allows us to benefit from the DemandedElts propagated through SimplifyDemandedBits.

llvm-svn: 367100

4 years ago[NFC][ARM][ParallelDSP] Cleanup isNarrowSequence
Sam Parker [Fri, 26 Jul 2019 10:57:42 +0000 (10:57 +0000)]
[NFC][ARM][ParallelDSP] Cleanup isNarrowSequence

Remove unused logic.

llvm-svn: 367099

4 years ago[SelectionDAG] GetDemandedBits - update SIGN_EXTEND_INREG op to just call SimplifyMul...
Simon Pilgrim [Fri, 26 Jul 2019 10:03:07 +0000 (10:03 +0000)]
[SelectionDAG] GetDemandedBits - update SIGN_EXTEND_INREG op to just call SimplifyMultipleUseDemandedBits.

llvm-svn: 367098

4 years ago[AMDGPU] Add llvm.amdgcn.softwqm intrinsic
Carl Ritson [Fri, 26 Jul 2019 09:54:12 +0000 (09:54 +0000)]
[AMDGPU] Add llvm.amdgcn.softwqm intrinsic

Add llvm.amdgcn.softwqm intrinsic which behaves like llvm.amdgcn.wqm
only if there is other WQM computation in the shader.

Reviewers: nhaehnle, tpr

Reviewed By: nhaehnle

Subscribers: arsenm, kzhuravl, jvesely, wdng, yaxunl, dstuttard, t-tye, llvm-commits

Tags: #llvm

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

llvm-svn: 367097

4 years ago[TargetLowering] SimplifyMultipleUseDemandedBits - add SIGN_EXTEND_INREG support.
Simon Pilgrim [Fri, 26 Jul 2019 09:41:08 +0000 (09:41 +0000)]
[TargetLowering] SimplifyMultipleUseDemandedBits - add SIGN_EXTEND_INREG support.

llvm-svn: 367096

4 years agoFix some "control reaches end of non-void function" warnings
Pavel Labath [Fri, 26 Jul 2019 09:38:23 +0000 (09:38 +0000)]
Fix some "control reaches end of non-void function" warnings

llvm-svn: 367095

4 years ago[ARM][ParallelDSP] Regenerate multi-use-loads.ll test checks
Simon Pilgrim [Fri, 26 Jul 2019 09:32:21 +0000 (09:32 +0000)]
[ARM][ParallelDSP] Regenerate multi-use-loads.ll test checks

llvm-svn: 367094

4 years ago[AArch64] Define ETE and TRBE system registers
Momchil Velikov [Fri, 26 Jul 2019 09:19:08 +0000 (09:19 +0000)]
[AArch64] Define ETE and TRBE system registers

Embedded Trace Extension and Trace Buffer Extension are optional
future architecture extensions.
(cf. https://developer.arm.com/architectures/cpu-architecture/a-profile/exploration-tools)

Their system registers are documented here:
https://developer.arm.com/docs/ddi0601/a

ETE shares register names with ETM. One exception is the ETE
TRCEXTINSELR0 register, which has the same encoding as the ETM
TRCEXTINSELR register (but different semantics). This patch treats
them as aliases: the assembler will accept both names, emitting
identical encoding, and the disassembler will keep disassembling
to TRCEXRINSELR.

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

llvm-svn: 367093

4 years ago[SelectionDAG] GetDemandedBits - update OR/XOR ops to just call SimplifyMultipleUseDe...
Simon Pilgrim [Fri, 26 Jul 2019 09:13:29 +0000 (09:13 +0000)]
[SelectionDAG] GetDemandedBits - update OR/XOR ops to just call SimplifyMultipleUseDemandedBits.

Eventually all of these will be moved over, but we create nodes in GetDemandedBits recursion at the moment which causes regressions when we try to remove them all.

llvm-svn: 367092

4 years ago[TargetLowering] SimplifyMultipleUseDemandedBits - add BITCAST pass through support.
Simon Pilgrim [Fri, 26 Jul 2019 08:38:39 +0000 (08:38 +0000)]
[TargetLowering] SimplifyMultipleUseDemandedBits - add BITCAST pass through support.

This allows us to peek through BITCASTs and attempt simplify the source operand, and then bitcast back.

llvm-svn: 367091

4 years agoObjectFileELF: Use llvm::JamCRC to refactor CRC32 computation
Fangrui Song [Fri, 26 Jul 2019 08:33:36 +0000 (08:33 +0000)]
ObjectFileELF: Use llvm::JamCRC to refactor CRC32 computation

Reviewed By: labath

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

llvm-svn: 367090

4 years ago[ARM][LowOverheadLoops] Add CPSR defs
Sam Parker [Fri, 26 Jul 2019 08:15:01 +0000 (08:15 +0000)]
[ARM][LowOverheadLoops] Add CPSR defs

Both WhileLoopStart and LoopEnd may get turned into a cmp and br pair,
so add an implicit def to these pseudo instructions in case that WLS
and LE aren't generated.

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

llvm-svn: 367089

4 years ago[WinEH] Allocate space in funclets stack to save XMM CSRs
Pengfei Wang [Fri, 26 Jul 2019 07:33:15 +0000 (07:33 +0000)]
[WinEH] Allocate space in funclets stack to save XMM CSRs

Summary:
This is an alternate approach to D57970.
Currently funclets reuse the same stack slots that are used in the
parent function for saving callee-saved xmm registers. If the parent
function modifies a callee-saved xmm register before an excpetion is
thrown, the catch handler will overwrite the original saved value.

This patch allocates space in funclets stack for saving callee-saved xmm
registers and uses RSP instead RBP to access memory.

Reviewers: andrew.w.kaylor, LuoYuanke, annita.zhang, craig.topper,
RKSimon

Subscribers: rnk, hiraditya, llvm-commits

Tags: #llvm

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

Signed-off-by: pengfei <pengfei.wang@intel.com>
llvm-svn: 367088

4 years ago[Loop Utils] Extend the scope of addStringMetadataToLoop.
Serguei Katkov [Fri, 26 Jul 2019 07:04:34 +0000 (07:04 +0000)]
[Loop Utils] Extend the scope of addStringMetadataToLoop.

To avoid duplicates in loop metadata, if the string to add is
already there, just update the value.

Reviewers: reames, Ashutosh
Reviewed By: reames
Subscribers: hiraditya, llvm-commits
Differential Revision: https://reviews.llvm.org/D65265

llvm-svn: 367087

4 years agoSymbolVendor: Move Symtab construction into the SymbolFile
Pavel Labath [Fri, 26 Jul 2019 07:03:28 +0000 (07:03 +0000)]
SymbolVendor: Move Symtab construction into the SymbolFile

Summary:
Instead of having SymbolVendor coordinate Symtab construction between
Symbol and Object files, make the SymbolVendor function a passthrough,
and put all of the logic into the SymbolFile.

Reviewers: clayborg, JDevlieghere, jingham, espindola

Subscribers: emaste, mgorny, arichardson, MaskRay, lldb-commits

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

llvm-svn: 367086

4 years ago[Loop Utils] Move utilty addStringMetadataToLoop to LoopUtils.cpp. NFC.
Serguei Katkov [Fri, 26 Jul 2019 06:10:08 +0000 (06:10 +0000)]
[Loop Utils] Move utilty addStringMetadataToLoop to LoopUtils.cpp. NFC.

Just move the utility function to LoopUtils.cpp to re-use it in loop peeling.

Reviewers: reames, Ashutosh
Reviewed By: reames
Subscribers: hiraditya, asbirlea, llvm-commits
Differential Revision: https://reviews.llvm.org/D65264

llvm-svn: 367085

4 years agoFix macOS build after r358716
Yi Kong [Fri, 26 Jul 2019 05:17:14 +0000 (05:17 +0000)]
Fix macOS build after r358716

COPYFILE_CLONE is only defined on newer macOS versions, using it without
check breaks build on systems running legacy OS and toolchain.

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

llvm-svn: 367084

4 years agoSome case eror for: detected memory leaks
Kang Zhang [Fri, 26 Jul 2019 03:25:58 +0000 (03:25 +0000)]
Some case eror for: detected memory leaks

llvm-svn: 367083

4 years agoAMDGPU/GlobalISel: Handle most function return types
Matt Arsenault [Fri, 26 Jul 2019 02:36:05 +0000 (02:36 +0000)]
AMDGPU/GlobalISel: Handle most function return types

handleAssignments gives up pretty easily on structs, and i8 values for
some reason. The other case that doesn't work is when an implicit sret
needs to be inserted if the return size exceeds the number of return
registers.

llvm-svn: 367082

4 years agoGlobalISel: Fold out unmerge to scalars from concat_vector
Matt Arsenault [Fri, 26 Jul 2019 02:22:23 +0000 (02:22 +0000)]
GlobalISel: Fold out unmerge to scalars from concat_vector

Removes illegal intermediate vectors if an operation was lowering to
concat_vectors, and the next operation is scalarized.

llvm-svn: 367081

4 years ago[PowerPC] Do the Simple Early Return in block-placement pass to optimize the blocks
Kang Zhang [Fri, 26 Jul 2019 01:58:53 +0000 (01:58 +0000)]
[PowerPC] Do the Simple Early Return in block-placement pass to optimize the blocks

Summary:
In `block-placement` pass, it will create some patterns for unconditional we can do the simple early retrun.
But the `early-ret` pass is before `block-placement`, we don't want to run it again.
This patch is to do the simple early return to optimize the blocks at the last of `block-placement`.

Below is an example
```
BB:                   | BB:
   XOR 3, 3, 4        |   XOR 3, 3, 4
   B TBB              |   B ChainBB
...                   | ...
ChainBB:              | ChainBB:
   B TBB              |   ADD 3, 3, 4
...                   |   BLR
TBB:                  |
   ADD 3, 3, 4        |
   BLR                |
```

Reviewed By: efriedma

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

llvm-svn: 367080

4 years ago[dotest] Remove dead code
Jonas Devlieghere [Fri, 26 Jul 2019 01:58:18 +0000 (01:58 +0000)]
[dotest] Remove dead code

Remove some dead code that I ran into when preparing D65311.

llvm-svn: 367079

4 years agoReland: [Remarks] Add support for serializing metadata for every remark streamer
Francis Visoiu Mistrih [Fri, 26 Jul 2019 01:33:30 +0000 (01:33 +0000)]
Reland: [Remarks] Add support for serializing metadata for every remark streamer

This allows every serializer format to implement metaSerializer() and
return the corresponding meta serializer.

Original llvm-svn: 366946
Reverted llvm-svn: 367004

This fixes the unit tests on Windows bots.

llvm-svn: 367078

4 years ago[Tests] Split inferior crashing tests
Jonas Devlieghere [Fri, 26 Jul 2019 01:00:40 +0000 (01:00 +0000)]
[Tests] Split inferior crashing tests

We noticed that TestInferiorCrashing.py and TestRecursiveInferior.py are
the second and third slowest tests in the test suite. Splitting them up
allows lit to schedule them more effectively.

llvm-svn: 367077

4 years agoRevert "[Sema] Diagnose default-initialization, destruction, and copying of"
Akira Hatanaka [Fri, 26 Jul 2019 00:02:17 +0000 (00:02 +0000)]
Revert "[Sema] Diagnose default-initialization, destruction, and copying of"

This reverts commit r365985.

Prior to r365985, clang used to mark C union fields that have
non-trivial ObjC ownership qualifiers as unavailable if the union was
declared in a system header. r365985 stopped doing so, which caused the
swift compiler to crash when it tried to import a non-trivial union.

I have a patch that fixes the crash (https://reviews.llvm.org/D65256),
but I'm temporarily reverting the original patch until we can decide on
whether it's taking the right approach.

llvm-svn: 367076

4 years ago[AArch64][GlobalISel] Simplify zext/sext selection, use MachineIRBuilder. NFC.
Amara Emerson [Fri, 26 Jul 2019 00:01:09 +0000 (00:01 +0000)]
[AArch64][GlobalISel] Simplify zext/sext selection, use MachineIRBuilder. NFC.

llvm-svn: 367075

4 years ago[clang-doc] Fix failing tests on Windows
Diego Astiazaran [Thu, 25 Jul 2019 23:22:55 +0000 (23:22 +0000)]
[clang-doc] Fix failing tests on Windows

Tests on Windows were failing due to path separator differences.
'/' was being used as separator in the expected output, paths in expected output are now changed to their native form before comparing them to the actual output.

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

llvm-svn: 367074

4 years ago[CMake] Add TableGen dependency to lldbInterpreter.
Jonas Devlieghere [Thu, 25 Jul 2019 22:56:59 +0000 (22:56 +0000)]
[CMake] Add TableGen dependency to lldbInterpreter.

lldbInterpreter depends on LLDBPropertiesGen and LLDBPropertiesEnumGen.

llvm-svn: 367073

4 years ago[clang-doc] Add option for user provided stylesheets
Diego Astiazaran [Thu, 25 Jul 2019 22:46:40 +0000 (22:46 +0000)]
[clang-doc] Add option for user provided stylesheets

An option has been added to clang-doc to provide a list of css stylesheets that the user wants to use for the generated html docs.

Depends on D64539.

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

llvm-svn: 367072

4 years ago[clang-tidy] Add a module for the Linux kernel.
Tom Roeder [Thu, 25 Jul 2019 22:32:50 +0000 (22:32 +0000)]
[clang-tidy] Add a module for the Linux kernel.

Summary:
Now that clang is going to be able to build the Linux kernel again on
x86, and we have gen_compile_commands.py upstream for generating
compile_commands.json, clang-tidy can be used on the Linux kernel
source.

To that end, this commit adds a new clang-tidy module to be used for
checks specific to Linux kernel source. The Linux kernel follows its own
style of C, and it will be useful to separate those checks into their
own module.

This also adds an initial check that makes sure that return values from
the kernel error functions like PTR_ERR and ERR_PTR are checked. It also
makes sure that any functions that directly return values from these
functions are checked.

Subscribers: xazax.hun, gribozavr, Eugene.Zelenko, lebedev.ri, mgorny, jdoerfert, cfe-commits

Tags: #clang, #clang-tools-extra

Reviewers: aaron.ballman, alexfh, hokein, JonasToth

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

llvm-svn: 367071

4 years ago[openmp] Workaround bug in old Android pthread_attr_setstacksize
Yi Kong [Thu, 25 Jul 2019 22:29:55 +0000 (22:29 +0000)]
[openmp] Workaround bug in old Android pthread_attr_setstacksize

Round the stack size to a multiple of the page size. Older versions of
Android (until KitKat) would fail pthread_attr_setstacksize with
EINVAL if the stack size was not a multiple of the page size.

Patch by Dan Albert <danalbert@google.com>.

Test: Build, copied into the NDK, passed openmp test on ICS.
Bug: https://github.com/android-ndk/ndk/issues/9
llvm-svn: 367070

4 years ago[InstCombine] add tests for lerp patterns (PR42716); NFC
Sanjay Patel [Thu, 25 Jul 2019 22:25:21 +0000 (22:25 +0000)]
[InstCombine] add tests for lerp patterns (PR42716); NFC

llvm-svn: 367069

4 years ago[CodeGen] Don't resolve the stack protector frame accesses until PEI
Francis Visoiu Mistrih [Thu, 25 Jul 2019 22:23:48 +0000 (22:23 +0000)]
[CodeGen] Don't resolve the stack protector frame accesses until PEI

Currently, stack protector loads and stores are resolved during
LocalStackSlotAllocation (if the pass needs to run). When this is the
case, the base register assigned to the frame access is going to be one
of the vregs created during LocalStackSlotAllocation. This means that we
are keeping a pointer to the stack protector slot, and we're using this
pointer to load and store to it.

In case register pressure goes up, we may end up spilling this pointer
to the stack, which can be a security concern.

Instead, leave it to PEI to resolve the frame accesses. In order to do
that, we make all stack protector accesses go through frame index
operands, then PEI will resolve this using an offset from sp/fp/bp.

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

llvm-svn: 367068

4 years ago[Sema] add -Walloca to flag uses of `alloca`
George Burgess IV [Thu, 25 Jul 2019 22:23:40 +0000 (22:23 +0000)]
[Sema] add -Walloca to flag uses of `alloca`

This CL adds an optional warning to diagnose uses of the
`__builtin_alloca` family of functions. The use of these functions is
discouraged by many, so it seems like a good idea to allow clang to warn
about it.

Patch by Elaina Guan!

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

llvm-svn: 367067

4 years ago[Docs] Remove reproducers from the project page.
Jonas Devlieghere [Thu, 25 Jul 2019 22:22:43 +0000 (22:22 +0000)]
[Docs] Remove reproducers from the project page.

Jim pointed out that this was still open on the website.

llvm-svn: 367066

4 years ago[Tablegen] Fix issues caused by incorrect escaping.
Jonas Devlieghere [Thu, 25 Jul 2019 22:17:08 +0000 (22:17 +0000)]
[Tablegen] Fix issues caused by incorrect escaping.

The printEscapedString would escape newlines by their ASCII values
instead of prefixing them with a `\`. Remove the escaping logic and
escape the strings in the definition file.

llvm-svn: 367065

4 years ago[profile] In Android, do not mkdir() dirs in GCOV_PREFIX
Pirama Arumuga Nainar [Thu, 25 Jul 2019 22:10:56 +0000 (22:10 +0000)]
[profile] In Android, do not mkdir() dirs in GCOV_PREFIX

Summary:
In Android, attempting to mkdir() or even stat() top-level directories
like /data causes noisy selinux denials.  During whole-system coverage
instrumentation, this causes a deluge of noisy messages that drown out
legitimate selinux denials, that should be audited and fixed.

To avoid this, skip creating any directory in GCOV_PREFIX (thereby
assuming that it exists).

- Android platform ensures that the GCOV_PREFIX used in Android is
created and read/writable by all processes.
- This only affects the Android platform (by checking against
__ANDROID_API_FUTURE__) and for apps built with Clang coverage, the
runtime will still create any non-existent parent directories for the
coverage files.

Reviewers: srhines, davidxl

Subscribers: krytarowski, #sanitizers, danalbert, llvm-commits

Tags: #sanitizers, #llvm

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

llvm-svn: 367064

4 years ago[NFC][clang] Refactor getCompilationPhases()+Types.def step 2.
Puyan Lotfi [Thu, 25 Jul 2019 22:05:55 +0000 (22:05 +0000)]
[NFC][clang] Refactor getCompilationPhases()+Types.def step 2.

- Removing a few of the entries in the Flags for the Types.def table.
- Removing redundant parts of getCompilationPhases().

Flags have been removed from Types.def:

 a - The type should only be assembled: Now, check that Phases contains
     phases::Assemble but not phases::Compile or phases::Backend.
 p - The type should only be precompiled: Now, check that Phases contains
     phases::Precompile but that Flags does not contain 'm'.
 m - Precompiling this type produces a module file: Now, check that
     isPrepeocessedModuleType.

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

llvm-svn: 367063

4 years ago[BPF] fix typedef issue for offset relocation
Yonghong Song [Thu, 25 Jul 2019 21:47:27 +0000 (21:47 +0000)]
[BPF] fix typedef issue for offset relocation

Currently, the CO-RE offset relocation does not work
if any struct/union member or array element is a typedef.
For example,
  typedef const int arr_t[7];
  struct input {
      arr_t a;
  };
  func(...) {
       struct input *in = ...;
       ... __builtin_preserve_access_index(&in->a[1]) ...
  }
The BPF backend calculated default offset is 0 while
4 is the correct answer. Similar issues exist for struct/union
typedef's.

When getting struct/union member or array element type,
we should trace down to the type by skipping typedef
and qualifiers const/volatile as this is what clang did
to generate getelementptr instructions.
(const/volatile member type qualifiers are already
ignored by clang.)

This patch fixed this issue, for each access index,
skipping typedef and const/volatile/restrict BTF types.

Signed-off-by: Yonghong Song <yhs@fb.com>
Differential Revision: https://reviews.llvm.org/D65259

llvm-svn: 367062

4 years ago[FileCollector] add support for recording empty directories
Alex Lorenz [Thu, 25 Jul 2019 21:47:11 +0000 (21:47 +0000)]
[FileCollector] add support for recording empty directories

The file collector class is useful for constructing reproducers by
creating a snapshot of the files that are accessed. Sometimes it might
also be important to construct directories that don't necessarily have files,
but are still accessed by some tool that we want to make a reproducer for.
This is useful for instance for modeling the behavior of Clang's header search,
which scans through a number of directories it doesn't actually access when
looking for framework headers. This commit extends the file collector to allow
it to work with paths that are just directories, by constructing them as the
files are copied over.

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

llvm-svn: 367061

4 years ago[AArch64][GlobalISel] Fix G_SELECT legalization fallback after r366943.
Amara Emerson [Thu, 25 Jul 2019 21:44:52 +0000 (21:44 +0000)]
[AArch64][GlobalISel] Fix G_SELECT legalization fallback after r366943.

Changes the order of legalization of G_ICMP suggested by Petar in D65079.

llvm-svn: 367060

4 years agoMention adding predicates to settings in the projects page.
Jim Ingham [Thu, 25 Jul 2019 21:37:57 +0000 (21:37 +0000)]
Mention adding predicates to settings in the projects page.

llvm-svn: 367059

4 years agoLet tablegen generate property definitions
Jonas Devlieghere [Thu, 25 Jul 2019 21:36:37 +0000 (21:36 +0000)]
Let tablegen generate property definitions

Property definitions are currently defined in a PropertyDefinition array
and have a corresponding enum to index in this array. Unfortunately this
is quite error prone. Indeed, just today we found an incorrect merge
where a discrepancy between the order of the enum values and their
definition caused the test suite to fail spectacularly.

Tablegen can streamline the process of generating the property
definition table while at the same time guaranteeing that the enums stay
in sync. That's exactly what this patch does. It adds a new tablegen
file for the properties, building on top of the infrastructure that
Raphael added recently for the command options. It also introduces two
new tablegen backends: one for the property definitions and one for
their corresponding enums.

It might be worth mentioning that I generated most of the tablegen
definitions from the existing property definitions, by adding a dump
method to the struct. This seems both more efficient and less error
prone that copying everything over by hand. Only Enum properties needed
manual fixup for the EnumValues and DefaultEnumValue fields.

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

llvm-svn: 367058

4 years agoRemove a project that was completed.
Jim Ingham [Thu, 25 Jul 2019 21:29:29 +0000 (21:29 +0000)]
Remove a project that was completed.

llvm-svn: 367057

4 years ago[clang-doc] Add stylesheet to generated html docs
Diego Astiazaran [Thu, 25 Jul 2019 21:27:50 +0000 (21:27 +0000)]
[clang-doc] Add stylesheet to generated html docs

A default css stylesheet is included for docs generated in html format.

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

llvm-svn: 367056

4 years agoRevert "Revert "CodeGen: ensure placeholder instruction for cleanup is created""
Saleem Abdulrasool [Thu, 25 Jul 2019 20:59:48 +0000 (20:59 +0000)]
Revert "Revert "CodeGen: ensure placeholder instruction for cleanup is created""

This reverts commit fd1274fa78cb0fd32cc1fa2e6f5bb8e62d29df19.

Add an explicit triple for the test which is pattern matching overly
aggressively.

llvm-svn: 367055

4 years ago[dotest] Set environment variables after potentialy clearing others.
Jonas Devlieghere [Thu, 25 Jul 2019 20:54:41 +0000 (20:54 +0000)]
[dotest] Set environment variables after potentialy clearing others.

Dotest contains code to clear DYLD_LIBRARY_PATH for the inferior to not
propagate sanitized builds. However, it's possible that we want to
inject a different library path with `--inferior-env`. To make that work
correctly, we need to do that *after* clearing DYLD_LIBRARY_PATH.

llvm-svn: 367054

4 years agoReland the "[NewPM] Port Sancov" patch from rL365838. No functional
Leonard Chan [Thu, 25 Jul 2019 20:53:15 +0000 (20:53 +0000)]
Reland the "[NewPM] Port Sancov" patch from rL365838. No functional
changes were made to the patch since then.

--------

[NewPM] Port Sancov

This patch contains a port of SanitizerCoverage to the new pass manager. This one's a bit hefty.

Changes:

- Split SanitizerCoverageModule into 2 SanitizerCoverage for passing over
  functions and ModuleSanitizerCoverage for passing over modules.
- ModuleSanitizerCoverage exists for adding 2 module level calls to initialization
  functions but only if there's a function that was instrumented by sancov.
- Added legacy and new PM wrapper classes that own instances of the 2 new classes.
- Update llvm tests and add clang tests.

llvm-svn: 367053

4 years ago[LLDB] Find debugserver in Command Line Tools as well
Antonio Afonso [Thu, 25 Jul 2019 20:53:00 +0000 (20:53 +0000)]
[LLDB] Find debugserver in Command Line Tools as well

Summary:
This might be an edge case in regular use but if you're shipping an lldb version with no debugserver lldb will try to use the System one.
However, lldb only knows how to find the Xcode one and not the Command Line Tools one. This diff fixes that.

We try to find debugserver with `PlatformDarwin::LocateExecutable("debugserver")`, we call `xcode-select -p` to get the path and then assume this path is of Xcode.

The changes I did are:
* Change `PlatformDarwin::LocateExecutable` to also add the Command Line Tools directory to the list of paths to search for debugserver.
* Created a new function to find the Command Line Tools directory named `GetCommandLineToolsLibraryPath`.
* Refactored the code that calls `xcode-select -p` into its own function `GetXcodeSelectPath()`. There were 2 identical pieces of code for this so I reduced it to one and used this function everywhere instead.
* I also changed `PlatformDarwin::GetSDKDirectoryForModules` to use the `SDKs` directory that exists in the Command Line Tools installation.

I'm not sure how to create tests for this. PlatformDarwinTest is really limited and I couldn't find how to mock Filesystem::Instance() so I could create a virtual file system.

Reviewers: clayborg, JDevlieghere

Reviewed By: clayborg, JDevlieghere

Subscribers: jasonmolenda, lldb-commits

Tags: #lldb

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

llvm-svn: 367052

4 years agoRevert "CodeGen: ensure placeholder instruction for cleanup is created"
JF Bastien [Thu, 25 Jul 2019 20:50:09 +0000 (20:50 +0000)]
Revert "CodeGen: ensure placeholder instruction for cleanup is created"

Originally in https://reviews.llvm.org/D64656

Causes bot failures:

/home/buildslave/buildslave/clang-cmake-armv8-full/llvm/tools/clang/test/CodeGenCXX/pr40771-ctad-with-lambda-copy-capture.cpp:20:16: error: CHECK-NEXT: expected string not found in input
// CHECK-NEXT: call void @_ZN1RC1E1Q(%struct.R* [[TMP_R]])
               ^
<stdin>:37:2: note: scanning from here
 %8 = call %struct.R* @_ZN1RC1E1Q(%struct.R* %1)
 ^
<stdin>:37:2: note: with "TMP_R" equal to "%1"
 %8 = call %struct.R* @_ZN1RC1E1Q(%struct.R* %1)
 ^
<stdin>:37:17: note: possible intended match here
 %8 = call %struct.R* @_ZN1RC1E1Q(%struct.R* %1)
                ^

llvm-svn: 367051

4 years ago[clang-doc] Fix output format of html
Diego Astiazaran [Thu, 25 Jul 2019 20:49:00 +0000 (20:49 +0000)]
[clang-doc] Fix output format of html

The children of a TagNode are rendered in the same line as the parent only if they are all TextNodes.
When children are not inline; two text nodes that are adjacent won't have a new line between them, each tag node is rendered in its own line.

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

llvm-svn: 367050

4 years ago[PredicateInfo] Replace pointer comparisons with deterministic compares.
Florian Hahn [Thu, 25 Jul 2019 20:48:13 +0000 (20:48 +0000)]
[PredicateInfo] Replace pointer comparisons with deterministic compares.

Currently there are a few pointer comparisons in ValueDFS_Compare, which
can cause non-deterministic ordering when materializing values. There
are 2 cases this patch fixes:

1. Order defs before uses used to compare pointers, which guarantees
   defs before uses, but causes non-deterministic ordering between 2
   uses or 2 defs, depending on the allocation order. By converting the
   pointers to booleans, we can circumvent that problem.

2. comparePHIRelated was comparing the basic block pointers of edges,
   which also results in a non-deterministic order and is also not
   really meaningful for ordering. By ordering by their destination DFS
   numbers we guarantee a deterministic order.

For the example below, we can end up with 2 different uselist orderings,
when running `opt -mem2reg -ipsccp` hundreds of times. Because the
non-determinism is caused by allocation ordering, we cannot reproduce it
with ipsccp alone.

    declare i32 @hoge() local_unnamed_addr #0

    define dso_local i32 @ham(i8* %arg, i8* %arg1) #0 {
    bb:
      %tmp = alloca i32
      %tmp2 = alloca i32, align 4
      br label %bb19

    bb4:                                              ; preds = %bb20
      br label %bb6

    bb6:                                              ; preds = %bb4
      %tmp7 = call i32 @hoge()
      store i32 %tmp7, i32* %tmp
      %tmp8 = load i32, i32* %tmp
      %tmp9 = icmp eq i32 %tmp8, 912730082
      %tmp10 = load i32, i32* %tmp
      br i1 %tmp9, label %bb11, label %bb16

    bb11:                                             ; preds = %bb6
      unreachable

    bb13:                                             ; preds = %bb20
      br label %bb14

    bb14:                                             ; preds = %bb13
      %tmp15 = load i32, i32* %tmp
      br label %bb16

    bb16:                                             ; preds = %bb14, %bb6
      %tmp17 = phi i32 [ %tmp10, %bb6 ], [ 0, %bb14 ]
      br label %bb19

    bb18:                                             ; preds = %bb20
      unreachable

    bb19:                                             ; preds = %bb16, %bb
      br label %bb20

    bb20:                                             ; preds = %bb19
      indirectbr i8* null, [label %bb4, label %bb13, label %bb18]
    }

Reviewers: davide, efriedma

Reviewed By: efriedma

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

llvm-svn: 367049

4 years ago[NFC][libcxx] Add comments about making mutex/condition_variable trivial on Apple...
Louis Dionne [Thu, 25 Jul 2019 20:29:20 +0000 (20:29 +0000)]
[NFC][libcxx] Add comments about making mutex/condition_variable trivial on Apple platforms

Leaving some comments behind so that we avoid re-having that discussion
in the future.

llvm-svn: 367048

4 years ago[lldb] [Process/NetBSD] Report stopped process on SIGSTOP
Michal Gorny [Thu, 25 Jul 2019 20:27:40 +0000 (20:27 +0000)]
[lldb] [Process/NetBSD] Report stopped process on SIGSTOP

Mark the process as stopped when SIGSTOP arrives.  This is necessary
for lldb-server to generate correct response to 'process interrupt',
and therefore to prevent the whole stack crashing when process
is stopped.

Thanks to Pavel Labath for the tip.

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

llvm-svn: 367047

4 years ago[NFC][DivRemPairs] Tests with rem in expanded form (PR42673)
Roman Lebedev [Thu, 25 Jul 2019 20:26:34 +0000 (20:26 +0000)]
[NFC][DivRemPairs] Tests with rem in expanded form (PR42673)

As discussed in https://bugs.llvm.org/show_bug.cgi?id=42673
there is a TTI hook hasDivRemOp() that matters here.
While -div-rem-pairs will decompose 'rem' if that hook returns false,
nothing does the opposite transform.

We can't to this in InstCombine, because it does not currently
access TTI, and i'm not sure we should change that.

We can't really do that in DAGCombine since it also currently does not
access TTI.

Therefore only DivRemPairs is left.

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

llvm-svn: 367046

4 years ago[clang-doc] Fix html entities in rendered text
Diego Astiazaran [Thu, 25 Jul 2019 20:14:45 +0000 (20:14 +0000)]
[clang-doc] Fix html entities in rendered text

Replace &, <, >, ", and ' with their corresponding html entities in text rendered
by HTML generator.

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

llvm-svn: 367045

4 years ago[Loop Peeling] Fix idom detection algorithm.
Serguei Katkov [Thu, 25 Jul 2019 19:31:50 +0000 (19:31 +0000)]
[Loop Peeling] Fix idom detection algorithm.

We'd like to determine the idom of exit block after peeling one iteration.
Let Exit is exit block.
Let ExitingSet - is a set of predecessors of Exit block. They are exiting blocks.
Let Latch' and ExitingSet' are copies after a peeling.
We'd like to find an idom'(Exit) - idom of Exit after peeling.
It is an evident that idom'(Exit) will be the nearest common dominator of ExitingSet and ExitingSet'.
idom(Exit) is a nearest common dominator of ExitingSet.
idom(Exit)' is a nearest common dominator of ExitingSet'.
Taking into account that we have a single Latch, Latch' will dominate Header and idom(Exit).
So the idom'(Exit) is nearest common dominator of idom(Exit)' and Latch'.
All these basic blocks are in the same loop, so what we find is
(nearest common dominator of idom(Exit) and Latch)'.

Reviewers: reames, fhahn
Reviewed By: reames
Subscribers: hiraditya, zzheng, llvm-commits
Differential Revision: https://reviews.llvm.org/D65292

llvm-svn: 367044

4 years ago[DDG] DirectedGraph as a base class for various dependence graphs such
Whitney Tsang [Thu, 25 Jul 2019 18:23:22 +0000 (18:23 +0000)]
[DDG] DirectedGraph as a base class for various dependence graphs such
as DDG and PDG.
Summary:
This is an implementation of a directed graph base class with explicit
representation of both nodes and edges. This implementation makes the
edges explicit because we expect to assign various attributes (such as
dependence type, distribution interference weight, etc) to the edges in
the derived classes such as DDG and DIG. The DirectedGraph consists of a
list of DGNode's. Each node consists of a (possibly empty) list of
outgoing edges to other nodes in the graph. A DGEdge contains a
reference to a single target node. Note that nodes do not know about
their incoming edges so the DirectedGraph class provides a function to
find all incoming edges to a given node.

This is the first patch in a series of patches that we are planning to
contribute upstream in order to implement Data Dependence Graph and
Program Dependence Graph.

More information about the proposed design can be found here:
https://ibm.ent.box.com/v/directed-graph-and-ddg
Authored By: bmahjour
Reviewer: Meinersbur, myhsum hfinkel, fhahn, jdoerfert, kbarton
Reviewed By: Meinersbur
Subscribers: mgorny, wuzish, jsji, lebedev.ri, dexonsmith, kristina,
llvm-commits, Whitney, etiotto
Tag: LLVM
Differential Revision: https://reviews.llvm.org/D64088

llvm-svn: 367043

4 years agoCodeGen: ensure placeholder instruction for cleanup is created
Saleem Abdulrasool [Thu, 25 Jul 2019 17:59:29 +0000 (17:59 +0000)]
CodeGen: ensure placeholder instruction for cleanup is created

A placeholder instruction for use in generation of cleanup code for an
initializer list would not be emitted if the base class contained a
non-trivial destructor and the class contains no fields of its own. This
would be the case when using CTAD to deduce the template arguments for a
struct with an overloaded call operator, e.g.

```
template <class... Ts> struct ctad : Ts... {};
template <class... Ts> ctad(Ts...)->ctad<Ts...>;
```

and this class was initialized with a list of lambdas capturing by copy,
e.g.

```
ctad c {[s](short){}, [s](long){}};
```

In a release build the bug would manifest itself as a crash in the SROA
pass, however, in a debug build the following assert in CGCleanup.cpp
would fail:

```
assert(dominatingIP && "no existing variable and no dominating IP!");
```

By ensuring that a placeholder instruction is emitted even if there's no
fields in the class, neither the assert nor the crash is reproducible.

See https://bugs.llvm.org/show_bug.cgi?id=40771

Patch by Ã˜ystein Dale!

llvm-svn: 367042

4 years ago[OpenMP] Fix build of stubs library, NFC.
Jonas Hahnfeld [Thu, 25 Jul 2019 17:51:24 +0000 (17:51 +0000)]
[OpenMP] Fix build of stubs library, NFC.

Both Clang and GCC complained that they cannot initialize a return
object of type 'kmp_proc_bind_t' with an 'int'. While at it, also
fix a warning about missing parentheses thrown by Clang.

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

llvm-svn: 367041

4 years agoAdd lifetime categories attributes
Matthias Gehre [Thu, 25 Jul 2019 17:50:51 +0000 (17:50 +0000)]
Add lifetime categories attributes

Summary:
This is the first part of work announced in
"[RFC] Adding lifetime analysis to clang" [0],
i.e. the addition of the [[gsl::Owner(T)]] and
[[gsl::Pointer(T)]] attributes, which
will enable user-defined types to participate in
the lifetime analysis (which will be part of the
next PR).
The type `T` here is called "DerefType" in the paper,
and denotes the type that an Owner owns and a Pointer
points to. E.g. `std::vector<int>` should be annotated
with `[[gsl::Owner(int)]]` and
a `std::vector<int>::iterator` with `[[gsl::Pointer(int)]]`.

[0] http://lists.llvm.org/pipermail/cfe-dev/2018-November/060355.html

Reviewers: gribozavr

Subscribers: xazax.hun, cfe-commits

Tags: #clang

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

llvm-svn: 367040

4 years agoRemove CallingConvMethodType
Erich Keane [Thu, 25 Jul 2019 17:14:45 +0000 (17:14 +0000)]
Remove CallingConvMethodType

This seems to be an old vestage of a previous implementation of getting
the default calling convention, and everything is now using
CXXABI/ASTContext's getDefaultCallingConvention.  Remove it, since it
isn't doing anything.

llvm-svn: 367039

4 years agoFix cxx_status html for r367027
Erich Keane [Thu, 25 Jul 2019 17:14:37 +0000 (17:14 +0000)]
Fix cxx_status html for r367027

llvm-svn: 367038

4 years ago[SimplifyCFG] avoid crashing after simplifying a switch (PR42737)
Sanjay Patel [Thu, 25 Jul 2019 17:01:12 +0000 (17:01 +0000)]
[SimplifyCFG] avoid crashing after simplifying a switch (PR42737)

Later code in TryToSimplifyUncondBranchFromEmptyBlock() assumes that
we have cleaned up unreachable blocks, but that was not happening
with this switch transform.

llvm-svn: 367037

4 years agoMake GCC happy about attribute location
JF Bastien [Thu, 25 Jul 2019 16:58:15 +0000 (16:58 +0000)]
Make GCC happy about attribute location

It doesn't like function attributes on definitions, only declarations.

llvm-svn: 367036

4 years agoFix unused function from r367031
JF Bastien [Thu, 25 Jul 2019 16:50:10 +0000 (16:50 +0000)]
Fix unused function from r367031

llvm-svn: 367035

4 years ago[NFC][CodeGen][X86][AArch64] div-rem pair reconstruction tests (PR42673)
Roman Lebedev [Thu, 25 Jul 2019 16:39:57 +0000 (16:39 +0000)]
[NFC][CodeGen][X86][AArch64] div-rem pair reconstruction tests (PR42673)

As discussed in https://bugs.llvm.org/show_bug.cgi?id=42673
there is a TTI hook hasDivRemOp() that matters here.
While -div-rem-pairs will decompose 'rem' if that hook returns false,
nothing does the opposite transform.

We can't to this in InstCombine, because it does not currently
access TTI, and i'm not sure we should change that.

We may be able to teach DivRemPairs to do this, but this really is a
per-target perf optimization, and we seem to do the opposite transform
in backend if hasDivRemOp() returned false: https://godbolt.org/z/ttt4HZ
I think it makes sense to be consistent.

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

llvm-svn: 367034

4 years ago[LOOPINFO] Introduce the loop guard API.
Whitney Tsang [Thu, 25 Jul 2019 16:13:18 +0000 (16:13 +0000)]
[LOOPINFO] Introduce the loop guard API.
Summary:
This is the first patch for the loop guard. We introduced
getLoopGuardBranch() and isGuarded().
This currently only works on simplified loop, as it requires a preheader
and a latch to identify the guard.
It will work on loops of the form:
/// GuardBB:
///   br cond1, Preheader, ExitSucc <== GuardBranch
/// Preheader:
///   br Header
/// Header:
///  ...
///   br Latch
/// Latch:
///   br cond2, Header, ExitBlock
/// ExitBlock:
///   br ExitSucc
/// ExitSucc:
Prior discussions leading upto the decision to introduce the loop guard
API: http://lists.llvm.org/pipermail/llvm-dev/2019-May/132607.html
Reviewer: reames, kbarton, hfinkel, jdoerfert, Meinersbur, dmgreen
Reviewed By: reames
Subscribers: wuzish, hiraditya, jsji, llvm-commits, bmahjour, etiotto
Tag: LLVM
Differential Revision: https://reviews.llvm.org/D63885

llvm-svn: 367033

4 years agoAllow prefetching from non-zero address spaces
JF Bastien [Thu, 25 Jul 2019 16:11:57 +0000 (16:11 +0000)]
Allow prefetching from non-zero address spaces

Summary:
This is useful for targets which have prefetch instructions for non-default address spaces.

<rdar://problem/42662136>

Subscribers: nemanjai, javed.absar, hiraditya, kbarton, jkorous, dexonsmith, cfe-commits, llvm-commits, RKSimon, hfinkel, t.p.northover, craig.topper, anemet

Tags: #clang, #llvm

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

llvm-svn: 367032

4 years agoCrashHandler: be careful about crashing while handling
JF Bastien [Thu, 25 Jul 2019 16:07:41 +0000 (16:07 +0000)]
CrashHandler: be careful about crashing while handling

Summary:
Looking at the current Apple-specific code for crash handling it does a few
silly things that I think we should avoid while handling crashes:

  * Try real hard not to allocate.
  * Set the global crash reporter string early so that any crash while
    generating the stack trace will still report some info.
  * Prevent reordering of operations in the current thread.

<rdar://problem/53503334>

Subscribers: hiraditya, jkorous, dexonsmith, llvm-commits, beanz, Bigcheese, thakis, lattner, jordan_rose

Tags: #llvm

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

llvm-svn: 367031

4 years ago[BPF] fix CO-RE incorrect index access string
Yonghong Song [Thu, 25 Jul 2019 16:01:26 +0000 (16:01 +0000)]
[BPF] fix CO-RE incorrect index access string

Currently, we expect the CO-RE offset relocation records
a string encoding the original getelementptr access index,
so kernel bpf loader can decode it correctly.

For example,
  struct s { int a; int b; };
  struct t { int c; int d; };
  #define _(x) (__builtin_preserve_access_index(x))
  int get_value(const void *addr1, const void *addr2);
  int test(struct s *arg1, struct t *arg2) {
    return get_value(_(&arg1->b), _(&arg2->d));
  }

We expect two offset relocations:
  reloc 1: type s, access index 0, 1
  reloc 2: type t, access index 0, 1

Two globals are created to retain access indexes for the
above two relocations with global variable names.
The first global has a name "0:1:". Unfortunately,
the second global has the name "0:1:.1" as the llvm
internals automatically add suffix ".1" to a global
with the same name. Later on, the BPF peels the last
character and record "0:1" and "0:1:." in the
relocation table.

This is not desirable. BPF backend could use the global
variable suffix knowledge to generate correct access str.
This patch rather took an approach not relying on
that knowledge. It generates "s:0:1:" and "t:0:1:" to
avoid global variable suffixes and later on generate
correct index access string "0:1" for both records.

Signed-off-by: Yonghong Song <yhs@fb.com>
Differential Revision: https://reviews.llvm.org/D65258

llvm-svn: 367030