Commit Graph

300205 Commits

Author SHA1 Message Date
Ali Tamur 63830b2794 Introduce a flag to warn when ifunc symbols are used with text relocations.
Summary:
This patch adds a new flag, --warn-ifunc-textrel, to work around a glibc bug. When a code with ifunc symbols is used to produce an object file with text relocations, lld always succeeds. However, if that object file is linked using an old version of glibc, the resultant binary just crashes with segmentation fault when it is run (The bug is going to be corrected as of glibc 2.19).

Since there is no way to tell beforehand what library the object file will be linked against in the future, there does not seem to be a fool-proof way for lld to give an error only in cases where the binary will crash. So, with this change (dated 2018-09-25), lld starts to give a warning, contingent on a new command line flag that does not have a gnu counter part. The default value for --warn-ifunc-textrel is false, so lld behaviour will not change unless the user explicitly asks lld to give a warning. Users that link with a glibc library with version 2.19 or newer, or does not use ifunc symbols, or does not generate object files with text relocations do not need to take any action. Other users may consider to start passing warn-ifunc-textrel to lld to get early warnings.

Reviewers: ruiu, espindola

Reviewed By: ruiu

Subscribers: grimar, MaskRay, markj, emaste, arichardson, llvm-commits

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

llvm-svn: 343628
2018-10-02 20:30:22 +00:00
Aaron Smith da0602c154 [CodeView] Only add the Scoped flag for an enum type when it has an immediate function scope to match MSVC
Reviewers: rnk, zturner, llvm-commits

Reviewed By: rnk

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

llvm-svn: 343627
2018-10-02 20:28:15 +00:00
Aaron Smith 802b033d78 [CodeView] Emit function options for subprogram and member functions
Summary:
Use the newly added DebugInfo (DI) Trivial flag, which indicates if a C++ record is trivial or not, to determine Codeview::FunctionOptions.

Clang and MSVC generate slightly different Codeview for C++ records. For example, here is the C++ code for a class with a defaulted ctor,

       class C {
       public:
         C() = default;
       };

Clang will produce a LF for the defaulted ctor while MSVC does not. For more details, refer to FIXMEs in the test cases in "function-options.ll" included with this set of changes.


Reviewers: zturner, rnk, llvm-commits, aleksandr.urakov

Reviewed By: rnk

Subscribers: Hui, JDevlieghere

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

llvm-svn: 343626
2018-10-02 20:21:05 +00:00
Adrian Prantl be50052a2b Remove unnecessary field
llvm-svn: 343624
2018-10-02 20:14:12 +00:00
Eric Liu 9a3af5a4f1 [clangd] Try to fix windows buildbot after r343576
http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/20347/steps/test/logs/stdio

llvm-svn: 343623
2018-10-02 20:00:32 +00:00
Sam McCall a659d779f8 Reland r343589 "[clangd] Dex: add Corpus factory for iterators, rename, fold constant. NFC""
This reverts commit r343610.

llvm-svn: 343622
2018-10-02 19:59:23 +00:00
Matt Davis 42425ccf50 [llvm-mca] Remove unecessary forward decls. NFC.
This patch also removes an unecessary include.

llvm-svn: 343621
2018-10-02 19:42:46 +00:00
Kristof Umann 40271e4fde [analyzer][NFC] Refactor functions in PlistDiagnostics to take AnalyzerOptions as parameter
I intend to add a new flag macro-expnasions-as-events, and unfortunately
I'll only be able to convert the macro piece into an event one once I'm
about to emit it, due to the lack of an avaible Preprocessor object in
the BugReporter.

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

llvm-svn: 343620
2018-10-02 19:27:34 +00:00
Jonathan Peyton 8bb8a92de9 [OpenMP] Shutdown library on Windows if possible for better OMPT behavior
On Windows, child workers are terminated by the parent during the normal
program exit process (ExitProcess()) and they are not able to finish generating
their OpenMP events. We can force manual library shut down in __kmpc_end() to
fix this at least for the cases where __kmpc_end() is properly inserted.

