platform/upstream/llvm.git
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

5 years ago[OPENMP]Improve error message for device unsupported types.
Alexey Bataev [Mon, 8 Jul 2019 19:21:54 +0000 (19:21 +0000)]
[OPENMP]Improve error message for device unsupported types.

Provide more data to the user in the error message about unsupported
type for device compilation.

llvm-svn: 365374

5 years agoAMDGPU: Fix stray typing
Matt Arsenault [Mon, 8 Jul 2019 19:05:19 +0000 (19:05 +0000)]
AMDGPU: Fix stray typing

llvm-svn: 365373

5 years agoAMDGPU: Make s34 the FP register
Matt Arsenault [Mon, 8 Jul 2019 19:03:38 +0000 (19:03 +0000)]
AMDGPU: Make s34 the FP register

Make the FP register callee saved.

This is tricky because now the FP needs to be spilled in the prolog
relative to the incoming SP register, rather than the frame register
used throughout the rest of the function. I don't like how this
bypassess the standard mechanism for CSR spills just to get the
correct insert point. I may look for a better solution, since all CSR
VGPRs may also need to have all lanes activated. Another option might
be to make getFrameIndexReference change the base register if the
frame index is a CSR, and then try to figure out the right insertion
point in emitProlog.

If there is a free VGPR lane available for SGPR spilling, try to use
it for the FP. If that would require intrtoducing a new VGPR spill,
try to use a free call clobbered SGPR. Only fallback to introducing a
new VGPR spill as a last resort.

This also doesn't attempt to handle SGPR spilling with scalar stores.

llvm-svn: 365372

5 years agoRevert "Move common functionality from processwindows into processdebugger"
Stella Stamenova [Mon, 8 Jul 2019 18:53:32 +0000 (18:53 +0000)]
Revert "Move common functionality from processwindows into processdebugger"

This reverts commit 9c01eaff6aa3f59d91530f47b85bb470377a7780.

The changes in this commit are causing several of the LLDB tests to hang and/or timeout.

llvm-svn: 365371

5 years agoRegUsageInfoCollector: Don't iterate all regs for every reg class
Matt Arsenault [Mon, 8 Jul 2019 18:48:42 +0000 (18:48 +0000)]
RegUsageInfoCollector: Don't iterate all regs for every reg class

This is extremly slow on AMDGPU, which has a lot of physical register
and a lot of register classes.

determineCalleeSaves, via MachineRegisterInfo::isPhysRegUsed already
added all of the super registers to the saved set.

llvm-svn: 365370

5 years agoAMDGPU: Move DEBUG_TYPE definition below includes
Matt Arsenault [Mon, 8 Jul 2019 18:48:39 +0000 (18:48 +0000)]
AMDGPU: Move DEBUG_TYPE definition below includes

llvm-svn: 365369

5 years ago[OPENMP]Rename loopTripCnt member data to LoopTripCnt, NFC.
Alexey Bataev [Mon, 8 Jul 2019 18:45:48 +0000 (18:45 +0000)]
[OPENMP]Rename loopTripCnt member data to LoopTripCnt, NFC.

Rename variable to follow LLVM coding standard.

llvm-svn: 365368

5 years agoRevert "[TSan] Attempt to fix linker error for Linux on AArch64"
Julian Lettner [Mon, 8 Jul 2019 18:37:36 +0000 (18:37 +0000)]
Revert "[TSan] Attempt to fix linker error for Linux on AArch64"

This reverts commit be4148062b155f3be52e0f6ebcb228f2dc137dcf.

llvm-svn: 365367

5 years agoKeep the order of the basic blocks in the cloned loop as the original
Whitney Tsang [Mon, 8 Jul 2019 18:30:35 +0000 (18:30 +0000)]
Keep the order of the basic blocks in the cloned loop as the original
loop
Summary:
Do the cloning in two steps, first allocate all the new loops, then
clone the basic blocks in the same order as the original loop.
Reviewer: Meinersbur, fhahn, kbarton, hfinkel
Reviewed By: hfinkel
Subscribers: hfinkel, hiraditya, llvm-commits
Tag: https://reviews.llvm.org/D64224
Differential Revision:

llvm-svn: 365366

5 years agoFix issues building libraries as more than one type with Xcode
Chris Bieneman [Mon, 8 Jul 2019 18:29:29 +0000 (18:29 +0000)]
Fix issues building libraries as more than one type with Xcode

Summary:
CMake+Xcode doesn't seem to handle targets that only have object
sources. This patch works around that limitation by adding a dummy
soruce file to any library target that is generated by llvm_add_library
when object libraries are generated.

Object libraries are generated whenever llvm_add_library is passed more
than one library type, which is now the default case for clang static
libraries (which generate STATIC and OBJECT libraries).

Reviewers: zturner, compnerd, joanlluch

Reviewed By: joanlluch

Subscribers: joanlluch, xbolva00, mgorny, llvm-commits

Tags: #llvm

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

llvm-svn: 365365

5 years ago[clangd] Don't insert absolute paths, give up instead.
Sam McCall [Mon, 8 Jul 2019 18:07:46 +0000 (18:07 +0000)]
[clangd] Don't insert absolute paths, give up instead.

Summary: Also implement resolution of paths relative to mainfile without HeaderSearchInfo.

Reviewers: kadircet

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

Tags: #llvm

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

llvm-svn: 365364

5 years ago[SCEV] Fix for PR42397. SCEVExpander wrongly adds nsw to shl instruction.
Denis Bakhvalov [Mon, 8 Jul 2019 18:03:43 +0000 (18:03 +0000)]
[SCEV] Fix for PR42397. SCEVExpander wrongly adds nsw to shl instruction.

