platform/upstream/llvm.git
6 years ago[InstCombine] Rewrite the binary op shrinking in visitFPTrunc to avoid creating overl...
Craig Topper [Fri, 2 Mar 2018 21:25:18 +0000 (21:25 +0000)]
[InstCombine] Rewrite the binary op shrinking in visitFPTrunc to avoid creating overly small ConstantFPs that we'll just need to extend again.

Instead of returning the smaller FP constant we now return the minimal Type the constant can fit into. We also return the Type of the input to any fp extends. The legality checks are then done on just the size of these Types. If we find something profitable we then emit FPTruncs in front of the smaller binop and assume those FPTruncs will be constant folded or combined with any ConstantFPs or fpextends.

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

llvm-svn: 326617

6 years ago[SystemZ] Fix test cases after r326613
Ulrich Weigand [Fri, 2 Mar 2018 21:22:42 +0000 (21:22 +0000)]
[SystemZ] Fix test cases after r326613

I forgot to check in the updated test cases after the r326613 commit.

llvm-svn: 326616

6 years ago[WebAssembly] Simplify createDefined. NFC.
Rui Ueyama [Fri, 2 Mar 2018 21:19:55 +0000 (21:19 +0000)]
[WebAssembly] Simplify createDefined. NFC.

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

llvm-svn: 326615

6 years agoReland "[WebAssembly] More uses of uint8_t for single byte values"
Heejin Ahn [Fri, 2 Mar 2018 20:52:59 +0000 (20:52 +0000)]
Reland "[WebAssembly] More uses of uint8_t for single byte values"

Summary:
Original change was D43991 (rL326541) and was reverted by rL326571 and
rL326572. This adds also the necessary MCCodeEmitter patch.

Reviewers: sbc100

Subscribers: jfb, dschuff, sbc100, jgravelle-google, sunfish, llvm-commits, ncw

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

llvm-svn: 326614

6 years ago[SystemZ] Allow LRV/STRV with volatile memory accesses
Ulrich Weigand [Fri, 2 Mar 2018 20:51:59 +0000 (20:51 +0000)]
[SystemZ] Allow LRV/STRV with volatile memory accesses

The byte-swapping loads and stores do not actually perform multiple
accesses to their memory operand, so they are OK to use with volatile
memory operands as well.  Remove overly cautious check.

llvm-svn: 326613

6 years ago[SystemZ] Add support for anyregcc calling convention
Ulrich Weigand [Fri, 2 Mar 2018 20:40:11 +0000 (20:40 +0000)]
[SystemZ] Add support for anyregcc calling convention

This adds back-end support for the anyregcc calling convention
for use with patchpoints.

Since all registers are considered call-saved with anyregcc
(except for 0 and 1 which may still be clobbered by PLT stubs
and the like), this required adding support for saving and
restoring vector registers in prologue/epilogue code for the
first time.  This is not used by any other calling convention.

llvm-svn: 326612

6 years ago[SystemZ] Support stackmaps and patchpoints
Ulrich Weigand [Fri, 2 Mar 2018 20:39:30 +0000 (20:39 +0000)]
[SystemZ] Support stackmaps and patchpoints

This adds back-end support for the @llvm.experimental.stackmap and
@llvm.experimental.patchpoint intrinsics.

llvm-svn: 326611

6 years ago[SystemZ] Fix common-code users of stack size
Ulrich Weigand [Fri, 2 Mar 2018 20:38:41 +0000 (20:38 +0000)]
[SystemZ] Fix common-code users of stack size

On SystemZ we need to provide a register save area of 160 bytes to
any called function.  This size needs to be added when allocating
stack in the function prologue.  However, it was not accounted for
as part of MachineFrameInfo::getStackSize(); instead the back-end
used a private routine getAllocatedStackSize().

This is OK for code-gen purposes, but it breaks other users of
the getStackSize() routine, in particular it breaks the recently-
added -stack-size-section feature.

Fix this by updating the main stack size tracked by common code
(in emitPrologue) instead of using the private routine.

No change in code generation intended.

llvm-svn: 326610

6 years ago[SystemZ] Support vector registers in inline asm
Ulrich Weigand [Fri, 2 Mar 2018 20:36:34 +0000 (20:36 +0000)]
[SystemZ] Support vector registers in inline asm

This adds support for specifying vector registers for use with inline
asm statements, either via the 'v' constraint or by explicit register
names (v0 ... v31).

llvm-svn: 326609

6 years ago[InstCombine] partly fix FMF for fmul+log2 fold
Sanjay Patel [Fri, 2 Mar 2018 20:32:46 +0000 (20:32 +0000)]
[InstCombine] partly fix FMF for fmul+log2 fold

The code was checking that all of the instructions in the
sequence are 'fast', but that's not necessary. The final
multiply is all that we need to check (tests adjusted).
The fmul doesn't need to be fully 'fast' either, but that
can be another patch.

llvm-svn: 326608

6 years agoRange-ify a for loop. NFC
George Burgess IV [Fri, 2 Mar 2018 20:10:38 +0000 (20:10 +0000)]
Range-ify a for loop. NFC

llvm-svn: 326607

6 years ago[InstCombine] add tests for rL169025; NFC
Sanjay Patel [Fri, 2 Mar 2018 19:26:13 +0000 (19:26 +0000)]
[InstCombine] add tests for rL169025; NFC

This narrow fold was added with no motivation or test cases
a bit over 5 years ago. Removing a constant operand is a
good canonicalization? We should handle Y*2.0 too then?

llvm-svn: 326606

6 years agoAdds a clang-tidy test for a failing assertion in the misc-misplaced-const check.
Aaron Ballman [Fri, 2 Mar 2018 19:14:34 +0000 (19:14 +0000)]
Adds a clang-tidy test for a failing assertion in the misc-misplaced-const check.

The test case previously triggered an assertion in the AST matchers because the QualType being matched is invalid. That is no longer the case after r326604.

llvm-svn: 326605

6 years agoFix the hasType() AST matcher to not assert when the QualType is invalid.
Aaron Ballman [Fri, 2 Mar 2018 19:14:21 +0000 (19:14 +0000)]
Fix the hasType() AST matcher to not assert when the QualType is invalid.

There's not a particularly good way to test this with the AST matchers unit tests because the only way to get an invalid type (that I can devise) involves creating parse errors, which the test harness always treats as a failure. Instead, a clang-tidy test case will be added in a follow-up commit based on the original bug report.

llvm-svn: 326604

6 years ago[Attr] Use -fsyntax-only in test
Joel E. Denny [Fri, 2 Mar 2018 19:03:27 +0000 (19:03 +0000)]
[Attr] Use -fsyntax-only in test

Suggested at: https://reviews.llvm.org/D43248

