platform/upstream/llvm.git
6 years ago[WebAssembly] Add test for `--undefined` flag. NFC.
Sam Clegg [Wed, 28 Feb 2018 01:42:16 +0000 (01:42 +0000)]
[WebAssembly] Add test for `--undefined` flag. NFC.

Specifically the case where the undefined symbol is not found
during the link.

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

llvm-svn: 326294

6 years ago[WebAssembly] Simplify Symbol::getWasmType. NFC.
Rui Ueyama [Wed, 28 Feb 2018 01:10:50 +0000 (01:10 +0000)]
[WebAssembly] Simplify Symbol::getWasmType. NFC.

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

llvm-svn: 326293

6 years ago[StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use warnings...
Eugene Zelenko [Wed, 28 Feb 2018 01:10:04 +0000 (01:10 +0000)]
[StaticAnalyzer] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).

llvm-svn: 326292

6 years ago[WebAssembly] Inline translateVA as it's trivial.
Rui Ueyama [Wed, 28 Feb 2018 01:01:34 +0000 (01:01 +0000)]
[WebAssembly] Inline translateVA as it's trivial.

The problem I want to address now is that chunks have too many data
members for "offsets", and their origins are not well defined.
For example, InputSegment has OutputSegmentOffset, but it's base class
also has OutputOffset. That's very confusing.

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

llvm-svn: 326291

6 years ago[RuntimeDyld][MachO] Support ARM64_RELOC_BRANCH26 for BL instructions by
Lang Hames [Wed, 28 Feb 2018 00:58:21 +0000 (00:58 +0000)]
[RuntimeDyld][MachO] Support ARM64_RELOC_BRANCH26 for BL instructions by
relaxing an assertion.

llvm-svn: 326290

6 years ago[WebAssembly] Remove ELF-ness.
Rui Ueyama [Wed, 28 Feb 2018 00:57:28 +0000 (00:57 +0000)]
[WebAssembly] Remove ELF-ness.

These output section names are ELF-specific. We shouldn't have this rule
for WebAssembly.

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

llvm-svn: 326289

6 years agoupdate_mir_test_checks: Use the regexes from UpdateTestChecks.common
Justin Bogner [Wed, 28 Feb 2018 00:56:24 +0000 (00:56 +0000)]
update_mir_test_checks: Use the regexes from UpdateTestChecks.common

Some of the update_*_test_checks regexes have been moved into a
library, so we might as well use them in update_mir_test_checks.
Also includes minor bugfixes to the regexes that are there so we
don't regress update_mir_test_checks

llvm-svn: 326288

6 years ago[ELF] Rename test/ELF/note-loadaddr.c to .s NFC
Fangrui Song [Wed, 28 Feb 2018 00:53:51 +0000 (00:53 +0000)]
[ELF] Rename test/ELF/note-loadaddr.c to .s NFC

llvm-svn: 326287

6 years ago[WebAssembly] Do not use inheritance to define SubSection.
Rui Ueyama [Wed, 28 Feb 2018 00:52:42 +0000 (00:52 +0000)]
[WebAssembly] Do not use inheritance to define SubSection.

SubSection inherited from SyntheticSection, and SyntheticSection inherits
from OutputSection, so SubSection was an OutputSection. But that's wrong
because SubSection is not actually a WebAssembly output section.
It shares some functionalities with OutputSection, but overall it's very
different.

This patch removes that inheritance.

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

llvm-svn: 326286

6 years ago[WebAssembly] Refactor ObjFile::initializeSymbols.
Rui Ueyama [Wed, 28 Feb 2018 00:50:54 +0000 (00:50 +0000)]
[WebAssembly] Refactor ObjFile::initializeSymbols.

The main purpose of this change is to make initializeSymbols shorter.

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

llvm-svn: 326285

6 years agoupdate_mir_test_checks: Drop support for vreg block checks
Justin Bogner [Wed, 28 Feb 2018 00:44:46 +0000 (00:44 +0000)]
update_mir_test_checks: Drop support for vreg block checks

Since vregs are printed in the instruction stream now, checking the
vreg block is always redundant. Remove the temporary feature that
allowed us to do that.

This reverts r316134

llvm-svn: 326284

6 years ago[WebAssembly] Do not use Subsection as a local variable name.
Rui Ueyama [Wed, 28 Feb 2018 00:39:30 +0000 (00:39 +0000)]
[WebAssembly] Do not use Subsection as a local variable name.

That variable hides the class of the same name.

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

llvm-svn: 326283

6 years ago[WebAssembly] Do not use default arguments for SymbolTable.
Rui Ueyama [Wed, 28 Feb 2018 00:37:03 +0000 (00:37 +0000)]
[WebAssembly] Do not use default arguments for SymbolTable.

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

llvm-svn: 326282

6 years ago[WebAssembly] Do not remove existing output file.
Rui Ueyama [Wed, 28 Feb 2018 00:33:59 +0000 (00:33 +0000)]
[WebAssembly] Do not remove existing output file.

FileOutputBuffer automatically removes an existing file, so we don't
need to do that. Actually doing that is discouraged because when the
linker fails to create an output for some reason after instantiating
FileOutputBufffer, FileOutputBuffer removes a temporary file and don't
touch an existing file. That's an desired behavior from the user's
point of view.

(Internally, FileOutputBuffer writes its contents to a temporary file
and then rename it over to an existing file on commit()).

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

llvm-svn: 326281

6 years ago[WebAssembly] Remove redundant local variables.
Rui Ueyama [Wed, 28 Feb 2018 00:31:16 +0000 (00:31 +0000)]
[WebAssembly] Remove redundant local variables.

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

llvm-svn: 326280

6 years ago[WebAssembly] Simplify createLikingSection.
Rui Ueyama [Wed, 28 Feb 2018 00:28:07 +0000 (00:28 +0000)]
[WebAssembly] Simplify createLikingSection.

Summary: [WebAssembly] Simplify createLikingSection.

Reviewers: sbc100

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

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

llvm-svn: 326279