Patch by Hansang Bae

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

llvm-svn: 343619
2018-10-02 19:15:04 +00:00
Jonas Hahnfeld 3ca4701d35 [OpenMP][NVPTX] Simplify codegen for orphaned parallel, NFCI.
Worker threads fork off to the compiler generated worker function
directly after entering the kernel function. Hence, there is no
need to check whether the current thread is the master if we are
outside of a parallel region (neither SPMD nor parallel_level > 0).

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

llvm-svn: 343618
2018-10-02 19:12:54 +00:00
Jonas Hahnfeld 5aaaecea7c [OpenMP] Simplify code for reductions on distribute directives, NFC.
Only need to care about the 'distribute simd' case, all other composite
directives are handled elsewhere. This was already reflected in the
outer 'if' condition, so all other inner conditions could never be true.

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

llvm-svn: 343617
2018-10-02 19:12:47 +00:00
Matt Morehouse 4b1ec17fb0 Revert "X86, AArch64, ARM: Do not attach debug location to spill/reload instructions"
This reverts r343520 due to breakage of HWASan tests on Android.

llvm-svn: 343616
2018-10-02 18:35:44 +00:00
Matt Davis 21d41dffe1 [llvm-mca] Constify the 'notify' routines. NFC.
Also fixed up some whitespace formatting in DispatchStage.cpp.

llvm-svn: 343615
2018-10-02 18:26:33 +00:00
Craig Topper 49225d0915 [X86][Disassembler] Add bizarro versions of the MOVSXD instruction that sign extend from a GR32 to GR32 or GR16.
The 0x63 opcodes in 64-bit mode have a fixed source size of 32-bits, but the destination size is controlled by REX.W and the 0x66 opsize prefix. This instruction is normally used with a REX.W prefix which provides desired behavior. The other encodings are interpretted as valid by the processor, but aren't useful.

This patch makes us recognize them for the disassembler to match objdump.

llvm-svn: 343614
2018-10-02 18:16:19 +00:00
Daniel Sanders 74de21d06f [globalisel][verifier] Run the MachineVerifier from IRTranslator onwards
-verify-machineinstrs inserts the MachineVerifier after every MachineInstr-based
pass. However, GlobalISel creates MachineInstr-based passes earlier than DAGISel
and the corresponding verifiers are not being added. This patch fixes that.

If GlobalISel triggers the fallback path then the MIR can be left in a bad
state that is going to be cleared by ResetMachineFunctions. In this situation
verifying between GlobalISel passes will prevent the fallback path from
recovering from this. As a result, we bail out of verifying a function if the
FailedISel attribute is present.

llvm-svn: 343613
2018-10-02 17:56:58 +00:00
Adrian Prantl f796e763b2 DWARFExpression: Resolve file addresses in the linked module
This is a follow-up to https://reviews.llvm.org/D46362.

When evaluating a complex expression in DWARFExpression::Evaluate,
file addresses must be resolved to load addresses before we can
perform operations such as DW_OP_deref on them.

For this the address goes through three steps

1. Read the file address as stored in the DWARF
2. Link/relocate the file address (when reading from a .dSYM, this is a no-op)
3. Convert the file address to a load address.

D46362 implemented step (3) by resolving the file address using the
Module that the original DWARF came from. In the case of a dSYM that
is correct, but when reading from .o files, we need to look up
relocated/linked addresses, so the right place to look them up is the
current frame's module. This patch fixes that by setting the
expression's Module to point to the linked debugmap object.

A word a bout the unorthodox testcase: The motivating testcase for
this fix is in Swift, but I managed to hand-modify LLVM-IR for a
trivial C program to exhibit the same problem, so we can fix this in
llvm.org.

rdar://problem/44689915

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