llvm-svn: 326603

6 years ago[Attr] Fix parameter indexing for several attributes
Joel E. Denny [Fri, 2 Mar 2018 19:03:22 +0000 (19:03 +0000)]
[Attr] Fix parameter indexing for several attributes

The patch fixes a number of bugs related to parameter indexing in
attributes:

* Parameter indices in some attributes (argument_with_type_tag,
  pointer_with_type_tag, nonnull, ownership_takes, ownership_holds,
  and ownership_returns) are specified in source as one-origin
  including any C++ implicit this parameter, were stored as
  zero-origin excluding any this parameter, and were erroneously
  printing (-ast-print) and confusingly dumping (-ast-dump) as the
  stored values.

* For alloc_size, the C++ implicit this parameter was not subtracted
  correctly in Sema, leading to assert failures or to silent failures
  of __builtin_object_size to compute a value.

* For argument_with_type_tag, pointer_with_type_tag, and
  ownership_returns, the C++ implicit this parameter was not added
  back to parameter indices in some diagnostics.

This patch fixes the above bugs and aims to prevent similar bugs in
the future by introducing careful mechanisms for handling parameter
indices in attributes.  ParamIdx stores a parameter index and is
designed to hide the stored encoding while providing accessors that
require each use (such as printing) to make explicit the encoding that
is needed.  Attribute declarations declare parameter index arguments
as [Variadic]ParamIdxArgument, which are exposed as ParamIdx[*].  This
patch rewrites all attribute arguments that are processed by
checkFunctionOrMethodParameterIndex in SemaDeclAttr.cpp to be declared
as [Variadic]ParamIdxArgument.  The only exception is xray_log_args's
argument, which is encoded as a count not an index.

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

llvm-svn: 326602

6 years agoFix more spelling mistakes in comments of LLVM Analysis passes
Vedant Kumar [Fri, 2 Mar 2018 18:57:02 +0000 (18:57 +0000)]
Fix more spelling mistakes in comments of LLVM Analysis passes

Patch by Reshabh Sharma!

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

llvm-svn: 326601

6 years ago[PatternMatch, InstSimplify] fix m_NaN to work with vector constants and use it
Sanjay Patel [Fri, 2 Mar 2018 18:36:08 +0000 (18:36 +0000)]
[PatternMatch, InstSimplify] fix m_NaN to work with vector constants and use it

This is NFC for the moment (and independent of any potential NaN semantic
controversy). Besides making the code in InstSimplify easier to read, the
motivation is to eventually allow undef elements in vector constants to
match too. A proposal to add the base logic for that is in D43792.

llvm-svn: 326600

6 years ago[Hexagon] Handle VACOPY in isel lowering
Krzysztof Parzyszek [Fri, 2 Mar 2018 18:35:57 +0000 (18:35 +0000)]
[Hexagon] Handle VACOPY in isel lowering

llvm-svn: 326599

6 years ago[clangd] Use higher timoout values in TUSchedulerTest::Debounce
Ilya Biryukov [Fri, 2 Mar 2018 18:23:41 +0000 (18:23 +0000)]
[clangd] Use higher timoout values in TUSchedulerTest::Debounce

Should unbreak windows buildbots.

llvm-svn: 326598

6 years ago[X86][BTVER2] Fix throughput of YMM bitwise instructions
Simon Pilgrim [Fri, 2 Mar 2018 18:20:35 +0000 (18:20 +0000)]
[X86][BTVER2] Fix throughput of YMM bitwise instructions

These instructions are double-pumped, split into 2 128-bit ops and then passing through either FPU pipe.

Found while testing llvm-mca (D43951)

llvm-svn: 326597

6 years ago[X86] Reject xmm16-31 in inline asm constraints when AVX512 is disabled
Craig Topper [Fri, 2 Mar 2018 18:19:40 +0000 (18:19 +0000)]
[X86] Reject xmm16-31 in inline asm constraints when AVX512 is disabled

Fixes PR36532

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

llvm-svn: 326596

6 years ago[InstCombine] Allow fptrunc (fpext X)) to be reduced to a single fpext/ftrunc
Craig Topper [Fri, 2 Mar 2018 18:16:51 +0000 (18:16 +0000)]
[InstCombine] Allow fptrunc (fpext X)) to be reduced to a single fpext/ftrunc

If we are only truncating bits from the extend we should be able to just use a smaller extend.

If we are truncating more than the extend we should be able to just use a fptrunc since the presense of the fpextend shouldn't affect rounding.

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

llvm-svn: 326595

6 years ago[OPENMP] Scan all redeclarations looking for `declare simd` attribute.
Alexey Bataev [Fri, 2 Mar 2018 18:07:00 +0000 (18:07 +0000)]
[OPENMP] Scan all redeclarations looking for `declare simd` attribute.

Patch fixes the problem with the functions marked as `declare simd`. If
the canonical declaration does not have associated `declare simd`
construct, we may not generate required code even if other
redeclarations are marked as `declare simd`.

llvm-svn: 326594

6 years ago[X86][x32] Save callee-save register used as base pointer for x32 ABI
Derek Schuff [Fri, 2 Mar 2018 17:46:39 +0000 (17:46 +0000)]
[X86][x32] Save callee-save register used as base pointer for x32 ABI

For the x32 ABI, since the base pointer register (EBX) is a callee save register
it should be saved before use.

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

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

Patch by Pratik Bhatu

llvm-svn: 326593

6 years ago[ARM] Fold variable into assert.
Benjamin Kramer [Fri, 2 Mar 2018 17:39:20 +0000 (17:39 +0000)]
[ARM] Fold variable into assert.

Avoids unused variable warnings in Release mode.

llvm-svn: 326592

6 years ago[utils] Add utils/update_cc_test_checks.py
Fangrui Song [Fri, 2 Mar 2018 17:37:04 +0000 (17:37 +0000)]
[utils] Add utils/update_cc_test_checks.py

A utility to update LLVM IR in C/C++ FileCheck test files.

Example RUN lines in .c/.cc test files:

// RUN: %clang -S -Os -DXX %s -o - | FileCheck %s
// RUN: %clangxx -S -Os %s -o - | FileCheck -check-prefix=IR %s

Usage:

% utils/update_cc_test_checks.py --llvm-bin=release/bin test/a.cc
% utils/update_cc_test_checks.py --c-index-test=release/bin/c-index-test --clang=release/bin/clang /tmp/c/a.cc

    // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
    // RUN: %clang -emit-llvm -S -Os -DXX %s -o - | FileCheck -check-prefix=AA %s
    // RUN: %clangxx -emit-llvm -S -Os %s -o - | FileCheck -check-prefix=BB %s
    using T =
    #ifdef XX
        int __attribute__((vector_size(16)))
    #else
        short __attribute__((vector_size(16)))
    #endif
        ;

    // AA-LABEL: _Z3fooDv4_i:
    // AA:       entry:
    // AA-NEXT:    %add = shl <4 x i32> %a, <i32 1, i32 1, i32 1, i32 1>
    // AA-NEXT:    ret <4 x i32> %add
    //
    // BB-LABEL: _Z3fooDv8_s:
    // BB:       entry:
    // BB-NEXT:    %add = shl <8 x i16> %a, <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>
    // BB-NEXT:    ret <8 x i16> %add
    T foo(T a) {
      return a + a;
    }

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

llvm-svn: 326591

6 years ago[OPENMP] Treat local variables in CUDA mode as thread local.
Alexey Bataev [Fri, 2 Mar 2018 17:17:12 +0000 (17:17 +0000)]
[OPENMP] Treat local variables in CUDA mode as thread local.

In CUDA mode all local variables are actually thread
local|threadprivate, not private, and, thus, they cannot be shared
between threads|lanes.

llvm-svn: 326590

6 years agoAMDGPU/GlobalISel: InstrMapping for G_ZEXT
Matt Arsenault [Fri, 2 Mar 2018 16:55:37 +0000 (16:55 +0000)]
AMDGPU/GlobalISel: InstrMapping for G_ZEXT

llvm-svn: 326589

6 years agoAMDGPU/GlobalISel: InstrMapping for G_TRUNC
Matt Arsenault [Fri, 2 Mar 2018 16:55:33 +0000 (16:55 +0000)]
AMDGPU/GlobalISel: InstrMapping for G_TRUNC

llvm-svn: 326588

6 years agoAMDGPU/GlobalISel: Define InstrMappings for G_FCMP
Matt Arsenault [Fri, 2 Mar 2018 16:53:15 +0000 (16:53 +0000)]
AMDGPU/GlobalISel: Define InstrMappings for G_FCMP

Patch by Tom Stellard

llvm-svn: 326587

6 years agoAMDGPU/GlobalISel: Define instruction mapping for @llvm.minnum
Matt Arsenault [Fri, 2 Mar 2018 16:40:17 +0000 (16:40 +0000)]
AMDGPU/GlobalISel: Define instruction mapping for @llvm.minnum

Patch by Tom Stellard

llvm-svn: 326586

6 years agoLoopUnroll: respect pragma unroll when AllowRemainder is disabled
Yaxun Liu [Fri, 2 Mar 2018 16:22:32 +0000 (16:22 +0000)]
LoopUnroll: respect pragma unroll when AllowRemainder is disabled

Currently when AllowRemainder is disabled, pragma unroll count is not
respected even though there is no remainder. This bug causes a loop
fully unrolled in many cases even though the user specifies a unroll
count. Especially it affects OpenCL/CUDA since in many cases a loop
contains convergent instructions and currently AllowRemainder is
disabled for such loops.

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

llvm-svn: 326585

6 years ago[ARM] Fix access to stack arguments when re-aligning SP in Armv6m
Momchil Velikov [Fri, 2 Mar 2018 15:47:14 +0000 (15:47 +0000)]
[ARM] Fix access to stack arguments when re-aligning SP in Armv6m

When an Armv6m function dynamically re-aligns the stack, access to incoming
stack arguments (and to stack area, allocated for register varargs) is done via
SP, which is incorrect, as the SP is offset by an unknown amount relative to the
value of SP upon function entry.

This patch fixes it, by making access to "fixed" frame objects be done via FP
when the function needs stack re-alignment.  It also changes the access to
"fixed" frame objects be done via FP (instead of using R6/BP) also for the case
when the stack frame contains variable sized objects. This should allow more
objects to fit within the immediate offset of the load instruction.

All of the above via a small refactoring to reuse the existing
`ARMFrameLowering::ResolveFrameIndexReference.`

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

llvm-svn: 326584

6 years ago[WebAssembly] Rename global types to match the notation in the spec
Nicholas Wilson [Fri, 2 Mar 2018 14:54:34 +0000 (14:54 +0000)]
[WebAssembly] Rename global types to match the notation in the spec

llvm-svn: 326583

6 years ago[MergeICmps] Revert accidentally submitted failing test case.
Clement Courbet [Fri, 2 Mar 2018 14:53:33 +0000 (14:53 +0000)]
[MergeICmps] Revert accidentally submitted failing test case.

Reverts r326574.

llvm-svn: 326582

6 years ago[WebAssembly] Export non-hidden defined data symbols via wasm globals
Nicholas Wilson [Fri, 2 Mar 2018 14:51:36 +0000 (14:51 +0000)]
[WebAssembly] Export non-hidden defined data symbols via wasm globals

This fixes a TODO introduced in rLLD325861.

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

llvm-svn: 326581

6 years ago[WebAssembly] Pass ownership of body to SyntheticFunction. NFC
Nicholas Wilson [Fri, 2 Mar 2018 14:48:50 +0000 (14:48 +0000)]
[WebAssembly] Pass ownership of body to SyntheticFunction. NFC

This avoids the Writer unnecessarily having a member to retain ownership
of the function body.

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

llvm-svn: 326580

6 years ago[WebAssembly] Add validation for init function signature
Nicholas Wilson [Fri, 2 Mar 2018 14:46:54 +0000 (14:46 +0000)]
[WebAssembly] Add validation for init function signature

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

llvm-svn: 326579

6 years ago[Power9] Add missing instructions to the Power 9 scheduler
Stefan Pintilie [Fri, 2 Mar 2018 14:41:38 +0000 (14:41 +0000)]
[Power9] Add missing instructions to the Power 9 scheduler

Adding more instructions using InstRW so that we can move away from ItinRW
and ultimately have a complete Power 9 scheduler.

llvm-svn: 326578

6 years ago[WebAssembly] Check function type indexes
Nicholas Wilson [Fri, 2 Mar 2018 14:35:29 +0000 (14:35 +0000)]
[WebAssembly] Check function type indexes

Also update tests containing invalid Wasm files, exposed by the check

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

llvm-svn: 326577

6 years ago[Docs] Add LLVM for Grad Students to Contributing page.
Florian Hahn [Fri, 2 Mar 2018 14:35:02 +0000 (14:35 +0000)]
[Docs] Add LLVM for Grad Students to Contributing page.

Adrian Sampson's blog post provides a good and relatively up-do-date
introduction to LLVM. I think this post could be helpful for people wanting
to get started with LLVM.

Reviewers: asb, tonic, silvas, probinson, kristof.beyls, rengolin

Reviewed By: rengolin

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

llvm-svn: 326576