6 years agoAMDGPU: Move run and check lines around to match processor order in AMDGPU.h
Konstantin Zhuravlyov [Wed, 28 Feb 2018 00:27:00 +0000 (00:27 +0000)]
AMDGPU: Move run and check lines around to match processor order in AMDGPU.h

llvm-svn: 326278

6 years ago[WebAssembly] Inline accessor functions that are called only once.
Rui Ueyama [Wed, 28 Feb 2018 00:26:26 +0000 (00:26 +0000)]
[WebAssembly] Inline accessor functions that are called only once.

Looks like these accessor functions are a bit overly defensive, and
due to the amount of code, that part isn't easy to read. We have
code to log translation results in writeTo and writeRelocations, so
I don't think we need to log it again in these functions.
I think the new function is much easier to understand.

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

llvm-svn: 326277

6 years ago[WebAssembly] Remove trivial accessors.
Rui Ueyama [Wed, 28 Feb 2018 00:20:29 +0000 (00:20 +0000)]
[WebAssembly] Remove trivial accessors.

{set,get}OutputSegment don't hide anything, so remove them.

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

llvm-svn: 326276

6 years ago[WebAssembly] Use more specific type and simplify code.
Rui Ueyama [Wed, 28 Feb 2018 00:18:34 +0000 (00:18 +0000)]
[WebAssembly] Use more specific type and simplify code.

Instead of {Function,Global,Data}Symbol, use Defined{Function,Global,Data}
because undefined symbol should never reach this function.

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

llvm-svn: 326275

6 years ago[WebAssembly] Remove LastDefinedKind for consistency with undefined kinds. NFC.
Rui Ueyama [Wed, 28 Feb 2018 00:16:11 +0000 (00:16 +0000)]
[WebAssembly] Remove LastDefinedKind for consistency with undefined kinds. NFC.

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

llvm-svn: 326274

6 years ago[WebAssembly] Remove premature optimization.
Rui Ueyama [Wed, 28 Feb 2018 00:15:59 +0000 (00:15 +0000)]
[WebAssembly] Remove premature optimization.

I think calling reserve() for each object file is too many and isn't useful.
We can add reserve() later. By default, we shouldn't add reserve() to a lot
of places.

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

llvm-svn: 326273

6 years agoInline trivial function. NFC.
Rafael Espindola [Wed, 28 Feb 2018 00:14:18 +0000 (00:14 +0000)]
Inline trivial function. NFC.

llvm-svn: 326272

6 years ago[WebAssembly] Separate addUndefined into addUndefined{Function,Data,Global}.
Rui Ueyama [Wed, 28 Feb 2018 00:09:22 +0000 (00:09 +0000)]
[WebAssembly] Separate addUndefined into addUndefined{Function,Data,Global}.

Previously, one function adds all types of undefined symbols. That
doesn't fit to the wasm's undefined symbol semantics well because
different types of undefined symbols are very different in wasm.
As a result, separate control flows merge in this addUndefined function
and then separate again for each type. That wasn't easy to read.

This patch separates the function into three functions. Now it is pretty
clear what we are doing for each undefined symbol type.

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

llvm-svn: 326271

6 years agoPass a GlobalDecl to setAliasAttributes. NFC.
Rafael Espindola [Wed, 28 Feb 2018 00:06:01 +0000 (00:06 +0000)]
Pass a GlobalDecl to setAliasAttributes. NFC.

This just makes a followup change easier to read.

llvm-svn: 326270

6 years ago[WebAssembly] Use StringRef instead of `const char *`.
Rui Ueyama [Wed, 28 Feb 2018 00:01:31 +0000 (00:01 +0000)]
[WebAssembly] Use StringRef instead of `const char *`.

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

llvm-svn: 326269

6 years ago[WebAssembly] Remove DataSize from linking metadata
Sam Clegg [Tue, 27 Feb 2018 23:58:03 +0000 (23:58 +0000)]
[WebAssembly] Remove DataSize from linking metadata

This means we don't need to write the linking metadata section
at all for executable (non-relocatable) output.

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

llvm-svn: 326268

6 years ago[WebAssembly] Remove DataSize from linking metadata section
Sam Clegg [Tue, 27 Feb 2018 23:57:37 +0000 (23:57 +0000)]
[WebAssembly] Remove DataSize from linking metadata section

Neither the linker nor the runtime need this information
anymore.  We were originally using this to model BSS size
but the plan is now to use the segment metadata to allow
for BSS segments.

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

llvm-svn: 326267

6 years agoImprove the way attribute argument printing happens for omitted optional arguments...
Aaron Ballman [Tue, 27 Feb 2018 23:49:28 +0000 (23:49 +0000)]
Improve the way attribute argument printing happens for omitted optional arguments when pretty printing.

Patch by Joel Denny.

llvm-svn: 326266

6 years agoPass a GlobalDecl to setFunctionDefinitionAttributes. NFC.
Rafael Espindola [Tue, 27 Feb 2018 23:44:36 +0000 (23:44 +0000)]
Pass a GlobalDecl to setFunctionDefinitionAttributes. NFC.

This just makes a followup patch easier to read.

llvm-svn: 326265

6 years agoFix lldbinline tests for remote targets
Pavel Labath [Tue, 27 Feb 2018 22:45:49 +0000 (22:45 +0000)]
Fix lldbinline tests for remote targets

r326140 exposed the fact that we are not actually running inline tests on
remote targets. The tests fail to launch the inferior in the first place
because they passed an invalid working directory to the launch function.

This should fix that.

llvm-svn: 326264

6 years ago[Hexagon] Recognize more sign-extensions as inputs to 32x32-bit multiply
Krzysztof Parzyszek [Tue, 27 Feb 2018 22:44:41 +0000 (22:44 +0000)]
[Hexagon] Recognize more sign-extensions as inputs to 32x32-bit multiply

llvm-svn: 326263

