platform/upstream/llvm.git
5 years ago[CodeGen] AccelTable - remove non-constexpr (MSVC) Atom defs
Simon Pilgrim [Tue, 9 Jul 2019 13:07:48 +0000 (13:07 +0000)]
[CodeGen] AccelTable - remove non-constexpr (MSVC) Atom defs

Now that we've dropped VS2015 support (D64326) we can enable the constexpr variables on MSVC builds as VS2017+ correctly handles them

llvm-svn: 365477

5 years ago[mips] Implement sge/sgeu pseudo instructions
Simon Atanasyan [Tue, 9 Jul 2019 12:55:55 +0000 (12:55 +0000)]
[mips] Implement sge/sgeu pseudo instructions

The `sge/sgeu Dst, Src1, Src2/Imm` pseudo instructions set register
`Dst` to 1 if register `Src1` is greater than or equal `Src2/Imm` and
to 0 otherwise.

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

llvm-svn: 365476

5 years ago[mips] Implement sgt/sgtu pseudo instructions with immediate operand
Simon Atanasyan [Tue, 9 Jul 2019 12:55:42 +0000 (12:55 +0000)]
[mips] Implement sgt/sgtu pseudo instructions with immediate operand

The `sgt/sgtu Dst, Src1, Src2/Imm` pseudo instructions set register
`Dst` to 1 if register `Src1` is greater than `Src2/Imm` and to 0 otherwise.

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

llvm-svn: 365475

5 years ago[docs][llvm-objdump] Make some wording improvements/simplifications.
James Henderson [Tue, 9 Jul 2019 12:41:39 +0000 (12:41 +0000)]
[docs][llvm-objdump] Make some wording improvements/simplifications.

llvm-svn: 365474

5 years ago[NFC] [X86] Fix scan-build complaining
Pengfei Wang [Tue, 9 Jul 2019 12:41:12 +0000 (12:41 +0000)]
[NFC] [X86] Fix scan-build complaining

Summary:
Remove unused variable. This fixes bug:
https://bugs.llvm.org/show_bug.cgi?id=42526

Signed-off-by: pengfei <pengfei.wang@intel.com>
Reviewers: RKSimon, xiangzhangllvm, craig.topper

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 365473

5 years agoOpaquePtr: pass type to CreateLoad. NFC.
Tim Northover [Tue, 9 Jul 2019 12:36:36 +0000 (12:36 +0000)]
OpaquePtr: pass type to CreateLoad. NFC.

This is the one place in LLVM itself that used the deprecated API for
CreateLoad, so I just added the type in.

llvm-svn: 365472

5 years ago[ADT] Enable ArrayRef/StringRef is_assignable tests on MSVC
Simon Pilgrim [Tue, 9 Jul 2019 12:20:04 +0000 (12:20 +0000)]
[ADT] Enable ArrayRef/StringRef is_assignable tests on MSVC

Now that we've dropped VS2015 support (D64326) we can enable these static_asserts on MSVC builds as VS2017+ correctly handles them

llvm-svn: 365471

5 years agoOpaquePtr: Update polly's calls to Loads.h API
Tim Northover [Tue, 9 Jul 2019 12:13:31 +0000 (12:13 +0000)]
OpaquePtr: Update polly's calls to Loads.h API

The Loads.h API changed so that a Type parameter is now mandatory in
preparation for pointer types being opaque. Unfortunately I don't build
polly routinely and it still had some uses. This just provides the
(obvious) load type in each case.

llvm-svn: 365470

5 years ago[NFC][AsmPrinter] Fix the formatting for the rL365467
Djordje Todorovic [Tue, 9 Jul 2019 12:06:21 +0000 (12:06 +0000)]
[NFC][AsmPrinter] Fix the formatting for the rL365467

In addition, fix the build failure for the 'unused'
variable. The variable was used inside the 'LLVM_DEBUG()'.

llvm-svn: 365469

5 years agoOpaquePtr: add Type parameter to Loads analysis API.
Tim Northover [Tue, 9 Jul 2019 11:35:35 +0000 (11:35 +0000)]
OpaquePtr: add Type parameter to Loads analysis API.

This makes the functions in Loads.h require a type to be specified
independently of the pointer Value so that when pointers have no structure
other than address-space, it can still do its job.

Most callers had an obvious memory operation handy to provide this type, but a
SROA and ArgumentPromotion were doing more complicated analysis. They get
updated to merge the properties of the various instructions they were
considering.

llvm-svn: 365468

5 years ago[DwarfDebug] Dump call site debug info
Djordje Todorovic [Tue, 9 Jul 2019 11:33:56 +0000 (11:33 +0000)]
[DwarfDebug] Dump call site debug info

Dump the DWARF information about call sites and call site parameters into
debug info sections.

The patch also provides an interface for the interpretation of instructions
that could load values of a call site parameters in order to generate DWARF
about the call site parameters.

([13/13] Introduce the debug entry values.)

Co-authored-by: Ananth Sowda <asowda@cisco.com>
Co-authored-by: Nikola Prica <nikola.prica@rt-rk.com>
Co-authored-by: Ivan Baev <ibaev@cisco.com>
Differential Revision: https://reviews.llvm.org/D60716

llvm-svn: 365467

5 years agoReland r365355: [Syntax] Introduce syntax trees
Ilya Biryukov [Tue, 9 Jul 2019 11:32:13 +0000 (11:32 +0000)]
Reland r365355: [Syntax] Introduce syntax trees

With a fix to a PS4 buildbot crash.

llvm-svn: 365466

5 years agoRevert rL365355 : [Syntax] Introduce syntax trees
Simon Pilgrim [Tue, 9 Jul 2019 11:26:35 +0000 (11:26 +0000)]
Revert rL365355 : [Syntax] Introduce syntax trees

Summary:
A tooling-focused alternative to the AST. This commit focuses on the
memory-management strategy and the structure of the AST.

More to follow later:
  - Operations to mutate the syntax trees and corresponding textual
    replacements.
  - Mapping between clang AST nodes and syntax tree nodes.
  - More node types corresponding to the language constructs.

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: llvm-commits, mgorny, cfe-commits

Tags: #clang, #llvm

Differential Revision: https://reviews.llvm.org/D61637
........
Fixes buildbots which were crashing on SyntaxTests.exe

llvm-svn: 365465

5 years ago[ASTImporter] Added visibility context check for EnumDecl.
Balazs Keri [Tue, 9 Jul 2019 11:08:18 +0000 (11:08 +0000)]
[ASTImporter] Added visibility context check for EnumDecl.

Summary:
ASTImporter makes now difference between enums with same name in different translation
units if these are not visible outside.
("Scoped enums" are not handled yet.)

Reviewers: martong, a.sidorin, shafik, a_sidorin

Reviewed By: a_sidorin

Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits

Tags: #clang

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

llvm-svn: 365464

5 years agoEnhance abseil-faster-strsplit-delimiter to handle other non-printable characters.
Dmitri Gribenko [Tue, 9 Jul 2019 11:04:04 +0000 (11:04 +0000)]
Enhance abseil-faster-strsplit-delimiter to handle other non-printable characters.

Summary:
Currently it fails on cases like '\001'.

Note: Since `StringLiteral::outputString` dumps most nonprintable
characters in octal value, the exact string literal format isn't preserved,
e.g. `"\x01"` becomes `'\001'`.

Reviewers: gribozavr

Reviewed By: gribozavr

Subscribers: lebedev.ri, Eugene.Zelenko, cfe-commits

Tags: #clang

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

Patch by Xiaoyi Zhang.

llvm-svn: 365463

5 years ago[RISCV] Fix RISCVTTIImpl::getIntImmCost for immediates where getMinSignedBits() > 64
Alex Bradbury [Tue, 9 Jul 2019 10:56:18 +0000 (10:56 +0000)]
[RISCV] Fix RISCVTTIImpl::getIntImmCost for immediates where getMinSignedBits() > 64

APInt::getSExtValue will assert if getMinSignedBits() > 64. This can happen,
for instance, if examining an i128. Avoid this assertion by checking
Imm.getMinSignedBits() <= 64 before doing
getTLI()->isLegalAddImmediate(Imm.getSExtValue()). We could directly check
getMinSignedBits() <= 12 but it seems better to reuse the isLegalAddImmediate
helper for this.

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

llvm-svn: 365462

5 years ago[docs][llvm-nm] Improve some wording
James Henderson [Tue, 9 Jul 2019 10:40:50 +0000 (10:40 +0000)]
[docs][llvm-nm] Improve some wording