6 years ago[MergeICmps] Revert 324317 "Enable the MergeICmps Pass by default."
Clement Courbet [Fri, 2 Mar 2018 14:34:49 +0000 (14:34 +0000)]
[MergeICmps] Revert 324317 "Enable the MergeICmps Pass by default."

While working on PR36557.

llvm-svn: 326575

6 years ago[MergeIcmps] Add the test case from PR36557.
Clement Courbet [Fri, 2 Mar 2018 14:34:39 +0000 (14:34 +0000)]
[MergeIcmps] Add the test case from PR36557.

Summary: See PR36557.

Subscribers: llvm-commits

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

llvm-svn: 326574

6 years agoTest commit: Remove an extraneous space. NFC
David Stenberg [Fri, 2 Mar 2018 14:28:56 +0000 (14:28 +0000)]
Test commit: Remove an extraneous space. NFC

Test commit access.

llvm-svn: 326573

6 years agoRevert "[WebAssembly] More uses of uint8_t" and "[WebAssembly] Update tests"
Nicholas Wilson [Fri, 2 Mar 2018 14:07:39 +0000 (14:07 +0000)]
Revert "[WebAssembly] More uses of uint8_t" and "[WebAssembly] Update tests"

This reverts commits r326541 and r326571.

The tests were correct, and were updated with incorrect expectations.
The original commit was broken and should be reverted to get things back
to a working state.

llvm-svn: 326572

6 years ago[WebAssembly] Update tests after r326541
Ilya Biryukov [Fri, 2 Mar 2018 13:52:21 +0000 (13:52 +0000)]
[WebAssembly] Update tests after r326541

r326541 slightly increased the size of WebAssembly object files
and it broke test/MC/WebAssembly/global-ctor-dtor.ll.

This commit updates the test to unbreak it, also mentioned this to the
author of the original commit in case they don't want it.

llvm-svn: 326571

6 years ago[ARM] Fix codegen for VLD3/VLD4/VST3/VST4 with WB
Florian Hahn [Fri, 2 Mar 2018 13:02:55 +0000 (13:02 +0000)]
[ARM] Fix codegen for VLD3/VLD4/VST3/VST4 with WB

Code generation of VLD3, VLD4, VST3 and VST4 with register writeback is
broken due to 2 separate bugs:

1) VLD1d64TPseudoWB_register and VLD1d64QPseudoWB_register are missing
   rules to expand them to non pseudo MIR. These are selected for
   ARMISD::VLD3_UPD/VLD4_UPD with v1i64 vectors in SelectVLD.

2) Selection of the right VLD/VST instruction is broken for load and
   store of 3 and 4 v1i64 vectors. SelectVLD and SelectVST are called
   with MIR opcode for fixed writeback (ie increment is access size)
   and call getVLDSTRegisterUpdateOpcode() to select an opcode with
   register writeback if base register update is of a different size.
   Since getVLDSTRegisterUpdateOpcode() only knows about
   VLD1/VLD2/VST1/VST2 the call is currently conditional on the number
   of element in the vector.

   However, VLD1/VST1 is selected by SelectVLD/SelectVST's caller for
   load and stores of 3 or 4 v1i64 vectors. Therefore the opcode is not
   updated which later lead to a fixed writeback instruction being
   constructed with an extra operand for the register writeback.

This patch addresses the two issues as follows:
- it adds the necessary mapping from VLD1d64TPseudoWB_register and
  VLD1d64QPseudoWB_register to VLD1d64Twb_register and
  VLD1d64Qwb_register respectively. Like for the existing _fixed
  variants, the cost of these is bumped for unaligned access.
- it changes the logic in SelectVLD and SelectVSD to call isVLDfixed
  and isVSTfixed respectively to decide whether the opcode should be
  updated. It also reworks the logic and comments for pushing the
  writeback offset operand and r0 operand to clarify the logic:
  writeback offset needs to be pushed if it's a register writeback,
  r0 needs to be pushed if not and the instruction is a
  VLD1/VLD2/VST1/VST2.

Reviewers: rengolin, t.p.northover, samparker

Reviewed By: samparker

Patch by Thomas Preud'homme <thomas.preudhomme@arm.com>

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

llvm-svn: 326570

6 years ago[clang] Fix use-after-free on code completion
Ilya Biryukov [Fri, 2 Mar 2018 12:28:27 +0000 (12:28 +0000)]
[clang] Fix use-after-free on code completion

Summary:
Found by asan. Fiddling with code completion AST after
FrontendAction::Exceute can lead to errors.
Calling the callback in ProcessCodeCompleteResults to make sure we
don't access uninitialized state.

This particular issue comes from the fact that Sema::TUScope is
deleted when destructor of ~Parser runs, but still present in
Sema::TUScope and accessed when building completion items.

I'm still struggling to come up with a small repro. The relevant
stackframes reported by asan are:
ERROR: AddressSanitizer: heap-use-after-free on address
READ of size 8 at 0x61400020d090 thread T175
    #0 0x5632dff7821b in llvm::SmallPtrSetImplBase::isSmall() const include/llvm/ADT/SmallPtrSet.h:195:33
    #1 0x5632e0335901 in llvm::SmallPtrSetImplBase::insert_imp(void const*) include/llvm/ADT/SmallPtrSet.h:127:9
    #2 0x5632e067347d in llvm::SmallPtrSetImpl<clang::Decl*>::insert(clang::Decl*) include/llvm/ADT/SmallPtrSet.h:372:14
    #3 0x5632e065df80 in clang::Scope::AddDecl(clang::Decl*) tools/clang/include/clang/Sema/Scope.h:287:18
    #4 0x5632e0623eea in clang::ASTReader::pushExternalDeclIntoScope(clang::NamedDecl*, clang::DeclarationName) clang/lib/Serialization/ASTReader.cpp
    #5 0x5632e062ce74 in clang::ASTReader::finishPendingActions() tools/clang/lib/Serialization/ASTReader.cpp:9164:9
    ....
    #30 0x5632e02009c4 in clang::index::generateUSRForDecl(clang::Decl const*, llvm::SmallVectorImpl<char>&) tools/clang/lib/Index/USRGeneration.cpp:1037:6
    #31 0x5632dff73eab in clang::clangd::(anonymous namespace)::getSymbolID(clang::CodeCompletionResult const&) tools/clang/tools/extra/clangd/CodeComplete.cpp:326:20
    #32 0x5632dff6fe91 in clang::clangd::CodeCompleteFlow::mergeResults(std::vector<clang::CodeCompletionResult, std::allocator<clang::CodeCompletionResult> > const&, clang::clangd::SymbolSlab const&)::'lambda'(clang::CodeCompletionResult const&)::operator()(clang::CodeCompletionResult const&) tools/clang/tools/extra/clangd/CodeComplete.cpp:938:24
    #33 0x5632dff6e426 in clang::clangd::CodeCompleteFlow::mergeResults(std::vector<clang::CodeCompletionResult, std::allocator<clang::CodeCompletionResult> > const&, clang::clangd::SymbolSlab const&) third_party/llvm/llvm/tools/clang/tools/extra/clangd/CodeComplete.cpp:949:38
    #34 0x5632dff7a34d in clang::clangd::CodeCompleteFlow::runWithSema() llvm/tools/clang/tools/extra/clangd/CodeComplete.cpp:894:16
    #35 0x5632dff6df6a in clang::clangd::CodeCompleteFlow::run(clang::clangd::(anonymous namespace)::SemaCompleteInput const&) &&::'lambda'()::operator()() const third_party/llvm/llvm/tools/clang/tools/extra/clangd/CodeComplete.cpp:858:35
    #36 0x5632dff6cd42 in clang::clangd::(anonymous namespace)::semaCodeComplete(std::unique_ptr<clang::CodeCompleteConsumer, std::default_delete<clang::CodeCompleteConsumer> >, clang::CodeCompleteOptions const&, clang::clangd::(anonymous namespace)::SemaCompleteInput const&, llvm::function_ref<void ()>) tools/clang/tools/extra/clangd/CodeComplete.cpp:735:5