6 years ago[Pipeliner] Drop memrefs instead of creating ones with size UINT64_MAX
Krzysztof Parzyszek [Tue, 27 Feb 2018 22:40:52 +0000 (22:40 +0000)]
[Pipeliner] Drop memrefs instead of creating ones with size UINT64_MAX

Absence of memory operands is treated as "aliasing everything", so
dropping them is sufficient.

Recommit r326256 with a fixed testcase.

llvm-svn: 326262

6 years ago[lldb] Use vFlash commands when writing to target's flash memory regions
Pavel Labath [Tue, 27 Feb 2018 22:14:33 +0000 (22:14 +0000)]
[lldb] Use vFlash commands when writing to target's flash memory regions

Summary:
When writing an object file over gdb-remote, use the vFlashErase, vFlashWrite, and vFlashDone commands if the write address is in a flash memory region.  A bare metal target may have this kind of setup.

- Update ObjectFileELF to set load addresses using physical addresses.  A typical case may be a data section with a physical address in ROM and a virtual address in RAM, which should be loaded to the ROM address.
- Add support for querying the target's qXfer:memory-map, which contains information about flash memory regions, leveraging MemoryRegionInfo data structures with minor modifications
- Update ProcessGDBRemote to use vFlash commands in DoWriteMemory when the target address is in a flash region

Original discussion at http://lists.llvm.org/pipermail/lldb-dev/2018-January/013093.html

Reviewers: clayborg, labath

Reviewed By: labath

Subscribers: arichardson, emaste, mgorny, lldb-commits

Differential Revision: https://reviews.llvm.org/D42145
Patch by Owen Shaw <llvm@owenpshaw.net>

llvm-svn: 326261

6 years ago[CodeView] Lower __restrict and other pointer qualifiers correctly
Reid Kleckner [Tue, 27 Feb 2018 22:08:15 +0000 (22:08 +0000)]
[CodeView] Lower __restrict and other pointer qualifiers correctly

Qualifiers on a pointer or reference type may apply to either the
pointee or the pointer itself. Consider 'const char *' and 'char *
const'. In the first example, the pointee data may not be modified
without casts, and in the second example, the pointer may not be updated
to point to new data.

In the general case, qualifiers are applied to types with LF_MODIFIER
records, which support the usual const and volatile qualifiers as well
as the __unaligned extension qualifier.

However, LF_POINTER records, which are used for pointers, references,
and member pointers, have flags for qualifiers applying to the
*pointer*. In fact, this is the only way to represent the restrict
qualifier, which can only apply to pointers, and cannot qualify regular
data types.

This patch causes LLVM to correctly fold 'const' and 'volatile' pointer
qualifiers into the pointer record, as well as adding support for
'__restrict' qualifiers in the same place.

Based on a patch from Aaron Smith

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

llvm-svn: 326260

6 years agoRevert "[Pipeliner] Drop memrefs instead of creating ones with size UINT64_MAX"
Krzysztof Parzyszek [Tue, 27 Feb 2018 22:07:38 +0000 (22:07 +0000)]
Revert "[Pipeliner] Drop memrefs instead of creating ones with size UINT64_MAX"

This reverts r326256. One testcase needs to be updated.

llvm-svn: 326259

6 years ago[analyzer] UndefinedAssignmentChecker: Better warning message in implicit ctors.
Artem Dergachev [Tue, 27 Feb 2018 22:05:55 +0000 (22:05 +0000)]
[analyzer] UndefinedAssignmentChecker: Better warning message in implicit ctors.

When a class forgets to initialize a field in the constructor, and then gets
copied around, a warning is emitted that the value assigned to a specific field
is undefined.

When the copy/move constructor is implicit (not written out in the code) but not
trivial (is not a trivial memory copy, eg. because members have an explicit copy
constructor), the body of such constructor is auto-generated in the AST.
In this case the checker's warning message is squeezed at the top of
the class declaration, and it gets hard to guess which field is at fault.

Fix the warning message to include the name of the field.

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

llvm-svn: 326258

6 years ago[ELF] Add llvm-readelf to the lit tool substitutions
Alexander Richardson [Tue, 27 Feb 2018 22:01:02 +0000 (22:01 +0000)]
[ELF] Add llvm-readelf to the lit tool substitutions

Summary:
Some of the tests invoke llvm-readelf. This currently appears to work
probably because the LLVM binary directory is included in $PATH. However,
this is quite fragile so let's just make lit expand the full path.

Reviewers: ruiu, espindola

Reviewed By: ruiu

Subscribers: llvm-commits

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

llvm-svn: 326257

6 years ago[Pipeliner] Drop memrefs instead of creating ones with size UINT64_MAX
Krzysztof Parzyszek [Tue, 27 Feb 2018 22:00:32 +0000 (22:00 +0000)]
[Pipeliner] Drop memrefs instead of creating ones with size UINT64_MAX

Absence of memory operands is treated as "aliasing everything", so
dropping them is sufficient.

llvm-svn: 326256

6 years ago[AsmPrinter] Handle qualified unnamed types in CodeView printer
Shoaib Meenai [Tue, 27 Feb 2018 21:48:41 +0000 (21:48 +0000)]
[AsmPrinter] Handle qualified unnamed types in CodeView printer

When attempting to compile the following Objective-C++ code with
CodeView debug info:

  void (^b)(void) = []() {};

The generated debug metadata contains a structure like the following:

  !43 = !DICompositeType(tag: DW_TAG_structure_type, name: "__block_literal_1", scope: !6, file: !6, line: 1, size: 168, elements: !44)
  !44 = !{!45, !46, !47, !48, !49, !52}
  ...
  !52 = !DIDerivedType(tag: DW_TAG_member, scope: !6, file: !6, line: 1, baseType: !53, size: 8, offset: 160, flags: DIFlagPublic)
  !53 = !DIDerivedType(tag: DW_TAG_const_type, baseType: !54)
  !54 = !DICompositeType(tag: DW_TAG_class_type, file: !6, line: 1, flags: DIFlagFwdDecl)