In particular, the --debug-syms switch really doesn't have anything to
do with debuggers, so I've updated the document accordingly.

llvm-svn: 365461

5 years agoFixed assertion
Shaurya Gupta [Tue, 9 Jul 2019 10:30:18 +0000 (10:30 +0000)]
Fixed assertion

llvm-svn: 365460

5 years ago[CMake] Polish a comment
Stefan Granitz [Tue, 9 Jul 2019 10:29:07 +0000 (10:29 +0000)]
[CMake] Polish a comment

llvm-svn: 365459

5 years ago[CMake] Don't initialize LLVM_INSTALL_TOOLCHAIN_ONLY in Apple-lldb-base cache
Stefan Granitz [Tue, 9 Jul 2019 10:29:00 +0000 (10:29 +0000)]
[CMake] Don't initialize LLVM_INSTALL_TOOLCHAIN_ONLY in Apple-lldb-base cache

llvm-svn: 365458

5 years ago[CMake] Remove old lldb_setup_framework_rpaths_in_tool()
Stefan Granitz [Tue, 9 Jul 2019 10:28:53 +0000 (10:28 +0000)]
[CMake] Remove old lldb_setup_framework_rpaths_in_tool()

llvm-svn: 365457

5 years ago[SelectionDAG] Simplify some calls to getSetCCResultType. NFC
Bjorn Pettersson [Tue, 9 Jul 2019 10:27:51 +0000 (10:27 +0000)]
[SelectionDAG] Simplify some calls to getSetCCResultType. NFC

DAGTypeLegalizer and SelectionDAGLegalize has helper
functions wrapping the call to TLI.getSetCCResultType(...).
Use those helpers in more places.

llvm-svn: 365456

5 years ago[LegalizeTypes] Fix saturation bug for smul.fix.sat
Bjorn Pettersson [Tue, 9 Jul 2019 10:24:50 +0000 (10:24 +0000)]
[LegalizeTypes] Fix saturation bug for smul.fix.sat

Summary:
Make sure we use SETGE instead of SETGT when checking
if the sign bit is zero at SMULFIXSAT expansion.

The faulty expansion occured when doing "expand" of
SMULFIXSAT and the scale was exactly matching the
size of the smaller type. For example doing
  i64 Z = SMULFIXSAT X, Y, 32
and expanding X/Y/Z into using two i32 values.

The problem was that we sometimes did not saturate
to min when overflowing.

Here is an example using Q3.4 numbers:

Consider that we are multiplying X and Y.
  X = 0x80 (-8.0 as Q3.4)
  Y = 0x20 (2.0 as Q3.4)
To avoid loss of precision we do a widening
multiplication, getting a 16 bit result
  Z = 0xF000 (-16.0 as Q7.8)

To detect negative overflow we should check if
the five most significant bits in Z are less than -1.
Assume that we name the 4 most significant bits
as HH and the next 4 bits as HL. Then we can do the
check by examining if
 (HH < -1) or (HH == -1 && "sign bit in HL is zero").

The fault was that we have been doing the check as
 (HH < -1) or (HH == -1 && HL > 0)
instead of
 (HH < -1) or (HH == -1 && HL >= 0).

In our example HH is -1 and HL is 0, so the old
code did not trigger saturation and simply truncated
the result to 0x00 (0.0). With the bugfix we instead
detect that we should saturate to min, and the result
will be set to 0x80 (-8.0).

Reviewers: leonardchan, bevinh

Reviewed By: leonardchan

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 365455

5 years agoRetire VS2015 Support
Simon Pilgrim [Tue, 9 Jul 2019 10:12:37 +0000 (10:12 +0000)]
Retire VS2015 Support

As proposed here: https://lists.llvm.org/pipermail/llvm-dev/2019-June/133147.html

This patch raises the minimum supported version to build LLVM/Clang to Visual Studio 2017.

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

llvm-svn: 365454

5 years agodummy variable extraction on a function scope
Shaurya Gupta [Tue, 9 Jul 2019 10:12:26 +0000 (10:12 +0000)]
dummy variable extraction on a function scope

Summary:
- Added extraction to a dummy variable
- using auto for the dummy variable type for now
- Works on a function scope
- Adding braces to create a compound statement not supported yet
- added unit tests

Reviewers: sammccall, kadircet

Subscribers: mgorny, jkorous, arphaman, cfe-commits

Tags: #clang

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

llvm-svn: 365453

5 years agoRetire VS2015 Support
Simon Pilgrim [Tue, 9 Jul 2019 10:10:48 +0000 (10:10 +0000)]
Retire VS2015 Support

As proposed here: https://lists.llvm.org/pipermail/llvm-dev/2019-June/133147.html

This patch raises the minimum supported version to build LLVM/Clang to Visual Studio 2017.

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

llvm-svn: 365452

5 years ago[docs][llvm-dwarfdump] Make some option descriptions clearer and more precise
James Henderson [Tue, 9 Jul 2019 10:03:12 +0000 (10:03 +0000)]
[docs][llvm-dwarfdump] Make some option descriptions clearer and more precise

Some of the wording in the doc (taken largely from the help text), was a
little imprecise in some cases, so this patch makes it a little more
precise.

Reviewed by: JDevlieghere, probinson

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

llvm-svn: 365451

5 years ago[llvm-profdata] Don't make the output overwrite the input file.
Haojian Wu [Tue, 9 Jul 2019 09:57:45 +0000 (09:57 +0000)]
[llvm-profdata] Don't make the output overwrite the input file.

Some file systems may not allow this behavior, the test fails on our internal
system ("Permission denied").

llvm-svn: 365450

5 years agoFixing @llvm.memcpy not honoring volatile.
Guillaume Chatelet [Tue, 9 Jul 2019 09:53:36 +0000 (09:53 +0000)]
Fixing @llvm.memcpy not honoring volatile.
This is explicitly not addressing target-specific code, or calls to memcpy.

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

Reviewers: courbet

Subscribers: hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 365449

5 years agoRevert r364515 and r364524
Jeremy Morse [Tue, 9 Jul 2019 09:38:03 +0000 (09:38 +0000)]
Revert r364515 and r364524

Jordan reports on llvm-commits a performance regression with r364515,
backing the patch out while it's investigated.

llvm-svn: 365448

5 years ago[NFC][PowerPC] Added a test to show current codegen of MachinePRE
Kai Luo [Tue, 9 Jul 2019 09:12:17 +0000 (09:12 +0000)]
[NFC][PowerPC] Added a test to show current codegen of MachinePRE

llvm-svn: 365447

5 years agoRemove trailing whitespaces in the Language Extensions doc
Sylvestre Ledru [Tue, 9 Jul 2019 08:50:17 +0000 (08:50 +0000)]
Remove trailing whitespaces in the Language Extensions doc

llvm-svn: 365446

5 years agoAdd AlignConsecutiveMacros to the clang release notes
Sylvestre Ledru [Tue, 9 Jul 2019 08:45:55 +0000 (08:45 +0000)]
Add AlignConsecutiveMacros to the clang release notes

llvm-svn: 365445

5 years agoReland "[LiveDebugValues] Emit the debug entry values"
Djordje Todorovic [Tue, 9 Jul 2019 08:36:34 +0000 (08:36 +0000)]
Reland "[LiveDebugValues] Emit the debug entry values"

Emit replacements for clobbered parameters location if the parameter
has unmodified value throughout the funciton. This is basic scenario
where we can use the debug entry values.

([12/13] Introduce the debug entry values.)

Co-authored-by: Ananth Sowda <asowda@cisco.com>
Co-authored-by: Nikola Prica <nikola.prica@rt-rk.com>
Co-authored-by: Ivan Baev <ibaev@cisco.com>
Differential Revision: https://reviews.llvm.org/D58042

llvm-svn: 365444

5 years ago[ELF] Assert sizeof(SymbolUnion) <= 80
Fangrui Song [Tue, 9 Jul 2019 07:12:58 +0000 (07:12 +0000)]
[ELF] Assert sizeof(SymbolUnion) <= 80

Reviewed By: ruiu

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

llvm-svn: 365443

5 years ago[ELF][test] Rename tail-merge-string-align2.s to merge-string-align2.s
Fangrui Song [Tue, 9 Jul 2019 06:10:21 +0000 (06:10 +0000)]
[ELF][test] Rename tail-merge-string-align2.s to merge-string-align2.s