Change-Id: I76c9f628c092ae3e6e78ebdaf55cec726e25d692
llvm-svn: 365363

5 years ago[InstCombine] add tests for insert of same splatted scalar; NFC
Sanjay Patel [Mon, 8 Jul 2019 18:03:22 +0000 (18:03 +0000)]
[InstCombine] add tests for insert of same splatted scalar; NFC

llvm-svn: 365362

5 years agoUpdate gn files
Vitaly Buka [Mon, 8 Jul 2019 17:50:22 +0000 (17:50 +0000)]
Update gn files

llvm-svn: 365361

5 years agoRevert "[BPF] add new intrinsics preserve_{array,union,struct}_access_index"
Yonghong Song [Mon, 8 Jul 2019 17:47:43 +0000 (17:47 +0000)]
Revert "[BPF] add new intrinsics preserve_{array,union,struct}_access_index"

This reverts commit r365352.

Test ThinLTO/X86/lazyload_metadata.ll failed. Revert the commit
and at the same time to fix the issue.

llvm-svn: 365360

5 years agoRevert "[libc++] Take 2: Do not cleverly link against libc++abi just because it happe...
Vitaly Buka [Mon, 8 Jul 2019 17:46:23 +0000 (17:46 +0000)]
Revert "[libc++] Take 2: Do not cleverly link against libc++abi just because it happens to be there"

r365326 still breaks bots:
http://lab.llvm.org:8011/builders/netbsd-amd64/builds/20712/steps/ninja%20build%20local/logs/stdio
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/39477/steps/test%20tsan%20in%20debug%20compiler-rt%20build/logs/stdio

And probably others

This reverts commit 945b9ec0693390ef35fe8c6b774495312246b8b6.

llvm-svn: 365359

5 years ago[Host] Fix out-of-line definition on Windows
Jonas Devlieghere [Mon, 8 Jul 2019 17:45:11 +0000 (17:45 +0000)]
[Host] Fix out-of-line definition on Windows

Add missing interface changes after r365295.

llvm-svn: 365358

5 years agoReplace temporary variable matches in test since r363952 causes an
Amy Huang [Mon, 8 Jul 2019 17:35:28 +0000 (17:35 +0000)]
Replace temporary variable matches in test since r363952 causes an
extra temporary variable to be created.

llvm-svn: 365357

5 years ago[clangd] Use -completion-style=bundled by default if signature help is available
Sam McCall [Mon, 8 Jul 2019 17:27:15 +0000 (17:27 +0000)]
[clangd] Use -completion-style=bundled by default if signature help is available

Summary:
I didn't manage to find something nicer than optional<bool>, but at least I
found a sneakier comment.

Reviewers: kadircet

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

Tags: #llvm

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

llvm-svn: 365356

5 years ago[Syntax] Introduce syntax trees
Ilya Biryukov [Mon, 8 Jul 2019 17:25:02 +0000 (17:25 +0000)]
[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

llvm-svn: 365355

5 years agoUpdate gn files
Vitaly Buka [Mon, 8 Jul 2019 17:15:57 +0000 (17:15 +0000)]
Update gn files

llvm-svn: 365354

5 years ago[AMDGPU][MC][DOC] Updated AMD GPU assembler syntax description.
Dmitry Preobrazhensky [Mon, 8 Jul 2019 17:09:09 +0000 (17:09 +0000)]
[AMDGPU][MC][DOC] Updated AMD GPU assembler syntax description.

Corrected a typo.

llvm-svn: 365353

5 years ago[BPF] add new intrinsics preserve_{array,union,struct}_access_index
Yonghong Song [Mon, 8 Jul 2019 17:08:28 +0000 (17:08 +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.

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

llvm-svn: 365352

5 years ago[WebAssembly] tablegen: distinguish float/int immediate operands.
Wouter van Oortmerssen [Mon, 8 Jul 2019 16:58:37 +0000 (16:58 +0000)]
[WebAssembly] tablegen: distinguish float/int immediate operands.

Summary:
Before, they were one category of operands which could cause
crashes in non-sensical combinations, e.g. "f32.const symbol".
Now these are forced to be an error.

Reviewers: dschuff

Subscribers: sbc100, jgravelle-google, aheejin, sunfish, llvm-commits

Tags: #llvm

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

llvm-svn: 365351

5 years agoAMDGPU: Remove mubuf specific PatFrags
Matt Arsenault [Mon, 8 Jul 2019 16:53:53 +0000 (16:53 +0000)]
AMDGPU: Remove mubuf specific PatFrags

These are identical to the *_global PatFrag, and will only create more
work to get the GlobalISel importer to handle them.

llvm-svn: 365350

5 years agoAMDGPU: Move waitcnt intrinsic to instruction definition pattern
Matt Arsenault [Mon, 8 Jul 2019 16:53:48 +0000 (16:53 +0000)]
AMDGPU: Move waitcnt intrinsic to instruction definition pattern

llvm-svn: 365349

5 years ago[llvm\test\Object] - An initial step to cleanup the test cases.
George Rimar [Mon, 8 Jul 2019 16:53:39 +0000 (16:53 +0000)]
[llvm\test\Object] - An initial step to cleanup the test cases.

This patch removes trivial-object-test.elf-i386,
trivial-object-test.elf-x86-64 and trivial-object-test2.elf-x86-64
precompiled objects from test/Object/Inputs folder.

I adjusted the existent test cases to use YAML instead.

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

llvm-svn: 365348