Note that the member node (!52) is unnamed, but rather than pointing to
a DICompositeType directly, it points to a DIDerivedType with tag
DW_TAG_const_type, which then points to the DICompositeType. However,
the CodeView assembly printer currently assumes that the base type for
an unnamed member will always be a DICompositeType, and attempts to
perform that cast, which triggers an assertion failure, since in this
case the base type is actually a DIDerivedType, not a DICompositeType
(and we would have to get the base type of the DIDerivedType to reach
the DICompositeType). I think the debug metadata being generated by the
frontend is correct (or at least plausible), and the CodeView printer
needs to handle this case.

This patch teaches the CodeView printer to unwrap any qualifier types.
The qualifiers are just dropped for now. Ideally, they would be applied
to the added indirect members instead, but this occurs infrequently
enough that adding the logic to handle the qualifiers correctly isn't
worth it for now. A FIXME is added to note this.

Additionally, Reid pointed out that the underlying assumption that an
unnamed member must be a composite type is itself incorrect and may not
hold for all frontends. Therefore, after all qualifiers have been
stripped, check if the resulting type is in fact a DICompositeType and
just return if it isn't, rather than assuming the type and crashing if
that assumption is violated.

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

llvm-svn: 326255

6 years agoAMDGPU: Define FP_FAST_FMA{F} macros for amdgcn
Konstantin Zhuravlyov [Tue, 27 Feb 2018 21:48:05 +0000 (21:48 +0000)]
AMDGPU: Define FP_FAST_FMA{F} macros for amdgcn

- Expand GK_*s (i.e. GFX6 -> GFX600, GFX601, etc.)
  - This allows us to choose features correctly in some cases (for example, fast fmaf is available on gfx600, but not gfx601)
- Move HasFMAF, HasFP64, HasLDEXPF to GPUInfo tables
- Add HasFastFMA, HasFastFMAF to GPUInfo tables
- Add missing tests

llvm-svn: 326254

6 years ago[codeview] Remove unused variable
Reid Kleckner [Tue, 27 Feb 2018 21:46:40 +0000 (21:46 +0000)]
[codeview] Remove unused variable

llvm-svn: 326253

6 years agoAMDGPU: Add fast fmaf feature to gfx702
Konstantin Zhuravlyov [Tue, 27 Feb 2018 21:46:15 +0000 (21:46 +0000)]
AMDGPU: Add fast fmaf feature to gfx702

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

llvm-svn: 326252

6 years ago[OPENMP] Emit warning for non-trivial types in map clauses.
Alexey Bataev [Tue, 27 Feb 2018 21:31:11 +0000 (21:31 +0000)]
[OPENMP] Emit warning for non-trivial types in map clauses.

If the mapped type is non-trivial, the warning message is emitted for
better user experience.

llvm-svn: 326251

6 years ago[libunwind][MIPS]: Add support for unwinding in N32 processes.
John Baldwin [Tue, 27 Feb 2018 21:24:02 +0000 (21:24 +0000)]
[libunwind][MIPS]: Add support for unwinding in N32 processes.

Summary:
N32 uses the same register context as N64.  However, N32 requires one
change to properly fetch addresses from registers stored in memory.
Since N32 is an ILP32 platform, getP() only fetches the first 32-bits
of a stored register.  For a big-endian platform this fetches the
upper 32-bits which will be zero.  To fix this, add a new
getRegister() method to AddressSpace which is responsible for
extracting the address stored in a register in memory.  This matches
getP() for all current ABIs except for N32 where it reads the 64-bit
register and returns the low 32-bits as an address.  The
DwarfInstructions::getSavedRegister() method uses
AddressSpace::getRegister() instead of AddressSpace::getP().

Reviewers: sdardis, compnerd

Reviewed By: sdardis

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

llvm-svn: 326250

6 years ago[analyzer] MallocChecker: Suppress false positives in shared pointers.
Artem Dergachev [Tue, 27 Feb 2018 21:19:33 +0000 (21:19 +0000)]
[analyzer] MallocChecker: Suppress false positives in shared pointers.

Throw away MallocChecker warnings that occur after releasing a pointer within a
destructor (or its callees) after performing C11 atomic fetch_add or fetch_sub
within that destructor (or its callees).

This is an indication that the destructor's class is likely a
reference-counting pointer. The analyzer is not able to understand that the
original reference count is usually large enough to avoid most use-after-frees.

Even when the smart pointer is a local variable, we still have these false
positives that this patch suppresses, because the analyzer doesn't currently
support atomics well enough.

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

llvm-svn: 326249

6 years ago[llvm-cvtres] Update the help test after SVN r326244.
Martin Storsjo [Tue, 27 Feb 2018 21:11:03 +0000 (21:11 +0000)]
[llvm-cvtres] Update the help test after SVN r326244.

llvm-svn: 326248

6 years ago[analyzer] Fix trivial copy for empty objects.
Artem Dergachev [Tue, 27 Feb 2018 21:10:08 +0000 (21:10 +0000)]
[analyzer] Fix trivial copy for empty objects.

The SVal for any empty C++ object is an UnknownVal. Because RegionStore does
not have binding extents, binding an empty object to an UnknownVal may
potentially overwrite existing bindings at the same offset.

Therefore, when performing a trivial copy of an empty object, don't try to
take the value of the object and bind it to the copy. Doing nothing is accurate
enough, and it doesn't screw any existing bindings.

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

llvm-svn: 326247

6 years ago[analyzer] Track temporaries without construction contexts for destruction.
Artem Dergachev [Tue, 27 Feb 2018 21:02:58 +0000 (21:02 +0000)]
[analyzer] Track temporaries without construction contexts for destruction.

Sometimes it is not known at compile time which temporary objects will be
constructed, eg. 'x ? A() : B()' or 'C() || D()'. In this case we track which
temporary was constructed to know how to properly call the destructor.

Once the construction context for temporaries was introduced, we moved the
tracking code to the code that investigates the construction context.

Bring back the old mechanism because construction contexts are not always
available yet - eg. in the case where a temporary is constructed without a
constructor expression, eg. returned from a function by value. The mechanism
should still go away eventually.