This test was added by D64200/r365139 to check we don't merge
SHF_MERGE|SHF_STRINGS sections with different alignments (that wastes
space and can make MergeTailAlignment::Builder out of sync).

It has nothing to do with tail merge (-O2), so rename it.

llvm-svn: 365442

5 years ago[Loop Peeling] Add support for peeling of loops with multiple exits
Serguei Katkov [Tue, 9 Jul 2019 06:07:25 +0000 (06:07 +0000)]
[Loop Peeling] Add support for peeling of loops with multiple exits

This patch modifies the loop peeling transformation so that
it does not expect that there is only one loop exit from latch.

It modifies only transformation. Update of branch weights remains
only for exit from latch.

The motivation is that in follow-up patch I plan to enable loop peeling for
loops with multiple exits but only if other exits then from latch one goes to
block with call to deopt.

For now this patch is NFC.

Reviewers: reames, mkuper, iajbar, fhahn
Reviewed By: reames, fhahn
Subscribers: zzheng, llvm-commits
Differential Revision: https://reviews.llvm.org/D63921

llvm-svn: 365441

5 years agoPrepare for making SwitchInstProfUpdateWrapper strict
Yevgeny Rouban [Tue, 9 Jul 2019 05:07:28 +0000 (05:07 +0000)]
Prepare for making SwitchInstProfUpdateWrapper strict

This patch removes the test part that relates to the non-strict
behavior of SwitchInstProfUpdateWrapper and changes
the assertion to llvm_unreachable() to allow the check in
release builds.
This patch prepares SwitchInstProfUpdateWrapper to become
strict with one line change. That is need to revert it easily
if any failure will arise.

llvm-svn: 365439

5 years ago[BPF] Preserve debuginfo array/union/struct type/access index
Yonghong Song [Tue, 9 Jul 2019 04:21:50 +0000 (04:21 +0000)]
[BPF] Preserve debuginfo array/union/struct type/access index

For background of BPF CO-RE project, please refer to
  http://vger.kernel.org/bpfconf2019.html
In summary, BPF CO-RE intends to compile bpf programs
adjustable on struct/union layout change so the same
program can run on multiple kernels with adjustment
before loading based on native kernel structures.

In order to do this, we need keep track of GEP(getelementptr)
instruction base and result debuginfo types, so we
can adjust on the host based on kernel BTF info.
Capturing such information as an IR optimization is hard
as various optimization may have tweaked GEP and also
union is replaced by structure it is impossible to track
fieldindex for union member accesses.

Three intrinsic functions, preserve_{array,union,struct}_access_index,
are introducted.
  addr = preserve_array_access_index(base, index, dimension)
  addr = preserve_union_access_index(base, di_index)
  addr = preserve_struct_access_index(base, gep_index, di_index)
here,
  base: the base pointer for the array/union/struct access.
  index: the last access index for array, the same for IR/DebugInfo layout.
  dimension: the array dimension.
  gep_index: the access index based on IR layout.
  di_index: the access index based on user/debuginfo types.

If using these intrinsics blindly, i.e., transforming all GEPs
to these intrinsics and later on reducing them to GEPs, we have
seen up to 7% more instructions generated. To avoid such an overhead,
a clang builtin is proposed:
  base = __builtin_preserve_access_index(base)
such that user wraps to-be-relocated GEPs in this builtin
and preserve_*_access_index intrinsics only apply to
those GEPs. Such a buyin will prevent performance degradation
if people do not use CO-RE, even for programs which use
bpf_probe_read().

For example, for the following example,
  $ cat test.c
  struct sk_buff {
     int i;
     int b1:1;
     int b2:2;
     union {
       struct {
         int o1;
         int o2;
       } o;
       struct {
         char flags;
         char dev_id;
       } dev;
       int netid;
     } u[10];
  };

  static int (*bpf_probe_read)(void *dst, int size, const void *unsafe_ptr)
      = (void *) 4;

  #define _(x) (__builtin_preserve_access_index(x))

  int bpf_prog(struct sk_buff *ctx) {
    char dev_id;
    bpf_probe_read(&dev_id, sizeof(char), _(&ctx->u[5].dev.dev_id));
    return dev_id;
  }
  $ clang -target bpf -O2 -g -emit-llvm -S -mllvm -print-before-all \
    test.c >& log

The generated IR looks like below:
  ...
  define dso_local i32 @bpf_prog(%struct.sk_buff*) #0 !dbg !15 {
    %2 = alloca %struct.sk_buff*, align 8
    %3 = alloca i8, align 1
    store %struct.sk_buff* %0, %struct.sk_buff** %2, align 8, !tbaa !45
    call void @llvm.dbg.declare(metadata %struct.sk_buff** %2, metadata !43, metadata !DIExpression()), !dbg !49
    call void @llvm.lifetime.start.p0i8(i64 1, i8* %3) #4, !dbg !50
    call void @llvm.dbg.declare(metadata i8* %3, metadata !44, metadata !DIExpression()), !dbg !51
    %4 = load i32 (i8*, i32, i8*)*, i32 (i8*, i32, i8*)** @bpf_probe_read, align 8, !dbg !52, !tbaa !45
    %5 = load %struct.sk_buff*, %struct.sk_buff** %2, align 8, !dbg !53, !tbaa !45
    %6 = call [10 x %union.anon]* @llvm.preserve.struct.access.index.p0a10s_union.anons.p0s_struct.sk_buffs(
         %struct.sk_buff* %5, i32 2, i32 3), !dbg !53, !llvm.preserve.access.index !19
    %7 = call %union.anon* @llvm.preserve.array.access.index.p0s_union.anons.p0a10s_union.anons(
         [10 x %union.anon]* %6, i32 1, i32 5), !dbg !53
    %8 = call %union.anon* @llvm.preserve.union.access.index.p0s_union.anons.p0s_union.anons(
         %union.anon* %7, i32 1), !dbg !53, !llvm.preserve.access.index !26
    %9 = bitcast %union.anon* %8 to %struct.anon.0*, !dbg !53
    %10 = call i8* @llvm.preserve.struct.access.index.p0i8.p0s_struct.anon.0s(
         %struct.anon.0* %9, i32 1, i32 1), !dbg !53, !llvm.preserve.access.index !34
    %11 = call i32 %4(i8* %3, i32 1, i8* %10), !dbg !52
    %12 = load i8, i8* %3, align 1, !dbg !54, !tbaa !55
    %13 = sext i8 %12 to i32, !dbg !54
    call void @llvm.lifetime.end.p0i8(i64 1, i8* %3) #4, !dbg !56
    ret i32 %13, !dbg !57
  }

  !19 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "sk_buff", file: !3, line: 1, size: 704, elements: !20)
  !26 = distinct !DICompositeType(tag: DW_TAG_union_type, scope: !19, file: !3, line: 5, size: 64, elements: !27)
  !34 = distinct !DICompositeType(tag: DW_TAG_structure_type, scope: !26, file: !3, line: 10, size: 16, elements: !35)

Note that @llvm.preserve.{struct,union}.access.index calls have metadata llvm.preserve.access.index
attached to instructions to provide struct/union debuginfo type information.

For &ctx->u[5].dev.dev_id,
  . The "%6 = ..." represents struct member "u" with index 2 for IR layout and index 3 for DI layout.
  . The "%7 = ..." represents array subscript "5".
  . The "%8 = ..." represents union member "dev" with index 1 for DI layout.
  . The "%10 = ..." represents struct member "dev_id" with index 1 for both IR and DI layout.

Basically, traversing the use-def chain recursively for the 3rd argument of bpf_probe_read() and
examining all preserve_*_access_index calls, the debuginfo struct/union/array access index
can be achieved.

The intrinsics also contain enough information to regenerate codes for IR layout.
For array and structure intrinsics, the proper GEP can be constructed.
For union intrinsics, replacing all uses of "addr" with "base" should be enough.

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

llvm-svn: 365438

5 years ago[LoopInfo] Update getExitEdges to accept vector of pairs for non const BasicBlock
Serguei Katkov [Tue, 9 Jul 2019 04:20:43 +0000 (04:20 +0000)]
[LoopInfo] Update getExitEdges to accept vector of pairs for non const BasicBlock

D63921 requires getExitEdges fills a vector of Edge pairs where
BasicBlocks are not constant.

The rest Loop API mostly returns non-const BasicBlocks, so to be more consistent with
other Loop API getExitEdges is modified to return non-const BasicBlocks as well.