0x61400020d090 is located 80 bytes inside of 432-byte region [0x61400020d040,0x61400020d1f0)
freed by thread T175  here:
    #0 0x5632df74e115 in operator delete(void*, unsigned long) projects/compiler-rt/lib/asan/asan_new_delete.cc:161:3
    #1 0x5632e0b06973 in clang::Parser::~Parser() tools/clang/lib/Parse/Parser.cpp:410:3
    #2 0x5632e0b06ddd in clang::Parser::~Parser() clang/lib/Parse/Parser.cpp:408:19
    #3 0x5632e0b03286 in std::unique_ptr<clang::Parser, std::default_delete<clang::Parser> >::~unique_ptr() .../bits/unique_ptr.h:236:4
    #4 0x5632e0b021c4 in clang::ParseAST(clang::Sema&, bool, bool) tools/clang/lib/Parse/ParseAST.cpp:182:1
    #5 0x5632e0726544 in clang::FrontendAction::Execute() tools/clang/lib/Frontend/FrontendAction.cpp:904:8
    #6 0x5632dff6cd05 in clang::clangd::(anonymous namespace)::semaCodeComplete(std::unique_ptr<clang::CodeCompleteConsumer, std::default_delete<clang::CodeCompleteConsumer> >, clang::CodeCompleteOptions const&, clang::clangd::(anonymous namespace)::SemaCompleteInput const&, llvm::function_ref<void ()>) tools/clang/tools/extra/clangd/CodeComplete.cpp:728:15

Reviewers: sammccall

Reviewed By: sammccall

Subscribers: klimek, jkorous-apple, cfe-commits, ioeric

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

llvm-svn: 326569

6 years ago[LV][CFG] Add irreducible CFG detection for outer loops
Florian Hahn [Fri, 2 Mar 2018 12:24:25 +0000 (12:24 +0000)]
[LV][CFG] Add irreducible CFG detection for outer loops

This patch adds support for detecting outer loops with irreducible control
flow in LV. Current detection uses SCCs and only works for innermost loops.
This patch adds a utility function that works on any CFG, given its RPO
traversal and its LoopInfoBase. This function is a generalization
of isIrreducibleCFG  from lib/CodeGen/ShrinkWrap.cpp. The code in
lib/CodeGen/ShrinkWrap.cpp is also updated to use the new generic utility
function.

Patch by Diego Caballero <diego.caballero@intel.com>

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

llvm-svn: 326568

6 years agoAMDGPU/GlobalISel: Define instruction mapping for @llvm.maxnum
Matt Arsenault [Fri, 2 Mar 2018 12:23:00 +0000 (12:23 +0000)]
AMDGPU/GlobalISel: Define instruction mapping for @llvm.maxnum

Patch by Tom Stellard

llvm-svn: 326567

6 years agoAdd possibility to specify output stream for CompilerInstance
Alexey Sotkin [Fri, 2 Mar 2018 12:11:40 +0000 (12:11 +0000)]
Add possibility to specify output stream for CompilerInstance

Patch by: krisb

Reviewers: teemperor

Reviewed By: teemperor

Subscribers: klimek, mgorny, cfe-commits

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

llvm-svn: 326566

6 years ago[X86] Remove old UNIMPLEMENTED list
Simon Pilgrim [Fri, 2 Mar 2018 11:59:37 +0000 (11:59 +0000)]
[X86] Remove old UNIMPLEMENTED list

All of these are implemented and have appropriate test coverage

llvm-svn: 326553

6 years ago[testsuite] Remove workaround for categories and inline tests.
Jonas Devlieghere [Fri, 2 Mar 2018 10:38:11 +0000 (10:38 +0000)]
[testsuite] Remove workaround for categories and inline tests.

Adding categories to inline tests does not work because the attribute
is set at the function level. For methods, this means it applies to all
instances of that particular class. While this is what we want in most
cases, it's not for inline tests, where different instances correspond
to different tests.

With the workaround in place, assigning a category to one test resulted
in the category applied to *all* inline tests.

This patch removes the workaround and throws an exception with an
informative error message, to prevent this from happening in the future.

llvm-svn: 326552

6 years ago[Sema] Improve test coverage of narrowing conversion diagnostics
Mikhail Maltsev [Fri, 2 Mar 2018 10:03:02 +0000 (10:03 +0000)]
[Sema] Improve test coverage of narrowing conversion diagnostics

Summary:
This patch adds tests of narrowing conversion diagnostics for the
'unscoped enum -> integer' case.

Reviewers: faisalv, rsmith, rogfer01

Reviewed By: rogfer01

Subscribers: cfe-commits, rogfer01

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

llvm-svn: 326551

6 years ago[clangd:vscode] Bump clangd-vscode version to 0.0.4.
Eric Liu [Fri, 2 Mar 2018 09:26:17 +0000 (09:26 +0000)]
[clangd:vscode] Bump clangd-vscode version to 0.0.4.

llvm-svn: 326548

6 years ago[clangd:vscode] check empty/null string correctly.
Eric Liu [Fri, 2 Mar 2018 09:21:41 +0000 (09:21 +0000)]
[clangd:vscode] check empty/null string correctly.

llvm-svn: 326547

6 years ago[clangd] Debounce streams of updates.
Sam McCall [Fri, 2 Mar 2018 08:56:37 +0000 (08:56 +0000)]
[clangd] Debounce streams of updates.

Summary:
Don't actually start building ASTs for new revisions until either:
- 500ms have passed since the last revision, or
- we actually need the revision for something (or to unblock the queue)

