Alexander Kornienko [Wed, 28 Feb 2018 14:47:20 +0000 (14:47 +0000)]
Rename a few checks from misc- to bugprone-.
Summary:
rename_check.py {misc,bugprone}-forwarding-reference-overload
rename_check.py {misc,bugprone}-macro-repeated-side-effects
rename_check.py {misc,bugprone}-lambda-function-name
rename_check.py {misc,bugprone}-misplaced-widening-cast
Reviewers: hokein, sammccall, aaron.ballman
Reviewed By: aaron.ballman
Subscribers: klimek, cfe-commits, mgorny
Differential Revision: https://reviews.llvm.org/D43867
llvm-svn: 326327
Nicholas Wilson [Wed, 28 Feb 2018 14:03:18 +0000 (14:03 +0000)]
[WebAssembly] Fix copy-paste error in debugging string
llvm-svn: 326326
Eric Liu [Wed, 28 Feb 2018 14:02:18 +0000 (14:02 +0000)]
[clangd] A few more fixes for STL header mapping.
llvm-svn: 326325
Gabor Horvath [Wed, 28 Feb 2018 14:01:48 +0000 (14:01 +0000)]
[analyzer] Fix a compiler warning
llvm-svn: 326324
Gabor Horvath [Wed, 28 Feb 2018 13:23:10 +0000 (13:23 +0000)]
[analyzer] Support for naive cross translation unit analysis
The aim of this patch is to be minimal to enable incremental development of
the feature on the top of the tree. This patch should be an NFC when the
feature is turned off. It is turned off by default and still considered as
experimental.
Technical details are available in the EuroLLVM Talk:
http://llvm.org/devmtg/2017-03//2017/02/20/accepted-sessions.html#7
Note that the initial prototype was done by A. Sidorin et al.: http://lists.llvm.org/pipermail/cfe-dev/2015-October/045730.html
Contributions to the measurements and the new version of the code: Peter Szecsi, Zoltan Gera, Daniel Krupp, Kareem Khazem.
Differential Revision: https://reviews.llvm.org/D30691
llvm-svn: 326323
Simon Dardis [Wed, 28 Feb 2018 13:02:44 +0000 (13:02 +0000)]
[mips] Begin reworking instruction predicates for ISAs/encodings (1/N)
The MIPS backend has inconsistent usage of instruction predicates
for assembly and code generation. The issue arises from supporting three
encodings, two (MIPS and microMIPS) of which have a near 1:1 instruction
mapping across ISA revisions and a third encoding with a more restricted
set of instructions (MIPS16e).
To enforce consistent usage, each of the ISA_* adjectives has (or will
have) the relevant encoding attached to it along the relevant ISA revision
where the instruction is defined.
Each instruction, pattern or alias will then have the correct ISA adjective
attached to it, and the base instruction description classes will have any
predicates relating to ISA encoding or revision removed.
Pseudo instructions will also be guarded for the encoding or ABI that they are
supported in.
Finally, the hasStandardEncoding() / inMicroMipsMode() / inMips16Mode() methods
of MipsSubtarget will be changed such that only one can be true at any one time.
The result of this is that code generation and assembly will produce the
correct encoding up front, while code generated from pseudo instructions
and other inserted sequences of instructions will be able to rely on the mapping
tables to produce the correct encoding. This should fix numerous bugs where
the result 'happens' to be correct but has edge cases where microMIPS and MIPS
have subtle differences (e.g. microMIPSR6 using 'j', 'jal' instructions.)
This patch starts the process by changing most of the ISA adjectives to make
use of the EncodingPredicate member of PredicateControl. Follow on patches
will annotate instructions with their correct ISA adjective and eliminate
the usage of "let Predicates = [..]", "let AdditionalPredicates = [..]" and
"isCodeGenOnly = 1" in the cases where it was used to control instruction
availability.
Contributions from Nitesh Jain.
Reviewers: atanasyan
Differential Revision: https://reviews.llvm.org/D41434
llvm-svn: 326322
Alexander Kornienko [Wed, 28 Feb 2018 12:21:38 +0000 (12:21 +0000)]
[clang-tidy] Fix 'add_new_check.py --udpate-docs'
llvm-svn: 326321
Alexander Ivchenko [Wed, 28 Feb 2018 12:11:53 +0000 (12:11 +0000)]
[GlobalIsel][X86] Support G_INTTOPTR instruction.
Add legalization/selection for x86/x86_64 and
corresponding tests.
Reviewed By: igorb
Differential Revision: https://reviews.llvm.org/D43622
llvm-svn: 326320
Xin Tong [Wed, 28 Feb 2018 12:09:53 +0000 (12:09 +0000)]
Fix typo. NFC
llvm-svn: 326319
Xin Tong [Wed, 28 Feb 2018 12:08:00 +0000 (12:08 +0000)]
[MergeICmp] Fix a bug in MergeICmp that can lead to a block being processed more than once.
Summary:
Fix a bug in MergeICmp that can lead to a BCECmp block being processed more than once and eventually lead to a broken LLVM module.
The problem is that if the non-constant value is not produced by the last block, the producer will be processed once when the its parent block
is processed and second time when the last block is processed.
We end up having 2 same BCECmpBlock in the merge queue. And eventually lead to a broken LLVM module.
Reviewers: courbet, davide
Reviewed By: courbet
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D43825
llvm-svn: 326318
Klaus Kretzschmar [Wed, 28 Feb 2018 11:32:23 +0000 (11:32 +0000)]
[IR] - Make User construction exception safe
There are many instruction ctors that call the setName method of the Value base class, which can throw a bad_alloc exception in OOM situations.
In such situations special User delete operators are called which are not implemented yet.
Example:
Lets look at the construction of a CallInst instruction during IR generation:
static CallInst *Create(FunctionType *Ty, Value *Func, ArrayRef<Value *> Args, .. ){
...
return new (TotalOps, DescriptorBytes) CallInst(Ty, Func, Args, Bundles, NameStr, InsertBefore);
}
CallInst::CalInst(Value* Func, ...) {
...
Op<-1>() = Func;
....
setName(name); // throws
...
}
Op<-1>() returns a reference to a Use object of the CallInst instruction and the operator= inserts this use object into the UseList of Func.
The same object is removed from that UseList by calling the User::operator delete If the CallInst object is deleted.
Since setName can throw a bad_alloc exception (if LLVM_ENABLE_EXCEPTIONS is switched on), the unwind chain runs into assertions ("Constructor throws?") in
special User::operator deletes operators:
operator delete(void* Usr, unsigned)
operator delete(void* Usr, unsigned, bool)
This situation can be fixed by simlpy calling the User::operator delete(void*) in these unimplemented methods.
To ensure that this additional call succeeds all information that is necessary to calculate the storage pointer from the Usr address
must be restored in the special case that a sublass has changed this information, e.g. GlobalVariable can change the NumberOfOperands.
Reviewd by: rnk
Differential Revision: https://reviews.llvm.org/D42731
llvm-svn: 326316
David Green [Wed, 28 Feb 2018 11:00:08 +0000 (11:00 +0000)]
[Dominators] Remove verifyDomTree and add some verifying for Post Dom Trees
Removes verifyDomTree, using assert(verify()) everywhere instead, and
changes verify a little to always run IsSameAsFreshTree first in order
to print good output when we find errors. Also adds verifyAnalysis for
PostDomTrees, which will allow checking of PostDomTrees it the same way
we check DomTrees and MachineDomTrees.
Differential Revision: https://reviews.llvm.org/D41298
llvm-svn: 326315
Alexander Kornienko [Wed, 28 Feb 2018 10:30:25 +0000 (10:30 +0000)]
[clang-tidy] Add a test for readability-implicit-bool-conversion with bitfields.
llvm-svn: 326314
Eric Liu [Wed, 28 Feb 2018 09:33:15 +0000 (09:33 +0000)]
[clangd] Prefer the definition of a TagDecl (e.g. class) as CanonicalDeclaration.
Summary:
Currently, we pick the first declaration of a symbol in a TU, which is considered
canonical in the clangIndex, as the canonical declaration in clangd. This causes
forward declarations that might appear in a random header to be used as a
canonical declaration, which is not desirable for features like go-to-declaration
or include insertion.
For example, for class X, we would consider the forward declaration in fwd.h to
be the canonical declaration, while the preferred canonical declaration should
be the actual definition in x.h.
```
// fwd.h
class X; // forward decl
// x.h
class X {};
```
This patch fixes the issue by making symbol collector favor the actual definition of
a TagDecl (i.e. class/struct/enum/union) found in a header file over the first seen
declarations in a TU. Other symbol types like functions are not handled because
using the first seen declarations as canonical declarations is usually a good
heuristic for them.
Reviewers: sammccall
Subscribers: klimek, ilya-biryukov, jkorous-apple, cfe-commits
Differential Revision: https://reviews.llvm.org/D43823
llvm-svn: 326313
Joachim Protze [Wed, 28 Feb 2018 09:28:51 +0000 (09:28 +0000)]
[OMPT] Fix inconsistent testcases
The main change of this patch is to insert {{.*}} in current_address=[[RETURN_ADDRESS_END]].
This is needed to match any of the alternatively printed addresses.
Additionally, clang-format is applied to the two tests.
Differential Revision: https://reviews.llvm.org/D43115
llvm-svn: 326312
Alexander Ivchenko [Wed, 28 Feb 2018 09:18:47 +0000 (09:18 +0000)]
[GlobalIsel][X86] Support G_PTRTOINT instruction.
Add legalization/selection for x86/x86_64 and
corresponding tests.
Reviewed By: igorb
Differential Revision: https://reviews.llvm.org/D43617
llvm-svn: 326311
Eric Liu [Wed, 28 Feb 2018 08:56:11 +0000 (08:56 +0000)]
[clangd] A few minor fixes for STL internal header mapping.
llvm-svn: 326310
Alex Bradbury [Wed, 28 Feb 2018 08:20:47 +0000 (08:20 +0000)]
[RISCV] Update two tests after r326208
llvm-svn: 326309
Craig Topper [Wed, 28 Feb 2018 08:14:28 +0000 (08:14 +0000)]
[X86] Don't use EXTRACT_ELEMENT from v1i1 with i8/i32 result type when we need to guarantee zeroes in the upper bits of return.
An extract_element where the result type is larger than the scalar element type is semantically an any_extend of from the scalar element type to the result type. If we expect zeroes in the upper bits of the i8/i32 we need to mae sure those zeroes are explicit in the DAG.
For these cases the best way to accomplish this is use an insert_subvector to pad zeroes to the upper bits of the v1i1 first. We extend to either v16i1(for i32) or v8i1(for i8). Then bitcast that to a scalar and finish with a zero_extend up to i32 if necessary. We can't extend past v16i1 because that's the largest mask size on KNL. But isel is smarter enough to know that a zext of a bitcast from v16i1 to i16 can use a KMOVW instruction. The insert_subvectors will be dropped during isel because we can determine that the producing instruction already zeroed the upper bits of the k-register.
llvm-svn: 326308
Akira Hatanaka [Wed, 28 Feb 2018 07:15:55 +0000 (07:15 +0000)]
[ObjC] Allow declaring __strong pointer fields in structs in Objective-C
ARC mode.
Declaring __strong pointer fields in structs was not allowed in
Objective-C ARC until now because that would make the struct non-trivial
to default-initialize, copy/move, and destroy, which is not something C
was designed to do. This patch lifts that restriction.
Special functions for non-trivial C structs are synthesized that are
needed to default-initialize, copy/move, and destroy the structs and
manage the ownership of the objects the __strong pointer fields point
to. Non-trivial structs passed to functions are destructed in the callee
function.
rdar://problem/
33599681
Differential Revision: https://reviews.llvm.org/D41228
llvm-svn: 326307
Craig Topper [Wed, 28 Feb 2018 06:19:55 +0000 (06:19 +0000)]
[X86] Change the masked FPCLASS implementation to use AND instead of OR to combine the mask results.
While the description for the instruction does mention OR, its talking about how the individual classification test results are ORed together.
The incoming mask is used as a zeroing write mask. If the bit is 1 the classification is written to the output. The bit is 0 the output is 0. This equivalent to an AND.
Here is pseudocode from the intrinsics guide
FOR j := 0 to 1
i := j*64
IF k1[j]
k[j] := CheckFPClass_FP64(a[i+63:i], imm8[7:0])
ELSE
k[j] := 0
FI
ENDFOR
k[MAX:2] := 0
llvm-svn: 326306
Igor Kudrin [Wed, 28 Feb 2018 05:55:56 +0000 (05:55 +0000)]
[ELF] Process linker scripts deeper when declaring symbols.
We should process symbols inside output section declarations the same way as top-level ones.
Differential Revision: https://reviews.llvm.org/D43008
llvm-svn: 326305
Andrew Zhogin [Wed, 28 Feb 2018 05:53:18 +0000 (05:53 +0000)]
[ARM] Cortex-A57 scheduler fix for ARM backend (missed 16-bit, v8.1/v8.2/v8.3, thumb and pseudo instructions)
Added missed scheduling info for ARM Cortex A57 (AArch32) to have CompleteModel with this checkCompleteness fix: https://reviews.llvm.org/D43235.
Reviewed By: RKSimon
Differential Revision: https://reviews.llvm.org/D43808
llvm-svn: 326304
Mohammad Shahid [Wed, 28 Feb 2018 04:19:34 +0000 (04:19 +0000)]
[SLP] Added new tests and updated existing for jumbled load, NFC.
llvm-svn: 326303
Jason Molenda [Wed, 28 Feb 2018 04:11:37 +0000 (04:11 +0000)]
Add EmulateInstructionPPC64.cpp to xcode project file.
llvm-svn: 326302
Rui Ueyama [Wed, 28 Feb 2018 03:43:38 +0000 (03:43 +0000)]
[WebAssembly] Fix variable name.
llvm-svn: 326301
Rui Ueyama [Wed, 28 Feb 2018 03:38:14 +0000 (03:38 +0000)]
[WebAssembly] Remove unnecessary namespace specifiers. NFC.
llvm-svn: 326300
Richard Smith [Wed, 28 Feb 2018 03:02:23 +0000 (03:02 +0000)]
Fix a couple of cases where we would fail to correctly parse deduced class template specialization types.
Specifically, we would not properly parse these types within template arguments
(for non-type template parameters), and in tentative parses. Fixing both of
these essentially requires that we parse deduced template specialization types
as types in all contexts, even in template argument lists -- in particular,
tentative parsing may look ahead and annotate a deduced template specialization
type before we figure out that we're actually supposed to treat the tokens as a
template-name. We deal with this by simply permitting deduced template
specialization types when parsing template arguments, and converting them to
template template arguments.
llvm-svn: 326299
Richard Smith [Wed, 28 Feb 2018 03:02:07 +0000 (03:02 +0000)]
Update cxx_status to mark "SVN" items as "Clang 6" instead.
llvm-svn: 326298
Rui Ueyama [Wed, 28 Feb 2018 02:57:37 +0000 (02:57 +0000)]
[WebAssembly] Simplify initializeSymbols and merge it with ObjFile::parse. NFC.
This patch simplifies initializeSymbols. Since that function is called
at the tail context of ObjFile::parse, and the function is called only
once from that function, that's effectively just a continuation of
ObjFile::parse. So this patch merge it with ObjFile::parse.
Differential Revision: https://reviews.llvm.org/D43848
llvm-svn: 326296
George Karpenkov [Wed, 28 Feb 2018 01:55:23 +0000 (01:55 +0000)]
[analyzer] [tests] Write to logfile instead of stdout while updating
reference results
llvm-svn: 326295
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Rafael Espindola [Wed, 28 Feb 2018 00:14:18 +0000 (00:14 +0000)]
Inline trivial function. NFC.
llvm-svn: 326272
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
Reid Kleckner [Tue, 27 Feb 2018 21:46:40 +0000 (21:46 +0000)]
[codeview] Remove unused variable
llvm-svn: 326253
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
George Karpenkov [Tue, 27 Feb 2018 19:19:43 +0000 (19:19 +0000)]
[analyzer] Logging test quickfix #2.
llvm-svn: 326229
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
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
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