llvm-svn: 343612
2018-10-02 17:50:42 +00:00
Yaxun Liu 9767089d00 [HIP] Support early finalization of device code for -fno-gpu-rdc
This patch renames -f{no-}cuda-rdc to -f{no-}gpu-rdc and keeps the original
options as aliases. When -fgpu-rdc is off,
clang will assume the device code in each translation unit does not call
external functions except those in the device library, therefore it is possible
to compile the device code in each translation unit to self-contained kernels
and embed them in the host object, so that the host object behaves like
usual host object which can be linked by lld.

The benefits of this feature is: 1. allow users to create static libraries which
can be linked by host linker; 2. amortized device code linking time.

This patch modifies HIP action builder to insert actions for linking device
code and generating HIP fatbin, and pass HIP fatbin to host backend action.
It extracts code for constructing command for generating HIP fatbin as
a function so that it can be reused by early finalization. It also modifies
codegen of HIP host constructor functions to embed the device fatbin
when it is available.

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

llvm-svn: 343611
2018-10-02 17:48:54 +00:00
Reid Kleckner 2b5259afb3 Revert r343589 "[clangd] Dex: add Corpus factory for iterators, rename, fold constant. NFC"
Declaring a field with the same name as a type causes GCC to error out:

Dex.h:104:10: error: declaration of 'clang::clangd::dex::Corpus clang::clangd::dex::Dex::Corpus' [-fpermissive]
   Corpus Corpus;
          ^