This is an alternative solution to D64060.

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

llvm-svn: 365437

5 years agoRevert "[BPF] Preserve debuginfo array/union/struct type/access index"
Yonghong Song [Tue, 9 Jul 2019 04:15:12 +0000 (04:15 +0000)]
Revert "[BPF] Preserve debuginfo array/union/struct type/access index"

This reverts commit r365435.

Forgot adding the Differential Revision link. Will add to the
commit message and resubmit.

llvm-svn: 365436

5 years ago[BPF] Preserve debuginfo array/union/struct type/access index
Yonghong Song [Tue, 9 Jul 2019 04:04:21 +0000 (04:04 +0000)]
[BPF] Preserve debuginfo array/union/struct type/access index

For background of BPF CO-RE project, please refer to
  http://vger.kernel.org/bpfconf2019.html
In summary, BPF CO-RE intends to compile bpf programs
adjustable on struct/union layout change so the same
program can run on multiple kernels with adjustment
before loading based on native kernel structures.

In order to do this, we need keep track of GEP(getelementptr)
instruction base and result debuginfo types, so we
can adjust on the host based on kernel BTF info.
Capturing such information as an IR optimization is hard
as various optimization may have tweaked GEP and also
union is replaced by structure it is impossible to track
fieldindex for union member accesses.

Three intrinsic functions, preserve_{array,union,struct}_access_index,
are introducted.
  addr = preserve_array_access_index(base, index, dimension)
  addr = preserve_union_access_index(base, di_index)
  addr = preserve_struct_access_index(base, gep_index, di_index)
here,
  base: the base pointer for the array/union/struct access.
  index: the last access index for array, the same for IR/DebugInfo layout.
  dimension: the array dimension.
  gep_index: the access index based on IR layout.
  di_index: the access index based on user/debuginfo types.

If using these intrinsics blindly, i.e., transforming all GEPs
to these intrinsics and later on reducing them to GEPs, we have
seen up to 7% more instructions generated. To avoid such an overhead,
a clang builtin is proposed:
  base = __builtin_preserve_access_index(base)
such that user wraps to-be-relocated GEPs in this builtin
and preserve_*_access_index intrinsics only apply to
those GEPs. Such a buyin will prevent performance degradation
if people do not use CO-RE, even for programs which use
bpf_probe_read().

For example, for the following example,
  $ cat test.c
  struct sk_buff {
     int i;
     int b1:1;
     int b2:2;
     union {
       struct {
         int o1;
         int o2;
       } o;
       struct {
         char flags;
         char dev_id;
       } dev;
       int netid;
     } u[10];
  };

  static int (*bpf_probe_read)(void *dst, int size, const void *unsafe_ptr)
      = (void *) 4;

  #define _(x) (__builtin_preserve_access_index(x))

  int bpf_prog(struct sk_buff *ctx) {
    char dev_id;
    bpf_probe_read(&dev_id, sizeof(char), _(&ctx->u[5].dev.dev_id));
    return dev_id;
  }
  $ clang -target bpf -O2 -g -emit-llvm -S -mllvm -print-before-all \
    test.c >& log

The generated IR looks like below:
  ...
  define dso_local i32 @bpf_prog(%struct.sk_buff*) #0 !dbg !15 {
    %2 = alloca %struct.sk_buff*, align 8
    %3 = alloca i8, align 1
    store %struct.sk_buff* %0, %struct.sk_buff** %2, align 8, !tbaa !45
    call void @llvm.dbg.declare(metadata %struct.sk_buff** %2, metadata !43, metadata !DIExpression()), !dbg !49
    call void @llvm.lifetime.start.p0i8(i64 1, i8* %3) #4, !dbg !50
    call void @llvm.dbg.declare(metadata i8* %3, metadata !44, metadata !DIExpression()), !dbg !51
    %4 = load i32 (i8*, i32, i8*)*, i32 (i8*, i32, i8*)** @bpf_probe_read, align 8, !dbg !52, !tbaa !45
    %5 = load %struct.sk_buff*, %struct.sk_buff** %2, align 8, !dbg !53, !tbaa !45
    %6 = call [10 x %union.anon]* @llvm.preserve.struct.access.index.p0a10s_union.anons.p0s_struct.sk_buffs(
         %struct.sk_buff* %5, i32 2, i32 3), !dbg !53, !llvm.preserve.access.index !19
    %7 = call %union.anon* @llvm.preserve.array.access.index.p0s_union.anons.p0a10s_union.anons(
         [10 x %union.anon]* %6, i32 1, i32 5), !dbg !53
    %8 = call %union.anon* @llvm.preserve.union.access.index.p0s_union.anons.p0s_union.anons(
         %union.anon* %7, i32 1), !dbg !53, !llvm.preserve.access.index !26
    %9 = bitcast %union.anon* %8 to %struct.anon.0*, !dbg !53
    %10 = call i8* @llvm.preserve.struct.access.index.p0i8.p0s_struct.anon.0s(
         %struct.anon.0* %9, i32 1, i32 1), !dbg !53, !llvm.preserve.access.index !34
    %11 = call i32 %4(i8* %3, i32 1, i8* %10), !dbg !52
    %12 = load i8, i8* %3, align 1, !dbg !54, !tbaa !55
    %13 = sext i8 %12 to i32, !dbg !54
    call void @llvm.lifetime.end.p0i8(i64 1, i8* %3) #4, !dbg !56
    ret i32 %13, !dbg !57
  }

  !19 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "sk_buff", file: !3, line: 1, size: 704, elements: !20)
  !26 = distinct !DICompositeType(tag: DW_TAG_union_type, scope: !19, file: !3, line: 5, size: 64, elements: !27)
  !34 = distinct !DICompositeType(tag: DW_TAG_structure_type, scope: !26, file: !3, line: 10, size: 16, elements: !35)

Note that @llvm.preserve.{struct,union}.access.index calls have metadata llvm.preserve.access.index
attached to instructions to provide struct/union debuginfo type information.

For &ctx->u[5].dev.dev_id,
  . The "%6 = ..." represents struct member "u" with index 2 for IR layout and index 3 for DI layout.
  . The "%7 = ..." represents array subscript "5".
  . The "%8 = ..." represents union member "dev" with index 1 for DI layout.
  . The "%10 = ..." represents struct member "dev_id" with index 1 for both IR and DI layout.

Basically, traversing the use-def chain recursively for the 3rd argument of bpf_probe_read() and
examining all preserve_*_access_index calls, the debuginfo struct/union/array access index
can be achieved.

The intrinsics also contain enough information to regenerate codes for IR layout.
For array and structure intrinsics, the proper GEP can be constructed.
For union intrinsics, replacing all uses of "addr" with "base" should be enough.

Signed-off-by: Yonghong Song <yhs@fb.com>
llvm-svn: 365435

5 years ago[LLD] NFC: Fixed GCC warning in ELF/Arch/RISCV.cpp
Denis Bakhvalov [Tue, 9 Jul 2019 03:56:44 +0000 (03:56 +0000)]
[LLD] NFC: Fixed GCC warning in ELF/Arch/RISCV.cpp

GCC emits warning on this line:
error: enumeral and non-enumeral type in conditional
expression [-Werror=extra]

Change-Id: I04969cc32e27e310968b88ebaa4e1c4894528d74
llvm-svn: 365434

5 years ago[NFC][PowerPC] Fixed unused variable 'NewInstr'.
Kai Luo [Tue, 9 Jul 2019 03:33:04 +0000 (03:33 +0000)]
[NFC][PowerPC] Fixed unused variable 'NewInstr'.

llvm-svn: 365433

5 years ago[AMDGPU] Added td definitions for HW regs
Stanislav Mekhanoshin [Tue, 9 Jul 2019 03:20:33 +0000 (03:20 +0000)]
[AMDGPU] Added td definitions for HW regs

Infrastructure work for future commit. NFC.

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

llvm-svn: 365432

5 years ago[AMDGPU] Always use s_memtime for readcyclecounter
Stanislav Mekhanoshin [Tue, 9 Jul 2019 03:10:18 +0000 (03:10 +0000)]
[AMDGPU] Always use s_memtime for readcyclecounter

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

llvm-svn: 365431

5 years ago[PowerPC][Peephole] Combine extsw and sldi after instruction selection
Kai Luo [Tue, 9 Jul 2019 02:55:08 +0000 (02:55 +0000)]
[PowerPC][Peephole] Combine extsw and sldi after instruction selection