In practice, this avoids the "first keystroke results in diagnostics" problem.
This is kind of awkward to test, and the test is pretty bad.
It can be observed nicely by capturing a trace, though.

Reviewers: hokein, ilya-biryukov

Subscribers: klimek, jkorous-apple, ioeric, cfe-commits

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

llvm-svn: 326546

6 years ago[ELF] - Report error when memory region is overflowed by data commands.
George Rimar [Fri, 2 Mar 2018 08:11:58 +0000 (08:11 +0000)]
[ELF] - Report error when memory region is overflowed by data commands.

LLD can not catch a memory area overflow when using a data command.
If we have the script below:

.foo :
{
  *(.foo)
  BYTE(0x1)
} > ram

where BYTE overflows the ram region, we do not report it currently.
Patch fixes that.

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

llvm-svn: 326545

6 years agoOpenBSD Ubsan support / interception
Kamil Rytarowski [Fri, 2 Mar 2018 07:32:30 +0000 (07:32 +0000)]
OpenBSD Ubsan support / interception

Summary: Interception, enabling OpenBSD platform

Patch by: David CARLIER

Reviewers: krytarowski, vitalybuka, visa

Reviewed By: vitalybuka

Subscribers: srhines, fedor.sergeev, llvm-commits, #sanitizers

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

llvm-svn: 326544

6 years agoOpenBSD UBsan support / ubsan part
Kamil Rytarowski [Fri, 2 Mar 2018 07:30:22 +0000 (07:30 +0000)]
OpenBSD UBsan support / ubsan part

Summary: UBsan, enable OpenBSD platform

Patch by: David CARLIER

Reviewers: krytarowski, kettenis, visa, vitalybuka

Reviewed By: vitalybuka

Subscribers: kubamracek, fedor.sergeev, llvm-commits, #sanitizers

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

llvm-svn: 326543

6 years ago[Frontend] Avoid including default system header paths on Fuchsia
Petr Hosek [Fri, 2 Mar 2018 07:19:42 +0000 (07:19 +0000)]
[Frontend] Avoid including default system header paths on Fuchsia

These paths aren't used and don't make sense on Fuchsia.

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

llvm-svn: 326542

6 years ago[WebAssembly] More uses of uint8_t for single byte values
Heejin Ahn [Fri, 2 Mar 2018 06:51:35 +0000 (06:51 +0000)]
[WebAssembly] More uses of uint8_t for single byte values

Summary: It looks like this was missing from D43921.

Reviewers: sbc100

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

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

llvm-svn: 326541

6 years ago[ThinLTO] Added a couple of C LTO API interfaces to control the cache policy.
Ekaterina Romanova [Fri, 2 Mar 2018 03:51:27 +0000 (03:51 +0000)]
[ThinLTO] Added a couple of C LTO API interfaces to control the cache policy.
- thinlto_codegen_set_cache_size_bytes to control the absolute size of cache directory.
- thinlto_codegen_set_cache_size_files the size and amount of files in cache directory.
These functions have been supported in C++ LTO API for a long time, but were absent in C LTO API.

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

llvm-svn: 326537

6 years agoUpdate man page for long opts that accept = after r326506
Ed Maste [Fri, 2 Mar 2018 02:57:12 +0000 (02:57 +0000)]
Update man page for long opts that accept = after r326506

Also remove the space between --lto-O and value, as the option with a
space is not accepted at present.

Leave --opt-remarks-filename as it does not currently accept the = form.

llvm.org/pr36563

llvm-svn: 326536

6 years agoAMDGPU/GCN: Promote i16 ctpop
Jan Vesely [Fri, 2 Mar 2018 02:50:22 +0000 (02:50 +0000)]
AMDGPU/GCN: Promote i16 ctpop

i16 capable ASICs do not support i16 operands for this instruction.
Add tablegen pattern to merge chained i16 additions.

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

llvm-svn: 326535

6 years agoAMDGPU/GlobalISel: Define instruction mapping for G_FPTOSI
Matt Arsenault [Fri, 2 Mar 2018 02:19:16 +0000 (02:19 +0000)]
AMDGPU/GlobalISel: Define instruction mapping for G_FPTOSI

Patch by Tom Stellard

llvm-svn: 326534

6 years agoAMDGPU/GlobalISel: Define instruction mapping for G_FPTOUI
Matt Arsenault [Fri, 2 Mar 2018 02:19:11 +0000 (02:19 +0000)]
AMDGPU/GlobalISel: Define instruction mapping for G_FPTOUI

Patch by Tom Stellard

llvm-svn: 326533

6 years agoAMDGPU/GlobalISel: Define instruction mapping for G_FMUL
Matt Arsenault [Fri, 2 Mar 2018 02:17:01 +0000 (02:17 +0000)]
AMDGPU/GlobalISel: Define instruction mapping for G_FMUL

llvm-svn: 326532

6 years agoRemove debugging code I accidentally committed in r326530.
Akira Hatanaka [Fri, 2 Mar 2018 02:03:21 +0000 (02:03 +0000)]
Remove debugging code I accidentally committed in r326530.

llvm-svn: 326531

6 years agoAdd an option to disable tail-call optimization for escaping blocks.
Akira Hatanaka [Fri, 2 Mar 2018 01:53:15 +0000 (01:53 +0000)]
Add an option to disable tail-call optimization for escaping blocks.

This makes it easier to debug crashes and hangs in block functions since
users can easily find out where the block is called from. The option
doesn't disable tail-calls from non-escaping blocks since non-escaping
blocks are not as hard to debug as escaping blocks.

rdar://problem/35758207

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

llvm-svn: 326530

6 years ago[analyzer] [tests] Again, make tests more resilient to changes in exploration strategy
George Karpenkov [Fri, 2 Mar 2018 01:41:19 +0000 (01:41 +0000)]
[analyzer] [tests] Again, make tests more resilient to changes in exploration strategy

llvm-svn: 326529

6 years ago[InstCombine] Add more test case to fpextend.ll.
Craig Topper [Fri, 2 Mar 2018 01:34:42 +0000 (01:34 +0000)]
[InstCombine] Add more test case to fpextend.ll.

This includes the test cases from D43970 and additional tests for combining (fptrunc (binop (fpext), (fpext))) where the pre-extended types don't match the trunc and therefore can't be completely removed.

llvm-svn: 326528

6 years agoAlways set dso_local in CodeGenModule::setDSOLocal.
Rafael Espindola [Fri, 2 Mar 2018 01:29:51 +0000 (01:29 +0000)]
Always set dso_local in CodeGenModule::setDSOLocal.

This shouldn't change any results for now, but is more consistent with
how we set dllimport/dllexport and will make future changes easier.