Additionally, fix a bug in the temporary cleanup code for the case when
construction contexts are not available, which could lead to temporaries
staying in the program state and increasing memory consumption.

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

llvm-svn: 326246

6 years ago[analyzer] Don't crash when dynamic type of a variable is set via placement new.
Artem Dergachev [Tue, 27 Feb 2018 20:54:40 +0000 (20:54 +0000)]
[analyzer] Don't crash when dynamic type of a variable is set via placement new.

If a variable or an otherwise a concrete typed-value region is being
placement-new'ed into, its dynamic type may change in arbitrary manners. And
when the region is used, there may be a third type that's different from both
the static and the dynamic type. It cannot be *completely* different from the
dynamic type, but it may be a base class of the dynamic type - and in this case
there isn't (and shouldn't be) any indication anywhere in the AST that there is
a derived-to-base cast from the dynamic type to the third type.

Perform a generic cast (evalCast()) from the third type to the dynamic type
in this case. From the point of view of the SVal hierarchy, this would have
produced non-canonical SVals if we used such generic cast in the normal case,
but in this case there doesn't seem to be a better option.

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

llvm-svn: 326245

6 years agollvm-cvtres: Mention ARM64 as a supported machine type in the help text. NFC.
Martin Storsjo [Tue, 27 Feb 2018 20:44:33 +0000 (20:44 +0000)]
llvm-cvtres: Mention ARM64 as a supported machine type in the help text. NFC.

llvm-svn: 326244

6 years agoAdd `--dynamic-linker=foo` as an alias for `--dynamic-linker foo`.
Rui Ueyama [Tue, 27 Feb 2018 20:37:18 +0000 (20:37 +0000)]
Add `--dynamic-linker=foo` as an alias for `--dynamic-linker foo`.

This patch fixes a minor compatibility issue with ld.gold and ld.bfd.

llvm-svn: 326243

6 years agoPut undefined symbols from shared libraries in the symbol table.
Rafael Espindola [Tue, 27 Feb 2018 20:31:22 +0000 (20:31 +0000)]
Put undefined symbols from shared libraries in the symbol table.

With the recent fixes these symbols have more in common than not with
regular undefined symbols.

llvm-svn: 326242

6 years ago[InstSimplify] add tests for FP with undef operand; NFC
Sanjay Patel [Tue, 27 Feb 2018 20:17:18 +0000 (20:17 +0000)]
[InstSimplify] add tests for FP with undef operand; NFC

Are any of these correct?

llvm-svn: 326241

6 years ago[analyzer] Disable constructor inlining when lifetime extending through a field.
Artem Dergachev [Tue, 27 Feb 2018 20:14:06 +0000 (20:14 +0000)]
[analyzer] Disable constructor inlining when lifetime extending through a field.

Automatic destructors are missing in the CFG in situations like

  const int &x = C().x;

For now it's better to disable construction inlining, because inlining
constructors while doing nothing on destructors is very bad.

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

llvm-svn: 326240

6 years ago[analyzer] Self-debug: Dump dynamic type info and taint with the program state.
Artem Dergachev [Tue, 27 Feb 2018 20:06:20 +0000 (20:06 +0000)]
[analyzer] Self-debug: Dump dynamic type info and taint with the program state.

Useful for debugging problems with dynamic type info and taint.

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

llvm-svn: 326239

6 years ago[CFG] NFC: Refactor ConstructionContext into a finite set of cases.
Artem Dergachev [Tue, 27 Feb 2018 20:03:35 +0000 (20:03 +0000)]
[CFG] NFC: Refactor ConstructionContext into a finite set of cases.

ConstructionContext is moved into a separate translation unit and is separated
into multiple classes. The "old" "raw" ConstructionContext is renamed into
ConstructionContextLayer - which corresponds to the idea of building the context
gradually layer-by-layer, but it isn't easy to use in the clients. Once
CXXConstructExpr is reached, layers that we've gathered so far are transformed
into the actual, "new-style" "flat" ConstructionContext, which is put into the
CFGConstructor element and has no layers whatsoever (until it actually needs
them, eg. aggregate initialization). The new-style ConstructionContext is
instead presented as a variety of sub-classes that enumerate different ways of
constructing an object in C++. There are 5 of these supported for now,
which is around a half of what needs to be supported.

The layer-by-layer buildup process is still a little bit weird, but it hides
all the weirdness in one place, that sounds like a good thing.

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

llvm-svn: 326238

6 years ago[ValueTracking] Teach cannotBeOrderedLessThanZeroImpl to look through ExtractElement.
Craig Topper [Tue, 27 Feb 2018 19:53:45 +0000 (19:53 +0000)]
[ValueTracking] Teach cannotBeOrderedLessThanZeroImpl to look through ExtractElement.

This is similar to what's done in computeKnownBits and computeSignBits. Don't do anything fancy just collect information valid for any element.

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

llvm-svn: 326237

6 years ago[analyzer] Introduce correct lifetime extension behavior in simple cases.
Artem Dergachev [Tue, 27 Feb 2018 19:47:49 +0000 (19:47 +0000)]
[analyzer] Introduce correct lifetime extension behavior in simple cases.

This patch uses the reference to MaterializeTemporaryExpr stored in the
construction context since r326014 in order to model that expression correctly.

When modeling MaterializeTemporaryExpr, instead of copying the raw memory
contents from the sub-expression's rvalue to a completely new temporary region,
that we conjure up for the lack of better options, we now have the better
option to recall the region into which the object was originally constructed
and declare that region to be the value of the expression, which is semantically
correct.

This only works when the construction context is available, which is worked on
independently.

The temporary region's liveness (in the sense of removeDeadBindings) is extended
until the MaterializeTemporaryExpr is resolved, in order to keep the store
bindings around, because it wouldn't be referenced from anywhere else in the
program state.

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

llvm-svn: 326236