Summary:
`extsw` and `sldi` are supposed to be combined if they are in the same
BB in instruction selection phase. This patch handles the case where
extsw and sldi are not in the same BB.

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

llvm-svn: 365430

5 years ago[PowerPC][NFC] remove redundant function isVFReg().
Chen Zheng [Tue, 9 Jul 2019 02:48:30 +0000 (02:48 +0000)]
[PowerPC][NFC] remove redundant function isVFReg().

llvm-svn: 365429

5 years ago[MachinePipeliner] Fix Phi refers to Phi in same stage in 1st epilogue
Jinsong Ji [Tue, 9 Jul 2019 02:27:35 +0000 (02:27 +0000)]
[MachinePipeliner] Fix Phi refers to Phi in same stage in 1st epilogue

Summary:
This is exposed by functional testing on PowerPC.
In some pipelined loops, Phi refer to phi did not get value defined by
the Phi, hence getting wrong value later.

As the comment mentioned, we should "use the value defined by the Phi,
unless we're generating the firstepilog and the Phi refers to a Phi
 in a different stage.", so Phi refering to same stage Phi should use
the value defined by the Phi here.

Reviewers: bcahoon, hfinkel

Reviewed By: hfinkel

Subscribers: MaskRay, wuzish, nemanjai, hiraditya, llvm-commits

Tags: #llvm

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

llvm-svn: 365428

5 years ago[PowerPC][MachinePipeliner][NFC] Add a testcase for Phi bug.
Jinsong Ji [Tue, 9 Jul 2019 02:27:29 +0000 (02:27 +0000)]
[PowerPC][MachinePipeliner][NFC] Add a testcase for Phi bug.

llvm-svn: 365427

5 years ago[WebAssembly] Make sret parameter work with AddMissingPrototypes
Heejin Ahn [Tue, 9 Jul 2019 02:10:33 +0000 (02:10 +0000)]
[WebAssembly] Make sret parameter work with AddMissingPrototypes

Summary:
Even with functions with `no-prototype` attribute, there can be an
argument `sret` (structure return) attribute, which is an optimization
when a function return type is a struct. Fixes PR42420.

Reviewers: sbc100

Subscribers: dschuff, jgravelle-google, llvm-commits

Tags: #llvm

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

llvm-svn: 365426

5 years ago[LoopPred] Stylistic improvement to recently added NE/EQ normalization [NFC]
Philip Reames [Tue, 9 Jul 2019 02:03:31 +0000 (02:03 +0000)]
[LoopPred] Stylistic improvement to recently added NE/EQ normalization [NFC]

llvm-svn: 365425

5 years ago[sanitizers][windows] FIX: Rtl-Heap Interception and tests
Matthew G McGovern [Tue, 9 Jul 2019 01:55:11 +0000 (01:55 +0000)]
[sanitizers][windows] FIX: Rtl-Heap Interception and tests

   - Adds interceptors for Rtl[Allocate|Free|Size|ReAllocate]Heap
   - Adds unit tests for the new interceptors and expands HeapAlloc
     tests to demonstrate new functionality.
   Reviewed as D62927
   - adds fixes for ~win and x64 tests

> llvm-svn: 365381

llvm-svn: 365424

5 years ago[BPF] add new intrinsics preserve_{array,union,struct}_access_index
Yonghong Song [Tue, 9 Jul 2019 01:51:36 +0000 (01:51 +0000)]
[BPF] add new intrinsics preserve_{array,union,struct}_access_index

For background of BPF CO-RE project, please refer to
  http://vger.kernel.org/bpfconf2019.html
In summary, BPF CO-RE intends to compile bpf programs
adjustable on struct/union layout change so the same
program can run on multiple kernels with adjustment
before loading based on native kernel structures.

In order to do this, we need keep track of GEP(getelementptr)
instruction base and result debuginfo types, so we
can adjust on the host based on kernel BTF info.
Capturing such information as an IR optimization is hard
as various optimization may have tweaked GEP and also
union is replaced by structure it is impossible to track
fieldindex for union member accesses.

Three intrinsic functions, preserve_{array,union,struct}_access_index,
are introducted.
  addr = preserve_array_access_index(base, index, dimension)
  addr = preserve_union_access_index(base, di_index)
  addr = preserve_struct_access_index(base, gep_index, di_index)
here,
  base: the base pointer for the array/union/struct access.
  index: the last access index for array, the same for IR/DebugInfo layout.
  dimension: the array dimension.
  gep_index: the access index based on IR layout.
  di_index: the access index based on user/debuginfo types.

For example, for the following example,
  $ cat test.c
  struct sk_buff {
     int i;
     int b1:1;
     int b2:2;
     union {
       struct {
         int o1;
         int o2;
       } o;
       struct {
         char flags;
         char dev_id;
       } dev;
       int netid;
     } u[10];
  };

  static int (*bpf_probe_read)(void *dst, int size, const void *unsafe_ptr)
      = (void *) 4;

  #define _(x) (__builtin_preserve_access_index(x))

  int bpf_prog(struct sk_buff *ctx) {
    char dev_id;
    bpf_probe_read(&dev_id, sizeof(char), _(&ctx->u[5].dev.dev_id));
    return dev_id;
  }
  $ clang -target bpf -O2 -g -emit-llvm -S -mllvm -print-before-all \
    test.c >& log

The generated IR looks like below:

  ...
  define dso_local i32 @bpf_prog(%struct.sk_buff*) #0 !dbg !15 {
    %2 = alloca %struct.sk_buff*, align 8
    %3 = alloca i8, align 1
    store %struct.sk_buff* %0, %struct.sk_buff** %2, align 8, !tbaa !45
    call void @llvm.dbg.declare(metadata %struct.sk_buff** %2, metadata !43, metadata !DIExpression()), !dbg !49
    call void @llvm.lifetime.start.p0i8(i64 1, i8* %3) #4, !dbg !50
    call void @llvm.dbg.declare(metadata i8* %3, metadata !44, metadata !DIExpression()), !dbg !51
    %4 = load i32 (i8*, i32, i8*)*, i32 (i8*, i32, i8*)** @bpf_probe_read, align 8, !dbg !52, !tbaa !45
    %5 = load %struct.sk_buff*, %struct.sk_buff** %2, align 8, !dbg !53, !tbaa !45
    %6 = call [10 x %union.anon]* @llvm.preserve.struct.access.index.p0a10s_union.anons.p0s_struct.sk_buffs(
         %struct.sk_buff* %5, i32 2, i32 3), !dbg !53, !llvm.preserve.access.index !19
    %7 = call %union.anon* @llvm.preserve.array.access.index.p0s_union.anons.p0a10s_union.anons(
         [10 x %union.anon]* %6, i32 1, i32 5), !dbg !53
    %8 = call %union.anon* @llvm.preserve.union.access.index.p0s_union.anons.p0s_union.anons(
         %union.anon* %7, i32 1), !dbg !53, !llvm.preserve.access.index !26
    %9 = bitcast %union.anon* %8 to %struct.anon.0*, !dbg !53
    %10 = call i8* @llvm.preserve.struct.access.index.p0i8.p0s_struct.anon.0s(
         %struct.anon.0* %9, i32 1, i32 1), !dbg !53, !llvm.preserve.access.index !34
    %11 = call i32 %4(i8* %3, i32 1, i8* %10), !dbg !52
    %12 = load i8, i8* %3, align 1, !dbg !54, !tbaa !55
    %13 = sext i8 %12 to i32, !dbg !54
    call void @llvm.lifetime.end.p0i8(i64 1, i8* %3) #4, !dbg !56
    ret i32 %13, !dbg !57
  }

  !19 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "sk_buff", file: !3, line: 1, size: 704, elements: !20)
  !26 = distinct !DICompositeType(tag: DW_TAG_union_type, scope: !19, file: !3, line: 5, size: 64, elements: !27)
  !34 = distinct !DICompositeType(tag: DW_TAG_structure_type, scope: !26, file: !3, line: 10, size: 16, elements: !35)

Note that @llvm.preserve.{struct,union}.access.index calls have metadata llvm.preserve.access.index
attached to instructions to provide struct/union debuginfo type information.

For &ctx->u[5].dev.dev_id,
  . The "%6 = ..." represents struct member "u" with index 2 for IR layout and index 3 for DI layout.
  . The "%7 = ..." represents array subscript "5".
  . The "%8 = ..." represents union member "dev" with index 1 for DI layout.
  . The "%10 = ..." represents struct member "dev_id" with index 1 for both IR and DI layout.