Since clang produces IR as it parses, it can find out mid file that
something is dllimport. When that happens we have to drop
dso_local. This is not a problem right now because
CodeGenModule::setDSOLocal is called from relatively few places at
the moment.

llvm-svn: 326527

6 years agoAMDGPU/GlobalISel: Define instruction mapping for G_FADD
Matt Arsenault [Fri, 2 Mar 2018 01:22:13 +0000 (01:22 +0000)]
AMDGPU/GlobalISel: Define instruction mapping for G_FADD

Patch by Tom Stellard

llvm-svn: 326526

6 years agoAMDGPU/GlobalISel: Define instruction mapping for G_SHL
Matt Arsenault [Fri, 2 Mar 2018 01:22:10 +0000 (01:22 +0000)]
AMDGPU/GlobalISel: Define instruction mapping for G_SHL

Patch by Tom Stellard

llvm-svn: 326525

6 years agoAMDGPU/GlobalISel: Define instruction mapping for G_XOR
Matt Arsenault [Fri, 2 Mar 2018 01:22:06 +0000 (01:22 +0000)]
AMDGPU/GlobalISel: Define instruction mapping for G_XOR

llvm-svn: 326524

6 years agoAMDGPU/GlobalISel: Define instruction mapping for G_AND
Matt Arsenault [Fri, 2 Mar 2018 01:22:01 +0000 (01:22 +0000)]
AMDGPU/GlobalISel: Define instruction mapping for G_AND

Patch by Tom Stellard

llvm-svn: 326523

6 years ago[WebAssembly] Gather EH instructions in one place. NFC.
Heejin Ahn [Fri, 2 Mar 2018 01:03:40 +0000 (01:03 +0000)]
[WebAssembly] Gather EH instructions in one place. NFC.

Summary:
- Gather EH instructions in one place for easy tracking (more will be
  added later)
- Variable name change

Reviewers: dschuff

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

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

llvm-svn: 326522

6 years ago[ArgumentPromotion] don't break musttail invariant PR36543
Fedor Indutny [Fri, 2 Mar 2018 00:59:27 +0000 (00:59 +0000)]
[ArgumentPromotion] don't break musttail invariant PR36543

Summary:
Do not break musttail invariant by promoting arguments of musttail
callee or caller.

Reviewers: sanjoy, dberlin, hfinkel, george.burgess.iv, fhahn, rnk

Reviewed By: rnk

Subscribers: rnk, llvm-commits

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

llvm-svn: 326521

6 years ago[analyzer] Prevent crashing in NonNullParamChecker
George Karpenkov [Fri, 2 Mar 2018 00:55:59 +0000 (00:55 +0000)]
[analyzer] Prevent crashing in NonNullParamChecker

https://bugs.llvm.org/show_bug.cgi?id=36381
rdar://37543426

Turns out, the type passed for the lambda capture was incorrect.
One more argument to abandon the getSVal overload which does not require the
type information.

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

llvm-svn: 326520

