Commit Graph

283953 Commits

Author SHA1 Message Date
Rui Ueyama da69b711c9 [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
2018-02-28 00:15:59 +00:00
Rafael Espindola bb333c26ed Inline trivial function. NFC.
llvm-svn: 326272
2018-02-28 00:14:18 +00:00
Rui Ueyama e3498ec562 [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
2018-02-28 00:09:22 +00:00
Rafael Espindola fa2fc906d2 Pass a GlobalDecl to setAliasAttributes. NFC.
This just makes a followup change easier to read.

llvm-svn: 326270
2018-02-28 00:06:01 +00:00
Rui Ueyama 37254065dd [WebAssembly] Use StringRef instead of `const char *`.
Differential Revision: https://reviews.llvm.org/D43721

llvm-svn: 326269
2018-02-28 00:01:31 +00:00
Sam Clegg 99eb42c0c5 [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
2018-02-27 23:58:03 +00:00
Sam Clegg 86b4a09a99 [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
2018-02-27 23:57:37 +00:00
Aaron Ballman 48a533d005 Improve the way attribute argument printing happens for omitted optional arguments when pretty printing.
Patch by Joel Denny.

llvm-svn: 326266
2018-02-27 23:49:28 +00:00
Rafael Espindola 64393cfca0 Pass a GlobalDecl to setFunctionDefinitionAttributes. NFC.
This just makes a followup patch easier to read.

llvm-svn: 326265
2018-02-27 23:44:36 +00:00
Pavel Labath 9bdd03f7da 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
2018-02-27 22:45:49 +00:00
Krzysztof Parzyszek 2373f8fcf3 [Hexagon] Recognize more sign-extensions as inputs to 32x32-bit multiply
llvm-svn: 326263
2018-02-27 22:44:41 +00:00
Krzysztof Parzyszek 2d79017d85 [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
2018-02-27 22:40:52 +00:00
Pavel Labath 029fb69372 [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
2018-02-27 22:14:33 +00:00
Reid Kleckner 3acdc67734 [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
2018-02-27 22:08:15 +00:00
Krzysztof Parzyszek 10ab103a58 Revert "[Pipeliner] Drop memrefs instead of creating ones with size UINT64_MAX"
This reverts r326256. One testcase needs to be updated.

llvm-svn: 326259
2018-02-27 22:07:38 +00:00
Artem Dergachev f119bf99e5 [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
2018-02-27 22:05:55 +00:00
Alexander Richardson 8edd70b7c6 [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
2018-02-27 22:01:02 +00:00
Krzysztof Parzyszek 82da5d7f55 [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
2018-02-27 22:00:32 +00:00
Shoaib Meenai 03303a3bb6 [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
2018-02-27 21:48:41 +00:00
Konstantin Zhuravlyov d6b3453bdb 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
2018-02-27 21:48:05 +00:00
Reid Kleckner 22d838cd31 [codeview] Remove unused variable
llvm-svn: 326253
2018-02-27 21:46:40 +00:00
Konstantin Zhuravlyov 40b09e86b9 AMDGPU: Add fast fmaf feature to gfx702
Differential Revision: https://reviews.llvm.org/D43790

llvm-svn: 326252
2018-02-27 21:46:15 +00:00
Alexey Bataev 95c23e72da [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
2018-02-27 21:31:11 +00:00
John Baldwin 0594aee52f [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
2018-02-27 21:24:02 +00:00
Artem Dergachev 5337efc69c [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
2018-02-27 21:19:33 +00:00
Martin Storsjo dff5a44f29 [llvm-cvtres] Update the help test after SVN r326244.
llvm-svn: 326248
2018-02-27 21:11:03 +00:00
Artem Dergachev 4449e7f008 [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
2018-02-27 21:10:08 +00:00
Artem Dergachev 1e3dbd7a17 [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
2018-02-27 21:02:58 +00:00
Artem Dergachev f01831ebe9 [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
2018-02-27 20:54:40 +00:00
Martin Storsjo 3a76492108 llvm-cvtres: Mention ARM64 as a supported machine type in the help text. NFC.
llvm-svn: 326244
2018-02-27 20:44:33 +00:00
Rui Ueyama f0884e474c 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
2018-02-27 20:37:18 +00:00
Rafael Espindola 3f4c673d38 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
2018-02-27 20:31:22 +00:00
Sanjay Patel bf28a8fc01 [InstSimplify] add tests for FP with undef operand; NFC
Are any of these correct?

llvm-svn: 326241
2018-02-27 20:17:18 +00:00
Artem Dergachev 8cd7961a0a [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
2018-02-27 20:14:06 +00:00
Artem Dergachev b7f53df0c2 [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
2018-02-27 20:06:20 +00:00
Artem Dergachev 4068481bdb [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
2018-02-27 20:03:35 +00:00
Craig Topper 301991080e [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
2018-02-27 19:53:45 +00:00
Artem Dergachev 308e27ee9d [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
2018-02-27 19:47:49 +00:00
Martin Storsjo ca4a24eb72 [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
2018-02-27 19:42:19 +00:00
George Karpenkov d1400213f5 [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
2018-02-27 19:28:52 +00:00
George Karpenkov 53c1c10beb [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
2018-02-27 19:28:52 +00:00
Sjoerd Meijer fc0d02cbbf [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
2018-02-27 19:26:02 +00:00
Jonas Devlieghere de979bfe58 [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
2018-02-27 19:24:36 +00:00
George Karpenkov 482bf0f531 [analyzer] Quickfix: don't crash when runtime definition is not available.
llvm-svn: 326230
2018-02-27 19:19:49 +00:00
George Karpenkov fa5d70e623 [analyzer] Logging test quickfix #2.
llvm-svn: 326229
2018-02-27 19:19:43 +00:00
Craig Topper 688d1eb919 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
2018-02-27 19:15:40 +00:00
Krasimir Georgiev 0aa4b4cb2e [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
2018-02-27 19:07:47 +00:00
Peter Collingbourne e8436e8631 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
2018-02-27 19:00:59 +00:00
Craig Topper c0a1291478 [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
2018-02-27 18:46:11 +00:00
Pavel Labath a535a7a2a0 [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
2018-02-27 18:42:46 +00:00