Basically, traversing the use-def chain recursively for the 3rd argument of bpf_probe_read() and
examining all preserve_*_access_index calls, the debuginfo struct/union/array access index
can be achieved.

The intrinsics also contain enough information to regenerate codes for IR layout.
For array and structure intrinsics, the proper GEP can be constructed.
For union intrinsics, replacing all uses of "addr" with "base" should be enough.

The test case ThinLTO/X86/lazyload_metadata.ll is adjusted to reflect the
new addition of the metadata.

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

llvm-svn: 365423

5 years ago[sanitizers][windows] Rtl-Heap Interception and tests
Matthew G McGovern [Tue, 9 Jul 2019 01:47:08 +0000 (01:47 +0000)]
[sanitizers][windows] Rtl-Heap Interception and tests
   - Adds interceptors for Rtl[Allocate|Free|Size|ReAllocate]Heap
   - Adds unit tests for the new interceptors and expands HeapAlloc
     tests to demonstrate new functionality.
   Reviewed as D62927

llvm-svn: 365422

5 years agoFix ASCII art header
Jonas Devlieghere [Tue, 9 Jul 2019 01:35:34 +0000 (01:35 +0000)]
Fix ASCII art header

llvm-svn: 365421

5 years ago[Windows] Include ErrorHandling.h
Jonas Devlieghere [Tue, 9 Jul 2019 01:35:31 +0000 (01:35 +0000)]
[Windows] Include ErrorHandling.h

Include ErrorHandling.h for mapWindowsError.

llvm-svn: 365420

5 years ago[LoopPred] Extend LFTR normalization to the inverse EQ case
Philip Reames [Tue, 9 Jul 2019 01:27:45 +0000 (01:27 +0000)]
[LoopPred] Extend LFTR normalization to the inverse EQ case

A while back, I added support for NE latches formed by LFTR.  I didn't think that quite through, as LFTR will also produce the inverse EQ form for some loops and I hadn't handled that.  This change just adds handling for that case as well.

llvm-svn: 365419

5 years ago[WebAssembly] Fix a typo in a test file name
Heejin Ahn [Tue, 9 Jul 2019 01:21:04 +0000 (01:21 +0000)]
[WebAssembly] Fix a typo in a test file name

Reviewers: sbc100

Subscribers: dschuff, jgravelle-google, sunfish, llvm-commits

Tags: #llvm

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

llvm-svn: 365418

5 years agoChanging CodeView debug info type record representation in assembly files to make...
Nilanjana Basu [Tue, 9 Jul 2019 01:11:02 +0000 (01:11 +0000)]
Changing CodeView debug info type record representation in assembly files to make it more human-readable & editable & fixing bug introduced in r364987

llvm-svn: 365417

5 years ago[crashlog] Fix a mismatch between bytes and strings.
Davide Italiano [Tue, 9 Jul 2019 01:05:12 +0000 (01:05 +0000)]
[crashlog] Fix a mismatch between bytes and strings.

The functions in read_plist() want bytes as input, not
strings.

<rdar://problem/52600712>

llvm-svn: 365416

5 years ago[TSan] Fix linker error for Linux/AArch64
Julian Lettner [Tue, 9 Jul 2019 00:48:38 +0000 (00:48 +0000)]
[TSan] Fix linker error for Linux/AArch64

llvm-svn: 365415

5 years agoUse `ln -n` to prevent forming a symlink cycle, instead of rm'ing the source
Nico Weber [Tue, 9 Jul 2019 00:36:18 +0000 (00:36 +0000)]
Use `ln -n` to prevent forming a symlink cycle, instead of rm'ing the source

This is a better fix for the problem fixed in r334972.

Also remove the rm'ing of the symlink destination that was there to
clean up the bots -- it's over a year later, bots should be happy now.

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

llvm-svn: 365414

5 years agoLet unaliased Args track which Alias they were created from, and use that in Arg...
Nico Weber [Tue, 9 Jul 2019 00:34:08 +0000 (00:34 +0000)]
Let unaliased Args track which Alias they were created from, and use that in Arg::getAsString() for diagnostics

With this, `clang-cl /source-charset:utf-16 test.cc` now prints `invalid
value 'utf-16' in '/source-charset:utf-16'` instead of `invalid value
'utf-16' in '-finput-charset=utf-16'` before, and several other clang-cl
flags produce much less confusing output as well.

Fixes PR29106.

Since an arg and its alias can have different arg types (joined vs not)
and different values (because of AliasArgs<>), I chose to give the Alias
its own Arg object. For convenience, I just store the alias directly in
the unaliased arg – there aren't many arg objects at runtime, so that
seems ok.

Finally, I changed Arg::getAsString() to use the alias's representation
if it's present – that function was already documented as being the
suitable function for diagnostics, and most callers already used it for
diagnostics.

Implementation-wise, Arg::accept() previously used to parse things as
the unaliased option. The core of that switch is now extracted into a
new function acceptInternal() which parses as the _aliased_ option, and
the previously-intermingled unaliasing is now done as an explicit step
afterwards.

(This also changes one place in lld that didn't use getAsString() for
diagnostics, so that that one place now also prints the flag as the user
wrote it, not as it looks after it went through unaliasing.)

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

llvm-svn: 365413

5 years ago[X86][PPC] Support -mlong-double-64
Fangrui Song [Tue, 9 Jul 2019 00:27:43 +0000 (00:27 +0000)]
[X86][PPC] Support -mlong-double-64

-mlong-double-64 is supported on some ports of gcc (i386, x86_64, and ppc{32,64}).
On many other targets, there will be an error:

    error: unrecognized command line option '-mlong-double-64'

This patch makes the driver option -mlong-double-64 available for x86
and ppc. The CC1 option -mlong-double-64 is available on all targets for
users to test on unsupported targets.

LongDoubleSize is added as a VALUE_LANGOPT so that the option can be
shared with -mlong-double-128 when we support it in clang.

Also, make powerpc*-linux-musl default to use 64-bit long double. It is
currently the only supported ABI on musl and is also how people
configure powerpc*-linux-musl-gcc.

Reviewed By: rnk

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

llvm-svn: 365412

5 years agoclang-cl: Port cl.exe's C4659 to clang-cl
Nico Weber [Tue, 9 Jul 2019 00:02:23 +0000 (00:02 +0000)]
clang-cl: Port cl.exe's C4659 to clang-cl

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

llvm-svn: 365411

5 years ago[analyzer] exploded-graph-rewriter: Implement a topology-only mode.
Artem Dergachev [Mon, 8 Jul 2019 23:54:14 +0000 (23:54 +0000)]
[analyzer] exploded-graph-rewriter: Implement a topology-only mode.

In this mode the rewriter will only rewrite program points
and omit program states. Useful for understanding
the rough topology of the graph.

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

llvm-svn: 365410

5 years ago[analyzer] exploded-graph-rewriter: Implement a single-path mode.
Artem Dergachev [Mon, 8 Jul 2019 23:54:11 +0000 (23:54 +0000)]
[analyzer] exploded-graph-rewriter: Implement a single-path mode.

Instead of rewriting the whole graph, rewrite the leftmost path in the
graph. Useful for trimmed graphs that are still too large to display due
to multiple equivalent reports mixed into them.

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

llvm-svn: 365409

5 years ago[ObjC] Add a -Wtautological-compare warning for BOOL
Erik Pilkington [Mon, 8 Jul 2019 23:42:52 +0000 (23:42 +0000)]
[ObjC] Add a -Wtautological-compare warning for BOOL

On macOS, BOOL is a typedef for signed char, but it should never hold a value
that isn't 1 or 0. Any code that expects a different value in their BOOL should
be fixed.

rdar://51954400

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

llvm-svn: 365408

5 years ago[Attributor] Deduce the "returned" argument attribute
Johannes Doerfert [Mon, 8 Jul 2019 23:27:20 +0000 (23:27 +0000)]
[Attributor] Deduce the "returned" argument attribute

Deduce the "returned" argument attribute by collecting all potentially
returned values.

Not only the unique return value, if any, can be used by subsequent
attributes but also the set of all potentially returned values as well
as the mapping from returned values to return instructions that they
originate from (see AAReturnedValues::checkForallReturnedValues).