Iterator.h:127:7: error: changes meaning of 'Corpus' from 'class clang::clangd::dex::Corpus' [-fpermissive]
 class Corpus {

llvm-svn: 343610
2018-10-02 17:31:43 +00:00
Tatyana Krasnukha f85f1408f6 Remove GetPythonDir declaration from HostInfoBase class
llvm-svn: 343609
2018-10-02 17:24:58 +00:00
Haojian Wu 795f6ed51c [clangd] Don't make check-clangd as a dependency in check-clang-tools
Summary:
check-clang-tools will run check-clangd first, and then run the rest
tests. If clangd tests fails, check-clang-tools would be stopped.

This would block other clang-tools developers if clangd is broken.

Reviewers: sammccall

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

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

llvm-svn: 343608
2018-10-02 17:22:11 +00:00
Petr Hosek a70ece45eb [lib/fuzzer] Fix logging for Fuchsia
This change fixes two aspects of logging on Fuchsia:

1. When logging to stdout, the output file descriptor should not be
closed in ExecuteCommand, as it prevent fdio_spawn_etc from succeeding
in subsequent calls.
2. When logging to a file in anything other than standalone Zircon, the
log file needs to be created in mutable storage. The best indicator
where this is relative to the Fuchsia component will be given by
'-artifact_prefix=...', so save the log file relative to that path.

Patch by: aarongreen
Differential Revision: https://reviews.llvm.org/D52562

llvm-svn: 343607
2018-10-02 17:21:04 +00:00
David Major 6d6c9150f9 Reland r342652 "[winasan] Unpoison the stack in NtTerminateThread"
In long-running builds we've seen some ASan complaints during thread creation that we suspect are due to leftover poisoning from previous threads whose stacks occupied that memory. This patch adds a hook that unpoisons the stack just before the NtTerminateThread syscall.

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

llvm-svn: 343606
2018-10-02 17:17:12 +00:00
Vitaly Buka 83e57e2123 [sanitizer] Include inlined frames into __sanitizer_symbolize_pc output
Summary:
Behavior for existing used is not changing as the first line is going
to be the same, and it was invalid to try to read more lines.

New clients can read until they get empty string.

Reviewers: eugenis, morehouse

Subscribers: kubamracek, eraman, llvm-commits

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

llvm-svn: 343605
2018-10-02 17:01:18 +00:00
Diogo N. Sampaio a35e55eff9 [NFC][BUG-FIX][ARM] Add missing data symbol
llvm rL343594: [ARM] Emmit data symbol
for constant pool data fixed a bug that ommited
required data symbols.
Such change breaked a test case in lld:
test/ELF/arm-thunk-largesection.s

llvm-svn: 343604
2018-10-02 16:53:12 +00:00
Reid Kleckner d5e4ec74e3 [codeview] Fix 32-bit x86 variable locations in realigned stack frames
Add the .cv_fpo_stackalign directive so that we can define $T0, or the
VFRAME virtual register, with it. This was overlooked in the initial
implementation because unlike MSVC, we push CSRs before allocating stack
space, so this value is only needed to describe local variable
locations. Variables that the compiler now addresses via ESP are instead
described as being stored at offsets from VFRAME, which for us is ESP
after alignment in the prologue.

This adds tests that show that we use the VFRAME register properly in
our S_DEFRANGE records, and that we emit the correct FPO data to define
it.

Fixes PR38857

llvm-svn: 343603
2018-10-02 16:43:52 +00:00
Francois Ferrand 6f40e21a16 clang-format: better handle statement macros
Summary:
Some macros are used in the body of function, and actually contain the trailing semicolon: they should thus be automatically followed by a new line, and not get merged with the next line. This is for example the case with Qt's Q_UNUSED macro:

  void foo(int a, int b) {
    Q_UNUSED(a)
    return b;
  }

This patch deals with these cases by introducing a new option to specify list of statement macros. This re-uses the system already in place for foreach macros, to ensure there is no impact on performance.

Reviewers: krasimir, djasper, klimek

Reviewed By: krasimir

Subscribers: acoomans, mgrang, alexfh, klimek, cfe-commits

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

llvm-svn: 343602
2018-10-02 16:37:51 +00:00
Kristina Brooks 59500f7a0b [Arm builtins] Remove non-necessary IS check
This patch removes the instruction set check to make the msr APSR_nzcvq,
ip instruction only execute if Thumb2 is used.
The APSR is a subset of the bits of the CPSR
(B.1.3.3 of the Arm v7 A and R ARM [1]) and is only available for A and
R profiles.
However in section B.9.3.11 of the same document we see that:

"In the A and R profiles, APSR_nzcvq is the same as CPSR_f"
"ARM recommends the APSR forms when only the N, Z, C, V, Q, and GE[3:0]
bits are being written."

This patch also make those files assemble for Armv8-M Mainline
architecture profile.

The builtins were cross-compiled for Arm, Aarch64 and Armv6-M, Armv7-M
and Armv7E-M targets.
Cross-compiled tests were executed for Arm target.

[1]: https://developer.arm.com/docs/ddi0406/latest/arm-architecture-reference-manual-armv7-a-and-armv7-r-edition

Patch by hug-dev (Hugues de Valon).

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

llvm-svn: 343601
2018-10-02 16:32:32 +00:00
Jessica Paquette 9cfc8eca70 Revert "[sanitizer] Include inlined frames into __sanitizer_symbolize_pc output"
This reverts r343554.

It was breaking some bots:
http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA/49997/

llvm-svn: 343600
2018-10-02 16:28:52 +00:00
Stephen Hines 80e7d65a42 [sanitizer] Use -Wl,-z,global on Android for sanitizers except UBsan
Summary:
This essentially reverts r337010 since it breaks UBSan, which is used
for a few platform libraries. The "-z global" flag is now added for
Scudo as well. The only other sanitizer shared libraries are for asan
and hwasan, which have also been reinstated to use the global flag.

Reviewers: cryptoad, eugenis

Reviewed By: cryptoad

Subscribers: kubamracek, mgorny, delcypher, #sanitizers, nickdesaulniers, chh, kongyi, pirama, llvm-commits

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

llvm-svn: 343599
2018-10-02 16:19:42 +00:00
Simon Pilgrim 860cb5c071 [X86][Btver2] Fix BLENDV and AESDEC schedules
Match AMD Fam16h SOG + llvm-exegesis tests

llvm-svn: 343597
2018-10-02 15:13:18 +00:00
Krzysztof Parzyszek 528aff3372 [Hexagon] Fix extracting subvectors of non-HVX vNi1
Patch by Brendon Cahoon.

llvm-svn: 343596
2018-10-02 15:05:43 +00:00
Sanjay Patel e2cd6384b7 [InstCombine] add tests with undef elements; NFC
See discussion in D52747.

llvm-svn: 343595
2018-10-02 15:00:56 +00:00
Diogo N. Sampaio eb9ca5ab18 [ARM] Emmit data symbol for constant pool data
The ARM elf emitter would omit printing data
symbol when constant data. This patch
overrides the emitFill method as to enforce that
the symbol is correctly printed.

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

llvm-svn: 343594
2018-10-02 14:55:48 +00:00
Haojian Wu 1c6b6deb33 [clangd] Add a #include completion test that triggers an assertion.
Summary: Test for https://reviews.llvm.org/D52774.

Reviewers: sammccall

Reviewed By: sammccall

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

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

llvm-svn: 343593
2018-10-02 14:46:08 +00:00
Haojian Wu 714e971540 [Preprocesssor] Filename should fall back to the written name when typo correction fails.
Summary:
The test is added in  Testcase is at https://reviews.llvm.org/D52775. I tried to add the test to clang's code
completion test, it doesn't reproduce the crash.

Reviewers: sammccall, kristina

Reviewed By: sammccall

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

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

llvm-svn: 343592
2018-10-02 14:42:51 +00:00
Haojian Wu dea577191c [Preprocessor] Hide include typo correction behind SpellChecking.
Summary:
Similar to Sema typo correction, the Preprocessor typo correction should
also be hidden behind the SpellChecking flag.

Reviewers: sammccall

Subscribers: cfe-commits

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

llvm-svn: 343591
2018-10-02 13:59:49 +00:00
Sam McCall 51be55d0ec [clangd] Zap TODONEs
llvm-svn: 343590
2018-10-02 13:51:43 +00:00
Sam McCall a1e7385d5c [clangd] Dex: add Corpus factory for iterators, rename, fold constant. NFC
Summary:
- Corpus avoids having to pass size to the true iterator, and (soon) any
  iterator that might optimize down to true.
- Shorten names of factory functions now they're scoped to the Corpus.
  intersect() and unionOf() rather than createAnd() or createOr() as this
  seems to read better to me, and fits with other short names. Opinion wanted!
- DEFAULT_BOOST_SCORE --> 1. This is a multiplier, don't obfuscate identity.
- Simplify variadic templates in Iterator.h

Reviewers: ioeric

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

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

llvm-svn: 343589
2018-10-02 13:44:26 +00:00
Roman Lebedev ea2046bea9 [NFC][CodeGen][X86] fma.ll, lwp-intrinsics.ll: actually spell --check-prefixes correctly :/
llvm-svn: 343588
2018-10-02 13:34:50 +00:00
Sanjay Patel 6dbecb4162 [InstCombine] add more insert/extract vector tests with FP types; NFC
These are candidates for the same fold that was implemented in
D52439, but FP types require bitcasting (and that changes the
extra uses profitability calculation).

llvm-svn: 343587
2018-10-02 13:34:05 +00:00
Simon Pilgrim 201bbe3993 [X86] Remove unnecessary BT(C/R/S)m(i/r) scheduler overrides
Some SchedAlias remain due to some badly setup RMW tags - but at least the overrides are all removed

llvm-svn: 343586
2018-10-02 13:11:59 +00:00
Roman Lebedev 5412be4b7a [NFC][CodeGen][X86] lwp-intrinsics.ll: fix check prefixes
llvm-svn: 343585
2018-10-02 13:11:08 +00:00
Roman Lebedev 8b253f0b54 [NFC][CodeGen][X86] fma.ll: fix check prefixes for -mcpu=bdver2
llvm-svn: 343584
2018-10-02 13:10:55 +00:00
Sven van Haastregt a3c6b407ec [OpenCL] Add block argument CodeGen test
r326937 ("[OpenCL] Remove block invoke function from emitted block
literal struct", 2018-03-07) broke block argument handling.  In
particular the commit was causing a crash during code generation, see
the discussion in https://reviews.llvm.org/D43783 .

The offending commit has just been reverted; add a test to avoid
breaking this again in the future.

llvm-svn: 343583
2018-10-02 13:02:27 +00:00
Sven van Haastregt da3b632057 Revert r326937 "[OpenCL] Remove block invoke function from emitted block literal struct"
This reverts r326937 as it broke block argument handling in OpenCL.
See the discussion on https://reviews.llvm.org/D43783 .

The next commit will add a test case that revealed the issue.

llvm-svn: 343582
2018-10-02 13:02:24 +00:00
Mikhail R. Gadelha 32ce136e80 [analyzer] Improvements to the SMT API
Summary:
Several improvements in preparation for the new backends.

Refactoring:

- Removed duplicated methods `fromBoolean`, `fromAPSInt`, `fromInt` and `fromAPFloat`. The methods `mkBoolean`, `mkBitvector` and `mkFloat` are now used instead.
- The names of the functions that convert BVs to FPs were swapped (`mkSBVtoFP`, `mkUBVtoFP`, `mkFPtoSBV`, `mkFPtoUBV`).
- Added a couple of comments in function calls.

Crosscheck encoding:

- Changed how constraints are encoded in the refutation manager so it doesn't start with (false OR ...). This change introduces one duplicated line (see file `BugReporterVisitors.cpp`, the `SMTConv::getRangeExpr is called twice, so I can remove this change if the duplication is a problem.

Reviewers: george.karpenkov, NoQ

Reviewed By: george.karpenkov

Subscribers: xazax.hun, szepet, a.sidorin, Szelethus

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

llvm-svn: 343581
2018-10-02 12:55:48 +00:00
Sam McCall 7402836042 [clangd] Dex iterator printer shows query structure, not iterator state.
Summary:
This makes it suitable for logging (which immediately found a bug, to
be fixed in the next patch...)

Reviewers: ioeric

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

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

llvm-svn: 343580
2018-10-02 11:51:36 +00:00
Bruno Ricci 26a2536f8b [AST] Pack the bit-fields of FunctionProtoType into Type.
Move the bit-fields of FunctionProtoType into FunctionTypeBitfields.
This cuts the size of FunctionProtoType by a pointer. Additionally use
llvm::TrailingObjects instead of manually doing the casts + arithmetic.

This patch is bigger then what could be expected for the following reasons:

1. As discussed before in D50631 it would be nice if there was some space left
   in FunctionTypeBitfields for future additions. This patch introduces an
   extra structure FunctionTypeExtraBitfields which is supposed to hold
   uncommon bits and is stored in a trailing object. The number of exception
   types NumExceptions is moved to this struct. As of this patch this trailing
   struct will only be allocated if we have > 0 types in a dynamic exception
   specification.

2. TrailingObjects cannot handle repeated types. Therefore the QualType
   representing an exception type is wrapped in a struct ExceptionType.
   The ExceptionType * is then reinterpret_cast'd to QualType *.

3. TrailingObjects needs the definition of the various trailing classes.
   Therefore ExtParameterInfo, ExceptionType and FunctionTypeExtraBitfields
   are put in FunctionType.

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

Reviewed By: rjmccall

llvm-svn: 343579
2018-10-02 11:46:38 +00:00
Alexander Kornienko c5016c0a27 [clang-tidy] Ignore singe bit bitfield -> bool conversion in readability-implicit-bool-conversion
llvm-svn: 343578
2018-10-02 11:38:41 +00:00
Simon Pilgrim 271bcb9397 [X86] Add APInt constant assembly printer helper
llvm-svn: 343577
2018-10-02 11:32:33 +00:00