6 years ago[StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use warnings...
Eugene Zelenko [Fri, 2 Mar 2018 00:54:51 +0000 (00:54 +0000)]
[StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 326519

6 years ago[analyzer] [NFC] [tests] Make test more resilient to changes in exploration strategy
George Karpenkov [Fri, 2 Mar 2018 00:54:05 +0000 (00:54 +0000)]
[analyzer] [NFC] [tests] Make test more resilient to changes in exploration strategy

llvm-svn: 326518

6 years ago[WebAssembly] Add exception handling option
Heejin Ahn [Fri, 2 Mar 2018 00:39:16 +0000 (00:39 +0000)]
[WebAssembly] Add exception handling option

Summary: Add exception handling option to clang.

Reviewers: dschuff

Subscribers: jfb, sbc100, jgravelle-google, sunfish, cfe-commits

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

llvm-svn: 326517

6 years agoUtility functions for checked arithmetic
George Karpenkov [Fri, 2 Mar 2018 00:30:43 +0000 (00:30 +0000)]
Utility functions for checked arithmetic

Provide checkedAdd and checkedMul functions, providing checked
arithmetic on signed integers.

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

llvm-svn: 326516

6 years ago[InstCombine] Simplify test cases by removing loads/stores that aren't required for...
Craig Topper [Fri, 2 Mar 2018 00:27:44 +0000 (00:27 +0000)]
[InstCombine] Simplify test cases by removing loads/stores that aren't required for what is being tested.

The loads and stores were getting the data and storing the results. There's no reason we can't just use function arguments and return.

llvm-svn: 326515

6 years agoSpeed up TestWatchpointMultipleThreads
Pavel Labath [Fri, 2 Mar 2018 00:17:05 +0000 (00:17 +0000)]
Speed up TestWatchpointMultipleThreads

Summary:
The inferior was sleeping before doing any interesting work. I remove that
to make the test faster.

While looking at the purpose of the test (to check that watchpoints are
propagated to all existing threads - r140757) I noticed that the test has
diverged from the original intention and now it creates the threads *after* the
watchpoint is set (this probably happened during the std::thread refactor).
After some discussion, we decided both scenarios make sense, so I modify the
test to test both.

The watchpoint propagation functionality is not really debug info depenent, so
I also stop replication of this test. This brings the test's time from ~108s
down to 4s.

Reviewers: davide, jingham

Subscribers: aprantl, lldb-commits

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

llvm-svn: 326514

6 years ago[InstCombine] allow fmul fold with less than 'fast'
Sanjay Patel [Fri, 2 Mar 2018 00:14:51 +0000 (00:14 +0000)]
[InstCombine] allow fmul fold with less than 'fast'

This is a retry of r326502 with updates to the reassociate
test file that I missed the first time.

@test15_reassoc in the supposed -reassociate test file
(except that it tests 2 other passes too...) shows that
there's no clear responsiblity for reassociation transforms.

Instcombine now gets that case, but only because the
constant values are identical. Otherwise, it would still
miss that pattern.

Reassociate doesn't get that case because it hasn't been
updated to use less than 'fast' FMF.

llvm-svn: 326513

6 years ago[NFC] Move CommentOpts checks to the call sites that depend on it. (Re-applying r326501.)
David L. Jones [Fri, 2 Mar 2018 00:07:45 +0000 (00:07 +0000)]
[NFC] Move CommentOpts checks to the call sites that depend on it. (Re-applying r326501.)

When parsing comments, for example, for -Wdocumentation, slightly different
behaviour occurs when -fparse-all-comments is specified. However, these
differences are subtle:

1. All comments are saved during parsing, regardless of whether they are doc
   comments or not.
2. "Maybe-doc" comments, like <, !, etc, are saved as such, instead of marking
   them as ordinary comments. The maybe-doc type of comment is never saved
   otherwise. (Warning on these is the impetus of -Wdocumentation.)
3. All comments are treated as doc comments in ASTContext, even if they are ordinary.

This change moves the logic for checking CommentOptions.ParseAllComments closer
to where it has an effect. The overall logic is unchanged, but checks of the
ParseAllComments flag are now done where the effect will be clearer.

Subscribers: cfe-commits
llvm-svn: 326512

6 years ago[Reassociate] regenerate checks; NFC
Sanjay Patel [Thu, 1 Mar 2018 23:41:03 +0000 (23:41 +0000)]
[Reassociate] regenerate checks; NFC

llvm-svn: 326511

6 years agorevert r326502: [InstCombine] allow fmul fold with less than 'fast'
Sanjay Patel [Thu, 1 Mar 2018 23:39:24 +0000 (23:39 +0000)]
revert r326502: [InstCombine] allow fmul fold with less than 'fast'

I forgot that I added tests for 'reassoc' to -reassociate, but
suprisingly that file calls -instcombine too, so it is affected.
I'll update that file and try again.

llvm-svn: 326510

6 years ago[WebAssembly] Simplify COMDAT handling.
Rui Ueyama [Thu, 1 Mar 2018 23:29:05 +0000 (23:29 +0000)]
[WebAssembly] Simplify COMDAT handling.

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

llvm-svn: 326509

6 years agoRevert r326501 due to buildbot breakage.
David L. Jones [Thu, 1 Mar 2018 23:14:00 +0000 (23:14 +0000)]
Revert r326501 due to buildbot breakage.

Original change:

[NFC] Move CommentOpts checks to the call sites that depend on it.

When parsing comments, for example, for -Wdocumentation, slightly different
behaviour occurs when -fparse-all-comments is specified. However, these
differences are subtle:

1. All comments are saved during parsing, regardless of whether they are doc comments or not.
2. "Maybe-doc" comments, like //<, //!, etc, are saved as such, instead of marking them as ordinary comments. The maybe-doc type of comment is never saved otherwise. (Warning on these is the impetus of -Wdocumentation.)
3. All comments are treated as doc comments in ASTContext, even if they are ordinary.

This change moves the logic for checking CommentOptions.ParseAllComments closer
to where it has an effect. The overall logic is unchanged, but checks of the
ParseAllComments flag are now done where the effect will be clearer.

llvm-svn: 326508

6 years agoReport an error if you try to link against .dll instead of .lib.
Rui Ueyama [Thu, 1 Mar 2018 23:11:30 +0000 (23:11 +0000)]
Report an error if you try to link against .dll instead of .lib.

It is a usage error to feed a .dll file instead of a .dll to COFF linker.
Previously, lld failed with a mysterious error message. Now we reject
it at the driver.

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

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

llvm-svn: 326507

6 years agoAccept both `--foo bar` and `--foo=bar` styles options.
Rui Ueyama [Thu, 1 Mar 2018 23:06:10 +0000 (23:06 +0000)]
Accept both `--foo bar` and `--foo=bar` styles options.

GNU linkers by convention supports both `--foo bar` and `--foo=bar` styles
for all long options that take arguments.

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

llvm-svn: 326506

6 years agobpf: introduce -mattr=dwarfris to disable DwarfUsesRelocationsAcrossSections
Yonghong Song [Thu, 1 Mar 2018 23:04:59 +0000 (23:04 +0000)]
bpf: introduce -mattr=dwarfris to disable DwarfUsesRelocationsAcrossSections

Commit e4507fb8c94b ("bpf: disable DwarfUsesRelocationsAcrossSections")
disables MCAsmInfo DwarfUsesRelocationsAcrossSections unconditionally
so that dwarf will not use cross section (between dwarf and symbol table)
relocations. This new debug format enables pahole to dump structures
correctly as libdwarves.so does not have BPF backend support yet.

This new debug format, however, breaks bcc (https://github.com/iovisor/bcc)
source debug output as llvm in-memory Dwarf support has some issues to
handle it. More specifically, with DwarfUsesRelocationsAcrossSections
disabled, JIT compiler does not generate .debug_abbrev and Dwarf
DIE (debug info entry) processing is not happy about this.

This patch introduces a new flag -mattr=dwarfris
(dwarf relocation in section) to disable DwarfUsesRelocationsAcrossSections.
DwarfUsesRelocationsAcrossSections is true by default.

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

6 years agoRename a test file and fix indentation.
Rui Ueyama [Thu, 1 Mar 2018 23:01:41 +0000 (23:01 +0000)]
Rename a test file and fix indentation.

llvm-svn: 326504

6 years agoSet DF_TEXTREL to executables that need text relocations.
Rui Ueyama [Thu, 1 Mar 2018 22:56:52 +0000 (22:56 +0000)]
Set DF_TEXTREL to executables that need text relocations.

Summary:
If an executable needs text relocations, it should be marked as such so
that the loader can prepare for text relocations. We currently create a
dummy segment with DT_TEXTREL for that purpose.

Generic ABI as of 2000 [1] mentioned that "Its [DT_TEXTREL's] use
has been superseded by the DF_TEXTREL flag". However, it's actually not
superseded even after 18 years. OpenBSD and musl recognize only DT_TEXTREL.
So we still need to set both.

[1] http://www.sco.com/developers/gabi/2000-07-17/ch5.dynamic.html

Reviewers: rafael

Subscribers: emaste, llvm-commits, arichardson

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

llvm-svn: 326503

6 years ago[InstCombine] allow fmul fold with less than 'fast'
Sanjay Patel [Thu, 1 Mar 2018 22:53:47 +0000 (22:53 +0000)]
[InstCombine] allow fmul fold with less than 'fast'

llvm-svn: 326502

6 years ago[NFC] Move CommentOpts checks to the call sites that depend on it.
David L. Jones [Thu, 1 Mar 2018 22:41:53 +0000 (22:41 +0000)]
[NFC] Move CommentOpts checks to the call sites that depend on it.

When parsing comments, for example, for -Wdocumentation, slightly different
behaviour occurs when -fparse-all-comments is specified. However, these
differences are subtle:

 1. All comments are saved during parsing, regardless of whether they are doc
    comments or not.
 2. "Maybe-doc" comments, like //<, //!, etc, are saved as such, instead of
    marking them as ordinary comments. The maybe-doc type of comment is never
    saved otherwise. (Warning on these is the impetus of -Wdocumentation.)
 3. All comments are treated as doc comments in ASTContext, even if they are
    ordinary.

This change moves the logic for checking CommentOptions.ParseAllComments closer
to where it has an effect. The overall logic is unchanged, but checks of the
ParseAllComments flag are now done where the effect will be clearer.

Reviewers: rsmith

Subscribers: cfe-commits

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

llvm-svn: 326501