Change in statistics (-stats) for LLVM-TS + Spec2006, totaling ~19% more "returned" arguments.

  ADDED: attributor                   NumAttributesManifested                  n/a ->        637
  ADDED: attributor                   NumAttributesValidFixpoint               n/a ->      25545
  ADDED: attributor                   NumFnArgumentReturned                    n/a ->        637
  ADDED: attributor                   NumFnKnownReturns                        n/a ->      25545
  ADDED: attributor                   NumFnUniqueReturned                      n/a ->      14118
CHANGED: deadargelim                  NumRetValsEliminated                     470 ->        449 (    -4.468%)
REMOVED: functionattrs                NumReturned                              535 ->        n/a
CHANGED: indvars                      NumElimIdentity                          138 ->        164 (   +18.841%)

Reviewers: homerdin, hfinkel, fedor.sergeev, sanjoy, spatel, nlopes, nicholas, reames, efriedma, chandlerc

Subscribers: hiraditya, bollu, cfe-commits, llvm-commits

Tags: #clang, #llvm

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

llvm-svn: 365407

5 years ago[cxx2a] P0624R2 fix: only lambdas with no lambda-capture are default-constructible...
David Blaikie [Mon, 8 Jul 2019 23:24:41 +0000 (23:24 +0000)]
[cxx2a] P0624R2 fix: only lambdas with no lambda-capture are default-constructible and assignable.

This is a fix for rG864949 which only disabled default construction and
assignment for lambdas with capture-defaults, where the C++2a draft
disables them for lambdas with any lambda-capture at all.

Patch by Logan Smith!

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

llvm-svn: 365406

5 years ago[Frontend] Explicitly include Bitstream/BitCodes.h and BitstreamWriter.h
Francis Visoiu Mistrih [Mon, 8 Jul 2019 23:02:50 +0000 (23:02 +0000)]
[Frontend] Explicitly include Bitstream/BitCodes.h and BitstreamWriter.h

This fixes a modules issue:

error: declaration of 'bitc' must be imported from module
'Clang_Serialization.ASTBitCodes' before it is required
Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID, Record);

llvm-svn: 365405

5 years ago[AArch64][GlobalISel] Use TST for comparisons when possible
Jessica Paquette [Mon, 8 Jul 2019 22:58:36 +0000 (22:58 +0000)]
[AArch64][GlobalISel] Use TST for comparisons when possible

Porting over the part of `emitComparison` in AArch64ISelLowering where we use
TST to represent a compare.

- Rename `tryOptCMN` to `tryFoldIntegerCompare`, since it now also emits TSTs
  when possible.

- Add a utility function for emitting a TST with register operands.

- Rename opt-fold-cmn.mir to opt-fold-compare.mir, since it now also tests the
  TST fold as well.

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

llvm-svn: 365404

5 years ago[ThreadLauncher] Use mapWindowsError and LLDB_INVALID_HOST_THREAD
Jonas Devlieghere [Mon, 8 Jul 2019 22:45:59 +0000 (22:45 +0000)]
[ThreadLauncher] Use mapWindowsError and LLDB_INVALID_HOST_THREAD

Address post-commit feedback from Pavel and Jim.

llvm-svn: 365403

5 years agoFix line endings. NFC
Paul Robinson [Mon, 8 Jul 2019 22:35:30 +0000 (22:35 +0000)]
Fix line endings. NFC

llvm-svn: 365402

5 years ago[llvm-profdata] Fix buildbot failure on llvm-clang-x86_64-expensive-checks-win
Rong Xu [Mon, 8 Jul 2019 22:17:55 +0000 (22:17 +0000)]
[llvm-profdata] Fix buildbot failure on llvm-clang-x86_64-expensive-checks-win

This fixes buildbot failure in LLVM on llvm-clang-x86_64-expensive-checks-win
from r365386.

llvm-svn: 365401

5 years ago[lldb, windows] When StartMonitoring fails, return a proper error
Stella Stamenova [Mon, 8 Jul 2019 22:09:08 +0000 (22:09 +0000)]
[lldb, windows] When StartMonitoring fails, return a proper error

This is possible now that the function returns an llvm::Expected

llvm-svn: 365400

5 years ago[Sanitizers] Remove clang_rt.sancov_{begin,end} on Solaris
Rainer Orth [Mon, 8 Jul 2019 22:08:33 +0000 (22:08 +0000)]
[Sanitizers] Remove clang_rt.sancov_{begin,end} on Solaris

There's no point to manually create the __start___sancov_guards and __stop___sancov_guards
sections and labels on Solaris any longer.  They were originally introduced in
https://reviews.llvm.org/D40899 and https://reviews.llvm.org/D40903.

- The Solaris 11.4 ld supports creating them out of the box.
- We already unconditionally use Solaris 11.4 features like the ld -z gnu-version-script-compat option and fully working .preinit_array support in compiler-rt.
- The current files don't assemble on SPARC because the assembler syntax may be different between /bin/as and GNU as.

Tested on amd64-pc-solaris2.11.

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

llvm-svn: 365399

5 years agoAMDGPU: Split extload/zextload local load patterns
Matt Arsenault [Mon, 8 Jul 2019 22:08:23 +0000 (22:08 +0000)]
AMDGPU: Split extload/zextload local load patterns

This will help removing the custom load predicates, allowing the
global isel emitter to handle them.

llvm-svn: 365398

5 years agoAdd parentheses to silence warnings.
Bill Wendling [Mon, 8 Jul 2019 22:05:02 +0000 (22:05 +0000)]
Add parentheses to silence warnings.

llvm-svn: 365397

5 years ago[Sanitizers] Don't use clang_rt.sancov_{begin,end} on Solaris
Rainer Orth [Mon, 8 Jul 2019 22:04:25 +0000 (22:04 +0000)]
[Sanitizers] Don't use clang_rt.sancov_{begin,end} on Solaris

As explained in https://reviews.llvm.org/D63601, there's no point using clang_rt.sancov_{begin,end}
on Solaris any longer.

This companion patch to the above removes their use from the driver.

Tested on amd64-pc-solaris2.11

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

llvm-svn: 365396

5 years agoAdd parentheses to silence warnings.
Bill Wendling [Mon, 8 Jul 2019 22:01:07 +0000 (22:01 +0000)]
Add parentheses to silence warnings.

llvm-svn: 365395

5 years agoAdd parentheses to silence warning.
Bill Wendling [Mon, 8 Jul 2019 22:00:33 +0000 (22:00 +0000)]
Add parentheses to silence warning.

llvm-svn: 365394

5 years agoRevert [Sema] Resolve placeholder types before type deduction to silence spurious...
Reid Kleckner [Mon, 8 Jul 2019 21:59:07 +0000 (21:59 +0000)]
Revert [Sema] Resolve placeholder types before type deduction to silence spurious `-Warc-repeated-use-of-weak` warnings

This reverts r365382 (git commit 8b1becf2e31d9170ee356a19c7b6ea991d3a520f)

Appears to regress this semi-reduced fragment of valid code from windows
SDK headers:

  #define InterlockedIncrement64 _InterlockedIncrement64
  extern "C" __int64 InterlockedIncrement64(__int64 volatile *Addend);
  #pragma intrinsic(_InterlockedIncrement64)
  unsigned __int64 InterlockedIncrement(unsigned __int64 volatile *Addend) {
    return (unsigned __int64)(InterlockedIncrement64)((volatile __int64 *)Addend);
  }

Found on a buildbot here, but no mail was sent due to it already being
red:
http://lab.llvm.org:8011/builders/sanitizer-windows/builds/48067

llvm-svn: 365393

5 years agoRemove install-headers
Jonas Devlieghere [Mon, 8 Jul 2019 21:53:22 +0000 (21:53 +0000)]
Remove install-headers

After discussing this internally, it is my understanding this was used
for building LLDB internally at Apple, and is no longer used or
necessary.

llvm-svn: 365392

5 years agoRemove lldb-perf
Jonas Devlieghere [Mon, 8 Jul 2019 21:38:34 +0000 (21:38 +0000)]
Remove lldb-perf

As discussed offline, this tool is no longer used or maintained, and
doesn't provide the right abstraction for performance tracking in lldb.

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

llvm-svn: 365391

5 years ago[Windows] Convert GetLastError to std::error_code
Jonas Devlieghere [Mon, 8 Jul 2019 21:19:02 +0000 (21:19 +0000)]
[Windows] Convert GetLastError to std::error_code

Create a std::error_code from the result of GetLastError, which in turn
we can use to return an llvm::Error.

llvm-svn: 365390