6 years ago[MinGW, CrossWindows] Allow passing -static together with -shared
Martin Storsjo [Tue, 27 Feb 2018 19:42:19 +0000 (19:42 +0000)]
[MinGW, CrossWindows] Allow passing -static together with -shared

In these combinations, link a DLL as usual, but pass -Bstatic instead
of -Bdynamic to indicate prefering static libraries.

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

llvm-svn: 326235

6 years ago[analyzer] Remove redundant check
George Karpenkov [Tue, 27 Feb 2018 19:28:52 +0000 (19:28 +0000)]
[analyzer] Remove redundant check

There is no point in assigning void just to crash on it in the next line

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

llvm-svn: 326234

6 years ago[analyzer] Only attempt to get the value of locations of known type
George Karpenkov [Tue, 27 Feb 2018 19:28:52 +0000 (19:28 +0000)]
[analyzer] Only attempt to get the value of locations of known type

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

In general, getSVal API should be changed so that it does not crash on
some non-obvious conditions.
It should either be updated to require a type, or to return Optional<SVal>.

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

llvm-svn: 326233

6 years ago[ARM] Another f16 litpool fix
Sjoerd Meijer [Tue, 27 Feb 2018 19:26:02 +0000 (19:26 +0000)]
[ARM] Another f16 litpool fix

We were always setting the block alignment to 2 bytes in Thumb mode
and 4-bytes in ARM mode (r325754, and r325012), but this could cause
reducing the block alignment when it already had been aligned (e.g.
in Thumb mode when the block is a CPE that was already 4-byte aligned).

Patch by Momchil Velikov, I've only added a test.

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

llvm-svn: 326232

6 years ago[dsymutil] Skip DW_AT_sibling attributes.
Jonas Devlieghere [Tue, 27 Feb 2018 19:24:36 +0000 (19:24 +0000)]
[dsymutil] Skip DW_AT_sibling attributes.

Following DW_AT_sibling attributes completely defeats the pruning pass.
Although clang doesn't generate the DW_AT_sibling attribute we should
still handle it correctly.

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

llvm-svn: 326231

6 years ago[analyzer] Quickfix: don't crash when runtime definition is not available.
George Karpenkov [Tue, 27 Feb 2018 19:19:49 +0000 (19:19 +0000)]
[analyzer] Quickfix: don't crash when runtime definition is not available.

llvm-svn: 326230

6 years ago[analyzer] Logging test quickfix #2.
George Karpenkov [Tue, 27 Feb 2018 19:19:43 +0000 (19:19 +0000)]
[analyzer] Logging test quickfix #2.

llvm-svn: 326229

6 years agoRevert r326225 "[X86] Move the load folding tables to a separate .inc file"
Craig Topper [Tue, 27 Feb 2018 19:15:40 +0000 (19:15 +0000)]
Revert r326225 "[X86] Move the load folding tables to a separate .inc file"

The bots don't seem to like the .inc file. I must be missing some cmake incantation.

llvm-svn: 326228

6 years ago[clang-format] Format operator key in protos
Krasimir Georgiev [Tue, 27 Feb 2018 19:07:47 +0000 (19:07 +0000)]
[clang-format] Format operator key in protos

Summary: This fixes a glitch where ``operator: value`` in a text proto would mess up the underlying formatting since it gets parsed as a kw_operator instead of an identifier.

Subscribers: klimek, cfe-commits

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

llvm-svn: 326227

6 years agoARM: Don't rewrite add reg, $sp, 0 -> mov reg, $sp if the add defines CPSR.
Peter Collingbourne [Tue, 27 Feb 2018 19:00:59 +0000 (19:00 +0000)]
ARM: Don't rewrite add reg, $sp, 0 -> mov reg, $sp if the add defines CPSR.

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

llvm-svn: 326226

6 years ago[X86] Move the load folding tables to a separate .inc file
Craig Topper [Tue, 27 Feb 2018 18:46:11 +0000 (18:46 +0000)]
[X86] Move the load folding tables to a separate .inc file

These tables add 3000 lines to X86InstrInfo.cpp. And if we ever manage to auto generate them they'll be a separate file anyway.

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

llvm-svn: 326225

6 years ago[LLDB] Initial version of PPC64 InstEmulation
Pavel Labath [Tue, 27 Feb 2018 18:42:46 +0000 (18:42 +0000)]
[LLDB] Initial version of PPC64 InstEmulation

Summary: Supports common prologue/epilogue instructions.

Reviewers: clayborg, labath

Reviewed By: clayborg, labath

Subscribers: davide, anajuliapc, alexandreyy, lbianc, nemanjai, mgorny, kbarton

Differential Revision: https://reviews.llvm.org/D43345
Author: Leandro Lupori <leandro.lupori@gmail.com>

llvm-svn: 326224

6 years ago[libunwind] Permit additional compiler and linker flags to be passed to tests.
John Baldwin [Tue, 27 Feb 2018 18:40:04 +0000 (18:40 +0000)]
[libunwind] Permit additional compiler and linker flags to be passed to tests.

Summary:
This is done via new LIBUNWIND_TEST_COMPILER_FLAGS and
LIBUNWIND_TEST_LINKER_FLAGS variables.

Reviewed By: sdardis

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

llvm-svn: 326223

6 years agoadd UUID to the acronyms list of objc property name checks
Yan Zhang [Tue, 27 Feb 2018 18:35:53 +0000 (18:35 +0000)]
add UUID to the acronyms list of objc property name checks

Reviewers: benhamilton, hokein

Reviewed By: benhamilton

Subscribers: klimek, cfe-commits

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

llvm-svn: 326222

6 years ago[ARM] add loop vectorizer test based on 482.sphinx3 from SPEC2006; NFC
Sanjay Patel [Tue, 27 Feb 2018 18:33:24 +0000 (18:33 +0000)]
[ARM] add loop vectorizer test based on 482.sphinx3 from SPEC2006; NFC

This is a slight reduction of one of the benchmarks
that suffered with D43079. Cost model changes should
not cause this test to remain scalarized.

llvm-svn: 326221

6 years ago[Hexagon] Add patterns for compares of i1 values
Krzysztof Parzyszek [Tue, 27 Feb 2018 18:31:46 +0000 (18:31 +0000)]
[Hexagon] Add patterns for compares of i1 values

llvm-svn: 326220

6 years agoHandle the NetBSD case in ToolChain::getOSLibName()
Kamil Rytarowski [Tue, 27 Feb 2018 18:16:47 +0000 (18:16 +0000)]
Handle the NetBSD case in ToolChain::getOSLibName()

Return a new CompilerRT Path on NetBSD: "netbsd", instead of
getOS(), which returns a string like "netbsd8.9.12".

Sponsored by <The NetBSD Foundation>

llvm-svn: 326219

6 years agoMove TestGdbRemoteExitCode next to the other llgs tests
Pavel Labath [Tue, 27 Feb 2018 18:07:53 +0000 (18:07 +0000)]
Move TestGdbRemoteExitCode next to the other llgs tests

This test contained a copy of the inferior used by most of llgs test.
This was done to enable better paralelization, but now it's irrelevant.

llvm-svn: 326218

6 years ago[AArch64] add SLP test based on TSVC; NFC
Sanjay Patel [Tue, 27 Feb 2018 18:06:15 +0000 (18:06 +0000)]
[AArch64] add SLP test based on TSVC; NFC

This is a slight reduction of one of the benchmarks
that suffered with D43079. Cost model changes should
not cause this test to remain scalarized.

llvm-svn: 326217

6 years agoDisable ASan exceptions on NetBSD
Kamil Rytarowski [Tue, 27 Feb 2018 18:05:49 +0000 (18:05 +0000)]
Disable ASan exceptions on NetBSD

This is a workarond for the fallout from D42644:
[asan] Intercept std::rethrow_exception indirectly.

Reported problem on NetBSD/amd64:

$ sh ./projects/compiler-rt/test/sanitizer_common/asan-i386-NetBSD/NetBSD/Output/ttyent.cc.script
/usr/lib/i386/libgcc.a(unwind-dw2.o): In function `_Unwind_RaiseException':
unwind-dw2.c:(.text+0x1b41): multiple definition of `_Unwind_RaiseException'
/public/llvm-build/lib/clang/7.0.0/lib/netbsd/libclang_rt.asan-i386.a(asan_interceptors.cc.o):/public/llvm/projects/compiler-rt/lib/asan/asan_interceptors.cc:337: first defined here
clang-7.0: error: linker command failed with exit code 1 (use -v to see invocation)

llvm-svn: 326216

6 years ago[GISel]: Print more fallback information when aborting
Aditya Nandakumar [Tue, 27 Feb 2018 18:04:23 +0000 (18:04 +0000)]
[GISel]: Print more fallback information when aborting

Currently when abort is enabled, we get a diagnostic saying "Fallback
path used .... " and the program terminates. To actually figure out what
the reason is, we need to run again with another verbose argument
"-pass-remarks-missed=gisel". Instead, when we are going to abort,
we might as well print expensive remarks.

https://reviews.llvm.org/D43796

llvm-svn: 326215

6 years agoRemoved accidentally committed code from previous commit.
Han Ming Ong [Tue, 27 Feb 2018 18:02:15 +0000 (18:02 +0000)]
Removed accidentally committed code from previous commit.

llvm-svn: 326214

6 years agoGot rid of weak imports of libpenergy and libpsample because we are already requiring...
Han Ming Ong [Tue, 27 Feb 2018 17:53:38 +0000 (17:53 +0000)]
Got rid of weak imports of libpenergy and libpsample because we are already requiring a modern macOS (at least 10.11)

Reviewer: Jason Molenda
llvm-svn: 326213

6 years ago[OPENMP] Allow multiple mappings for member expressions for pointers.
Alexey Bataev [Tue, 27 Feb 2018 17:42:00 +0000 (17:42 +0000)]
[OPENMP] Allow multiple mappings for member expressions for pointers.

If several member expressions are mapped and they reference the same
address as a base, but access different members, this must be allowed.

llvm-svn: 326212

6 years ago[clangd] Remove codecomplete override content API. Long live addDocument!
Sam McCall [Tue, 27 Feb 2018 17:15:50 +0000 (17:15 +0000)]
[clangd] Remove codecomplete override content API. Long live addDocument!

llvm-svn: 326211

6 years agoAdd missing REQUIRES.
Rafael Espindola [Tue, 27 Feb 2018 17:13:23 +0000 (17:13 +0000)]
Add missing REQUIRES.

llvm-svn: 326210

6 years agoFix gcc warning.
Rafael Espindola [Tue, 27 Feb 2018 17:11:10 +0000 (17:11 +0000)]
Fix gcc warning.

Should fix the build in some bots.

llvm-svn: 326209

6 years agoRe-enable "[MachineCopyPropagation] Extend pass to do COPY source forwarding"
Geoff Berry [Tue, 27 Feb 2018 16:59:10 +0000 (16:59 +0000)]
Re-enable "[MachineCopyPropagation] Extend pass to do COPY source forwarding"

Re-enable commit r323991 now that r325931 has been committed to make
MachineOperand::isRenamable() check more conservative w.r.t. code
changes and opt-in on a per-target basis.

llvm-svn: 326208

6 years agoAdd support for SHF_ARM_PURECODE.
Rafael Espindola [Tue, 27 Feb 2018 16:55:25 +0000 (16:55 +0000)]
Add support for SHF_ARM_PURECODE.

Now we don't mark a PT_LOAD as readable if all its sections are
SHF_ARM_PURECODE.

llvm-svn: 326207

6 years ago[scudo] Introduce Chunk::getHeaderSize
Kostya Kortchinsky [Tue, 27 Feb 2018 16:14:49 +0000 (16:14 +0000)]
[scudo] Introduce Chunk::getHeaderSize