5 years ago[lldb] Fix two more issues in Windows following rL365226: Change LaunchThread interfa...
Stella Stamenova [Mon, 8 Jul 2019 21:17:58 +0000 (21:17 +0000)]
[lldb] Fix two more issues in Windows following rL365226: Change LaunchThread interface to return an expected

A couple of the function signatures changed and they were not updated in the Windows HostProcess

llvm-svn: 365388

5 years agoStandardize on MSVC behavior for triples with no environment
Reid Kleckner [Mon, 8 Jul 2019 21:05:20 +0000 (21:05 +0000)]
Standardize on MSVC behavior for triples with no environment

Summary:
This makes it so that IR files using triples without an environment work
out of the box, without normalizing them.

Typically, the MSVC behavior is more desirable. For example, it tends to
enable things like constant merging, use of associative comdats, etc.

Addresses PR42491

Reviewers: compnerd

Subscribers: hiraditya, dexonsmith, llvm-commits

Tags: #llvm

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

llvm-svn: 365387

5 years agollvm-profdata] Handle the cases of overlapping input file and output file
Rong Xu [Mon, 8 Jul 2019 21:03:12 +0000 (21:03 +0000)]
llvm-profdata] Handle the cases of overlapping input file and output file

Currently llvm-profdata does not expect the same file name for the input profile
and the output profile.
>llvm-profdata merge A.profraw B.profraw -o B.profraw
The above command runs successfully but the resulted B.profraw is not correct.
This patch fixes the issue by moving the initialization of writer after loading
the profile.

For the show command, the following will report a confusing error of
"Empty raw profile file":
>llvm-profdata show B.profraw -o B.profraw
It's harder to fix as we need to output something before loading the input profile.
I don't think that a fix for this is worth the effort. I just make the error explicit for
the show command.

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

llvm-svn: 365386

5 years agoRevert "[sanitizers][windows] Rtl-Heap Interception and tests"
JF Bastien [Mon, 8 Jul 2019 20:21:09 +0000 (20:21 +0000)]
Revert "[sanitizers][windows] Rtl-Heap Interception and tests"

Causes build failure on clang-ppc64be-linux-lnt:

compiler-rt/lib/asan/asan_malloc_win.cc:23:2: error: #error "Missing arch or unsupported platform for Windows."
 #error "Missing arch or unsupported platform for Windows."
  ^~~~~
compiler-rt/lib/asan/asan_malloc_win.cc:25:10: fatal error: heapapi.h: No such file or directory
 #include <heapapi.h>
          ^~~~~~~~~~~
compilation terminated.
[39/1151] Building CXX object projects/compiler-rt/lib/asan/CMakeFiles/RTAsan.powerpc64.dir/asan_debugging.cc.o
[40/1151] Building CXX object projects/compiler-rt/lib/asan/CMakeFiles/RTAsan.powerpc64.dir/asan_malloc_win.cc.o
FAILED: projects/compiler-rt/lib/asan/CMakeFiles/RTAsan.powerpc64.dir/asan_malloc_win.cc.o
/usr/bin/c++  -D_DEBUG -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -Iprojects/compiler-rt/lib/asan -Icompiler-rt/lib/asan -Iinclude -I/home/buildbots/ppc64be-clang-lnt-test/clang-ppc64be-lnt/llvm/include -Icompiler-rt/lib/asan/.. -fPIC -fvisibility-inlines-hidden -Werror=date-time -std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough -Wno-maybe-uninitialized -Wno-noexcept-type -Wdelete-non-virtual-dtor -Wno-comment -fdiagnostics-color -ffunction-sections -fdata-sections -Wall -std=c++11 -Wno-unused-parameter -O2    -UNDEBUG  -m64 -fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables -fno-stack-protector -fvisibility=hidden -fno-lto -O3 -g -Wno-variadic-macros -Wno-non-virtual-dtor -fno-rtti -MD -MT projects/compiler-rt/lib/asan/CMakeFiles/RTAsan.powerpc64.dir/asan_malloc_win.cc.o -MF projects/compiler-rt/lib/asan/CMakeFiles/RTAsan.powerpc64.dir/asan_malloc_win.cc.o.d -o projects/compiler-rt/lib/asan/CMakeFiles/RTAsan.powerpc64.dir/asan_malloc_win.cc.o -c compiler-rt/lib/asan/asan_malloc_win.cc
compiler-rt/lib/asan/asan_malloc_win.cc:23:2: error: #error "Missing arch or unsupported platform for Windows."
 #error "Missing arch or unsupported platform for Windows."
  ^~~~~
compiler-rt/lib/asan/asan_malloc_win.cc:25:10: fatal error: heapapi.h: No such file or directory
 #include <heapapi.h>
          ^~~~~~~~~~~

llvm-svn: 365384

5 years agoRevert "Reapply [llvm-ar][test] Increase llvm-ar test coverage"
JF Bastien [Mon, 8 Jul 2019 20:06:36 +0000 (20:06 +0000)]
Revert "Reapply [llvm-ar][test] Increase llvm-ar test coverage"

llvm-ar.extract.test has been failing on greendragon and gone unfixed.

llvm-svn: 365383

5 years ago[Sema] Resolve placeholder types before type deduction to silence
Akira Hatanaka [Mon, 8 Jul 2019 20:04:39 +0000 (20:04 +0000)]
[Sema] Resolve placeholder types before type deduction to silence
spurious `-Warc-repeated-use-of-weak` warnings

The spurious -Warc-repeated-use-of-weak warnings are issued when an
initializer expression uses a weak ObjC pointer.

My first attempt to silence the warnings (r350917) caused clang to
reject code that is legal in C++17. The patch is based on the feedback I
received from Richard when the patch was reverted.

http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20190422/268945.html
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20190422/268943.html

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

llvm-svn: 365382

5 years ago[sanitizers][windows] Rtl-Heap Interception and tests
Matthew G McGovern [Mon, 8 Jul 2019 19:58:50 +0000 (19:58 +0000)]
[sanitizers][windows] Rtl-Heap Interception and tests
   - Adds interceptors for Rtl[Allocate|Free|Size|ReAllocate]Heap
   - Adds unit tests for the new interceptors and expands HeapAlloc
     tests to demonstrate new functionality.
   Reviewed as D62927

llvm-svn: 365381

5 years agoA test commit following 'Obtaining Commit Access' (https://llvm.org/docs/DeveloperPol...
Jian Cai [Mon, 8 Jul 2019 19:53:22 +0000 (19:53 +0000)]
A test commit following 'Obtaining Commit Access' (https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access)

llvm-svn: 365380

5 years ago[InstCombine] fold insertelement into splat of same scalar
Sanjay Patel [Mon, 8 Jul 2019 19:48:52 +0000 (19:48 +0000)]
[InstCombine] fold insertelement into splat of same scalar

Forming the canonical splat shuffle improves analysis and
may allow follow-on transforms (although some possibilities
are missing as shown in the test diffs).

The backend generically turns these patterns into build_vector,
so there should be no codegen regressions. All targets are
expected to be able to lower splats efficiently.

llvm-svn: 365379

5 years agoAMDGPU: Fix unused variable in release build
Matt Arsenault [Mon, 8 Jul 2019 19:47:42 +0000 (19:47 +0000)]
AMDGPU: Fix unused variable in release build

llvm-svn: 365378

5 years agoAdd missing declarations of explicit member specializations.
Richard Smith [Mon, 8 Jul 2019 19:45:46 +0000 (19:45 +0000)]
Add missing declarations of explicit member specializations.

This should fix the build under -Wundefined-func-template and certain
versions of GCC.

llvm-svn: 365377

5 years agoTeach the symbolizer lib symbolize objects directly.
Yuanfang Chen [Mon, 8 Jul 2019 19:28:57 +0000 (19:28 +0000)]
Teach the symbolizer lib symbolize objects directly.

Currently, the symbolizer lib can only symbolize a file on disk.
This patch teaches the symbolizer lib to symbolize objects.
llvm-objdump needs this to support archive disassembly with source info.

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

Reviewed by: jhenderson, grimar, MaskRay

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

llvm-svn: 365376

5 years agoRevert "[TSan] Attempt to fix iOS on-device test"
Julian Lettner [Mon, 8 Jul 2019 19:26:21 +0000 (19:26 +0000)]
Revert "[TSan] Attempt to fix iOS on-device test"

This reverts commit a2ca358291a3a621bfae66eeb01f51eeb69d2dd4.

llvm-svn: 365375