Summary:
Instead of using `AlignedChunkHeaderSize`, introduce a `constexpr` function
`getHeaderSize` in the `Chunk` namespace. Switch `RoundUpTo` to a `constexpr`
as well (so we can use it in `constexpr` declarations). Mark a few variables
in the areas touched as `const`.

Overall this has no functional change, and is mostly to make things a bit more
consistent.

Reviewers: alekseyshl

Reviewed By: alekseyshl

Subscribers: delcypher, #sanitizers, llvm-commits

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

llvm-svn: 326206

6 years ago[clang-format] Tidy up new API guessLanguage()
Ben Hamilton [Tue, 27 Feb 2018 15:56:40 +0000 (15:56 +0000)]
[clang-format] Tidy up new API guessLanguage()

Summary:
This fixes a few issues djasper@ brought up in his review of D43522.

Test Plan:
  make -j12 FormatTests && ./tools/clang/unittests/Format/FormatTests

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

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

llvm-svn: 326205

6 years agoRevert "[Tooling] [0/1] Refactor FrontendActionFactory::create() to return std::uniqu...
Roman Lebedev [Tue, 27 Feb 2018 15:54:55 +0000 (15:54 +0000)]
Revert "[Tooling] [0/1] Refactor FrontendActionFactory::create() to return std::unique_ptr<>"

This reverts commit rL326201

This broke gcc4.8 builds, compiler just segfaults:¬
http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/14909¬
http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test/builds/22673¬

llvm-svn: 326204

6 years agoRevert "[Tooling] [1/1] Refactor FrontendActionFactory::create() to return std::uniqu...
Roman Lebedev [Tue, 27 Feb 2018 15:54:41 +0000 (15:54 +0000)]
Revert "[Tooling] [1/1] Refactor FrontendActionFactory::create() to return std::unique_ptr<>"

This reverts commit rL326202

This broke gcc4.8 builds, compiler just segfaults:
http://lab.llvm.org:8011/builders/clang-atom-d525-fedora-rel/builds/14909
http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test/builds/22673

llvm-svn: 326203

6 years ago[Tooling] [1/1] Refactor FrontendActionFactory::create() to return std::unique_ptr<>
Roman Lebedev [Tue, 27 Feb 2018 15:19:28 +0000 (15:19 +0000)]
[Tooling] [1/1] Refactor FrontendActionFactory::create() to return std::unique_ptr<>

Summary:
I'm not sure whether there are any principal reasons why it returns raw owning pointer,
or it is just a old code that was not updated post-C++11.

I'm not too sure what testing i should do, because `check-all` is not error clean here for some reason,
but it does not //appear// asif those failures are related to these changes.

This is Clang-tools-extra part.
Clang part is D43779.

Reviewers: klimek, bkramer, alexfh, pcc

Reviewed By: alexfh

Subscribers: ioeric, jkorous-apple, cfe-commits

Tags: #clang, #clang-tools-extra

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

llvm-svn: 326202

6 years ago[Tooling] [0/1] Refactor FrontendActionFactory::create() to return std::unique_ptr<>
Roman Lebedev [Tue, 27 Feb 2018 15:19:20 +0000 (15:19 +0000)]
[Tooling] [0/1] Refactor FrontendActionFactory::create() to return std::unique_ptr<>

Summary:
Noticed during review of D41102.

I'm not sure whether there are any principal reasons why it returns raw owning pointer,
or it is just a old code that was not updated post-C++11.

I'm not too sure what testing i should do, because `check-all` is not error clean here for some reason,
but it does not //appear// asif those failures are related to these changes.

This is clang part.
Clang-tools-extra part is D43780.

Reviewers: klimek, bkramer, alexfh, pcc

Reviewed By: alexfh

Subscribers: cfe-commits

Tags: #clang

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

llvm-svn: 326201

6 years ago[ELF] - Format, fix mistype. NFC.
George Rimar [Tue, 27 Feb 2018 14:06:47 +0000 (14:06 +0000)]
[ELF] - Format, fix mistype. NFC.

llvm-svn: 326198

6 years agoAttrDocs.td: fix some bad code-blocks
Hans Wennborg [Tue, 27 Feb 2018 13:48:50 +0000 (13:48 +0000)]
AttrDocs.td: fix some bad code-blocks

llvm-svn: 326195

6 years agoAttrDocs.td: fix bad bullet list
Hans Wennborg [Tue, 27 Feb 2018 13:48:47 +0000 (13:48 +0000)]
AttrDocs.td: fix bad bullet list

llvm-svn: 326194

6 years agoAttrDocs.td: fix bad indent and code block
Hans Wennborg [Tue, 27 Feb 2018 13:48:41 +0000 (13:48 +0000)]
AttrDocs.td: fix bad indent and code block

llvm-svn: 326193

6 years agoclang-format: use AfterControlStatement to format ObjC control blocks
Francois Ferrand [Tue, 27 Feb 2018 13:48:27 +0000 (13:48 +0000)]
clang-format: use AfterControlStatement to format ObjC control blocks

ObjC defines `@autoreleasepool` and `@synchronized` control blocks. These
used to be formatted according to the `AfterObjCDeclaration` brace-
wrapping flag, which is not very consistent.

This patch changes the behavior to use the `AfterControlStatement` flag
instead. This should not affect the behavior unless a custom brace
wrapping mode is used.

Reviewers: krasimir, djasper, klimek, benhamilton

Subscribers: cfe-commits

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

llvm-svn: 326192

6 years agoclang-format: fix formatting of ObjC @synchronized blocks
Francois Ferrand [Tue, 27 Feb 2018 13:48:21 +0000 (13:48 +0000)]
clang-format: fix formatting of ObjC @synchronized blocks

Summary:
The blocks used to be formatted using the "default" behavior, and would
thus be mistaken for function calls followed by blocks: this could lead
to unexpected inlining of the block and extra line-break before the
opening brace.

They are now formatted similarly to `@autoreleasepool` blocks, as
expected:

  @synchronized(self) {
      f();
  }

Reviewers: krasimir, djasper, klimek

Subscribers: cfe-commits

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

llvm-svn: 326191