Nikita Popov [Sat, 7 Sep 2019 12:03:48 +0000 (12:03 +0000)]
[X86] Add test for PR43230; NFC
llvm-svn: 371305
Bjorn Pettersson [Sat, 7 Sep 2019 11:40:10 +0000 (11:40 +0000)]
[DwarfExpression] Disallow some rewrites to avoid undefined behavior
Summary:
The value operand in DW_OP_plus_uconst/DW_OP_constu value can be
large (it uses uint64_t as representation internally in LLVM).
This means that in the uint64_t to int conversions, previously done
by DwarfExpression::addMachineRegExpression, could lose information.
Also, the negation done in "-Offset" was undefined behavior in case
Offset was exactly INT_MIN.
To avoid the above problems, we now avoid transformation like
[Reg, DW_OP_plus_uconst, Offset] --> [DW_OP_breg, Offset]
and
[Reg, DW_OP_constu, Offset, DW_OP_plus] --> [DW_OP_breg, Offset]
when Offset > INT_MAX.
And we avoid to transform
[Reg, DW_OP_constu, Offset, DW_OP_minus] --> [DW_OP_breg,-Offset]
when Offset > INT_MAX+1.
The patch also adjusts DwarfCompileUnit::constructVariableDIEImpl
to make sure that "DW_OP_constu, Offset, DW_OP_minus" is used
instead of "DW_OP_plus_uconst, Offset" when creating DIExpressions
with negative frame index offsets.
Notice that this might just be the tip of the iceberg. There
are lots of fishy handling related to these constants. I think both
DIExpression::appendOffset and DIExpression::extractIfOffset may
trigger undefined behavior for certain values.
Reviewers: sdesmalen, rnk, JDevlieghere
Reviewed By: JDevlieghere
Subscribers: jholewinski, aprantl, hiraditya, ychen, uabelho, llvm-commits
Tags: #debug-info, #llvm
Differential Revision: https://reviews.llvm.org/D67263
llvm-svn: 371304
Bjorn Pettersson [Sat, 7 Sep 2019 11:39:57 +0000 (11:39 +0000)]
[DebugInfo] Pre-commit of test case for DW_OP_breg/DW_OP_fbreg folds
This currently triggers undefined behavior if executed with an
ubsan build. It is just a precommit of the test case to show that
we got a problem.
Fix is proposed in https://reviews.llvm.org/D67263 and plan is to
commit the fix directly after this patch.
llvm-svn: 371303
Simon Pilgrim [Sat, 7 Sep 2019 11:04:04 +0000 (11:04 +0000)]
Fix MSVC "32-bit shift implicitly converted to 64 bits" warnings. NFCI.
llvm-svn: 371302
Roman Lebedev [Sat, 7 Sep 2019 10:55:04 +0000 (10:55 +0000)]
[SimplifyCFG][NFC] Make merge-cond-stores-cost.ll X86-specific, and rewrite it
We clearly perform store-merging, even though div is really costly.
llvm-svn: 371300
Fangrui Song [Sat, 7 Sep 2019 10:42:11 +0000 (10:42 +0000)]
[ELF][test] Improve tests
Add file-level comments
Delete insignificant addresses to make them more tolerant to layout changes
Simplify test output
Delete weak-undef-val.s - covered by relocation-undefined-weak.s
Delete weak-undef-export.s - covered by additional test added to weak-undef.s
Delete version-undef-sym.s - covered by undefined-versioned-symbol.s => version-symbol-undef.s
Delete symbol-ordering-file2.s - covered by symbol-ordering-file.s
Delete gotpcrelx.s - covered by gotpc-relax-und-dso.s => x86-64-gotpc-relax-und-dso.s
llvm-svn: 371299
Benjamin Kramer [Sat, 7 Sep 2019 10:27:13 +0000 (10:27 +0000)]
[Attributor] Make unimplemented method pure virtual.
Otherwise the compiler mistakes it for a vtable anchor.
llvm-svn: 371298
Roman Lebedev [Sat, 7 Sep 2019 09:25:26 +0000 (09:25 +0000)]
[SimplifyCFG][NFC] Show that we don't consider the cost when merging cond stores
We count instruction count in each BB's separately, not their cost.
llvm-svn: 371297
Roman Lebedev [Sat, 7 Sep 2019 09:25:18 +0000 (09:25 +0000)]
[SimplifyCFG][NFC] Regenerate merge-cond-stores* tests
llvm-svn: 371296
Roman Lebedev [Sat, 7 Sep 2019 09:06:06 +0000 (09:06 +0000)]
[SimplifyCFG] SpeculativelyExecuteBB(): It's SpeculatedInstructions, not SpeculationCost
It counts the number of instructions we are ok speculating
(at most 1 there), not their cost, so rename accordingly.
llvm-svn: 371294
Sylvestre Ledru [Sat, 7 Sep 2019 08:38:46 +0000 (08:38 +0000)]
Replicate the change "[Alignment][NFC] Use Align with TargetLowering::setMinFunctionAlignment"
on AVR to avoid a breakage.
See r371200 / https://reviews.llvm.org/D67229
llvm-svn: 371293
Fangrui Song [Sat, 7 Sep 2019 08:20:09 +0000 (08:20 +0000)]
[ELF][test] Improve LTO tests
Add file-level comments
Delete insignificant addresses to make them more tolerant to layout changes
Simplify test output
llvm-svn: 371292
Hideto Ueno [Sat, 7 Sep 2019 07:03:05 +0000 (07:03 +0000)]
[Attributor] ValueSimplify Abstract Attribute
Summary:
This patch introduces initial `AAValueSimplify` which simplifies a value in a context.
example
- (for function returned) If all the return values are the same and constant, then we can replace callsite returned with the constant.
- If an internal function takes the same value(constant) as an argument in the callsite, then we can replace the argument with that constant.
Reviewers: jdoerfert, sstefan1
Reviewed By: jdoerfert
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D66967
llvm-svn: 371291
David Zarzycki [Sat, 7 Sep 2019 06:44:52 +0000 (06:44 +0000)]
[git-llvm] Do not reinvent `@{upstream}`
Make `git-llvm` more robust when used with a nontrivial repository.
https://reviews.llvm.org/D67262
llvm-svn: 371290
Xing GUO [Sat, 7 Sep 2019 05:14:47 +0000 (05:14 +0000)]
Revert [CodeGen] Fix typos to run tests. NFC.
This reverts r371286 (git commit
b38105bbd0f7dfef424a4f096aa6a6b7b467fe99)
r371286 caused build bots' failure. I'll check it.
llvm-svn: 371289
Xing GUO [Sat, 7 Sep 2019 04:57:53 +0000 (04:57 +0000)]
[CodeGen] Fix typos to run tests. NFC.
llvm-svn: 371286
Teresa Johnson [Sat, 7 Sep 2019 03:09:46 +0000 (03:09 +0000)]
Remove stale TLI Module level pass registration
Clang patch to adapt to LLVM changes in D66428 that make the TLI
require a Function. There is no longer a module-level
TargetLibraryAnalysis, so remove its registration
llvm-svn: 371285
Teresa Johnson [Sat, 7 Sep 2019 03:09:36 +0000 (03:09 +0000)]
Change TargetLibraryInfo analysis passes to always require Function
Summary:
This is the first change to enable the TLI to be built per-function so
that -fno-builtin* handling can be migrated to use function attributes.
See discussion on D61634 for background. This is an enabler for fixing
handling of these options for LTO, for example.
This change should not affect behavior, as the provided function is not
yet used to build a specifically per-function TLI, but rather enables
that migration.
Most of the changes were very mechanical, e.g. passing a Function to the
legacy analysis pass's getTLI interface, or in Module level cases,
adding a callback. This is similar to the way the per-function TTI
analysis works.
There was one place where we were looking for builtins but not in the
context of a specific function. See FindCXAAtExit in
lib/Transforms/IPO/GlobalOpt.cpp. I'm somewhat concerned my workaround
could provide the wrong behavior in some corner cases. Suggestions
welcome.
Reviewers: chandlerc, hfinkel
Subscribers: arsenm, dschuff, jvesely, nhaehnle, mehdi_amini, javed.absar, sbc100, jgravelle-google, eraman, aheejin, steven_wu, george.burgess.iv, dexonsmith, jfb, asbirlea, gchatelet, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D66428
llvm-svn: 371284
Craig Topper [Sat, 7 Sep 2019 01:39:21 +0000 (01:39 +0000)]
[X86] Add tests for fp128 frem, sqrt, sin, and cos.
llvm-svn: 371283
Craig Topper [Sat, 7 Sep 2019 01:39:12 +0000 (01:39 +0000)]
[X86] Autogenerate fp128-libcalls.ll
llvm-svn: 371282
Fangrui Song [Sat, 7 Sep 2019 01:38:56 +0000 (01:38 +0000)]
[llvm-objcopy] Rename SHOffset (e_shoff) field to SHOff. NFC
Similar to D67254.
`struct Elf*_Shdr` has a field `sh_offset`. Rename SHOffset to SHOff to
avoid confusion.
llvm-svn: 371281
Jason Molenda [Sat, 7 Sep 2019 01:38:37 +0000 (01:38 +0000)]
Long timeouts for the MacOSX SystemRuntime plugins under ASAN; else quick.
In April via r357829, Adrian unified timeouts across lldb and set the
default value high so that we wouldn't get timeouts on ASAN bots that
were running under load.
The library that the MacOSX SystemRuntime has functions that need
to take a lock, and if that lock is held already, those functions
will never complete; we're seeing the 15 second timeout being hit
with inferiors that are doing a lot of enqueuing and dequeuing of
libdispatch work items causing this deadlocking behavior.
This patch reverts to a very short timeout for these SystemRuntime
function calls, given the behavior of this library that they are
calling into. When lldb is built with AddressSanitizer enabled,
they will use the default 15 second timeout.
tl;dr: this reverts to the previous timeouts for these SystemRuntime
inf func calls.
<rdar://problem/
54538149>
llvm-svn: 371280
Jan Korous [Sat, 7 Sep 2019 00:59:13 +0000 (00:59 +0000)]
[clang][DependencyFileGenerator] Fix missing -MT option handling
Targets in DependencyFileGenerator don't necessarily come from -MT option.
Differential Revision: https://reviews.llvm.org/D67308
llvm-svn: 371279
Reid Kleckner [Sat, 7 Sep 2019 00:41:08 +0000 (00:41 +0000)]
Fix thunks.cpp test, don't FileCheck for anon namespace id
The anon namespace id is a hash of the main input path to the compiler,
which varies in the test suite because the input path is absolute.
llvm-svn: 371277
Akira Hatanaka [Sat, 7 Sep 2019 00:34:47 +0000 (00:34 +0000)]
[Sema][ObjC] Mark C union fields that have non-trivial ObjC ownership
qualifications as unavailable if the union is declared in a system
header
r365985 stopped marking those fields as unavailable, which caused the
union's NonTrivialToPrimitive* bits to be set to true. This patch
restores the behavior prior to r365985, except that users can explicitly
specify the ownership qualification of the field to instruct the
compiler not to mark it as unavailable.
rdar://problem/
53420753
Differential Revision: https://reviews.llvm.org/D65256
llvm-svn: 371276
Akira Hatanaka [Sat, 7 Sep 2019 00:34:43 +0000 (00:34 +0000)]
[Sema] Diagnose default-initialization, destruction, and copying of
non-trivial C union types
This recommits r365985, which was reverted because it broke a few
projects using unions containing non-trivial ObjC pointer fields in
system headers. We now have a patch to fix the problem (see
https://reviews.llvm.org/D65256).
Original commit message:
This patch diagnoses uses of non-trivial C unions and structs/unions
containing non-trivial C unions in the following contexts, which require
default-initialization, destruction, or copying of the union objects,
instead of disallowing fields of non-trivial types in C unions, which is
what we currently do:
- function parameters.
- function returns.
- assignments.
- compound literals.
- block captures except capturing of `__block` variables by non-escaping blocks.
- local and global variable definitions.
- lvalue-to-rvalue conversions of volatile types.
See the discussion in https://reviews.llvm.org/D62988 for more background.
rdar://problem/
50679094
Differential Revision: https://reviews.llvm.org/D63753
llvm-svn: 371275
Richard Smith [Sat, 7 Sep 2019 00:11:53 +0000 (00:11 +0000)]
Synchronize LLVM's copy of libc++abi's demangler with the libc++abi
version after r371273.
Also fix a minor issue in r371273 that only surfaced after template
instantiation from LLVM's use of the demangler.
llvm-svn: 371274
Richard Smith [Fri, 6 Sep 2019 23:53:21 +0000 (23:53 +0000)]
Implement demangling support for C++20 lambda expression extensions.
This implements demangling support for the mangling extensions specified
in https://github.com/itanium-cxx-abi/cxx-abi/pull/85, much of which is
implemented in Clang r359967 and r371004.
Specifically, this provides demangling for:
* <template-param-decl> in <lambda-sig>
* <template-param> with non-zero level
* lambda-expression literals (not emitted by Clang yet)
* nullptr literals
* string literals
(The final two seem unrelated, but handling them was necessary in order
to disambiguate between lambda expressions and the other forms of
literal for which we have a type but no value.)
When demangling a <lambda-sig>, we form template parameters with no
corresponding argument, so we cannot substitute in the argument in the
demangling. Instead we invent synthetic names for the template
parameters (eg, '[]<typename $T>($T *x)').
llvm-svn: 371273
Reid Kleckner [Fri, 6 Sep 2019 22:55:26 +0000 (22:55 +0000)]
Use musttail for variadic method thunks when possible
This avoids cloning variadic virtual methods when the target supports
musttail and the return type is not covariant. I think we never
implemented this previously because it doesn't handle the covariant
case. But, in the MS ABI, there are some cases where vtable thunks must
be emitted even when the variadic method defintion is not available, so
it looks like we need to implement this. Do it for both ABIs, since it's
a nice size improvement and simplification for Itanium.
Emit an error when emitting thunks for variadic methods with a covariant
return type. This case is essentially not implementable unless the ABI
provides a way to perfectly forward variadic arguments without a tail
call.
Fixes PR43173.
Differential Revision: https://reviews.llvm.org/D67028
llvm-svn: 371269
Matthew Voss [Fri, 6 Sep 2019 22:51:46 +0000 (22:51 +0000)]
Update lld tests dynamic-list.s and symbol-override.s to use llvm-nm
The following tests failed on Windows bots due to nm not being
available:
lld/test/ELF/dynamic-list.s
lld/test/ELF/symbol-override.s
llvm-svn: 371267
Amara Emerson [Fri, 6 Sep 2019 22:27:09 +0000 (22:27 +0000)]
[AArch64][GlobalISel] Enable the localizer for optimized builds.
Despite the fact that the localizer's original motivation was to fix horrendous
constant spilling at -O0, shortening live ranges still has net benefits even
with optimizations enabled.
On an -Os build of CTMark, doing this improves code size by 0.5% geomean.
There are a few regressions, bullet increasing in size by 0.5%. One example from
bullet where code size increased slightly was due to GlobalISel actually now
generating the same code as SelectionDAG. So we actually have an opportunity
in future to implement better heuristics for localization and therefore be
*better* than SDAG in some cases. In relation to other optimizations though that
one is relatively minor.
Differential Revision: https://reviews.llvm.org/D67303
llvm-svn: 371266
Evandro Menezes [Fri, 6 Sep 2019 22:07:11 +0000 (22:07 +0000)]
[InstCombine] Refactor substitution of instruction in the parent BB (NFC)
Add the new method `LibCallSimplifier::substituteInParent()` that calls
`LibCallSimplifier::replaceAllUsesWith()' and
`LibCallSimplifier::eraseFromParent()` back to back, simplifying the
resulting code.
llvm-svn: 371264
Lang Hames [Fri, 6 Sep 2019 21:55:43 +0000 (21:55 +0000)]
[ORC][RPC] Join server thread before checking condition in unit test.
Otherwise we have a race on the sent-messages count.
llvm-svn: 371263
Nick Desaulniers [Fri, 6 Sep 2019 21:50:11 +0000 (21:50 +0000)]
[IR] CallBrInst: scan+update arg list when indirect dest list changes
Summary:
There's an unspoken invariant of callbr that the list of BlockAddress
Constants in the "function args" list match the BasicBlocks in the
"other labels" list. (This invariant is being added to the LangRef in
https://reviews.llvm.org/D67196).
When modifying the any of the indirect destinations of a callbr
instruction (possible jump targets), we need to update the function
arguments if the argument is a BlockAddress whose BasicBlock refers to
the indirect destination BasicBlock being replaced. Otherwise, many
transforms that modify successors will end up violating that invariant.
A recent change to the arm64 Linux kernel exposed this bug, which
prevents the kernel from booting.
I considered maintaining a mapping from indirect destination BasicBlock
to argument operand BlockAddress, but this ends up being a one to
potentially many (though usually one) mapping. Also, the list of
arguments to a function (or more typically inline assembly) ends up
being less than 10. The implementation is significantly simpler to just
rescan the full list of arguments. Because of the one to potentially
many relationship, the full arg list must be scanned (we can't stop at
the first instance).
Thanks to the following folks that reported the issue and helped debug
it:
* Nathan Chancellor
* Will Deacon
* Andrew Murray
* Craig Topper
Link: https://bugs.llvm.org/show_bug.cgi?id=43222
Link: https://github.com/ClangBuiltLinux/linux/issues/649
Link: https://lists.infradead.org/pipermail/linux-arm-kernel/2019-September/678330.html
Reviewers: craig.topper, chandlerc
Reviewed By: craig.topper
Subscribers: void, javed.absar, kristof.beyls, hiraditya, llvm-commits, nathanchance, srhines
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67252
llvm-svn: 371262
Craig Topper [Fri, 6 Sep 2019 21:49:01 +0000 (21:49 +0000)]
[X86] Add a AVX512VBMI command line to min-legal-vector-width.ll. Always enable fast-variable-shuffle
Trying to minimize the features we need to manipulate when this
is updated for D67259.
The VBMI is interesting because it enables some improved combining
for truncates.
I enabled fast-variable-shuffle because all the CPUs we're going
to add implicitly enable it. So they can share check lines.
llvm-svn: 371261
Craig Topper [Fri, 6 Sep 2019 21:48:44 +0000 (21:48 +0000)]
[X86] Replace -mcpu with -mattr on some tests.
llvm-svn: 371260
Jonas Devlieghere [Fri, 6 Sep 2019 21:43:33 +0000 (21:43 +0000)]
[test] Add a FIXME test for stop-command-source-on-error
Modifying the interpreter settings is tricky because they don't take
effect until we create a new command interpreter, which should be merely
an implementation detail. This leads to confusing and unexpected
scenarios.
This adds a test cases with FIXMEs for some of the odd scenarios I
encountered. I didn't XFAIL the test because I don't think there's a way
to get an unexpected PASS if any of the commands succeeds and splitting
up the file in multiple tests seems excessive.
llvm-svn: 371259
Alex Langford [Fri, 6 Sep 2019 21:05:21 +0000 (21:05 +0000)]
[Core] Remove use of ClangASTContext in DumpDataExtractor
Summary:
DumpDataExtractor uses ClangASTContext in order to get the proper llvm
fltSemantics for the type it needs so that it can dump floats in a more
precise way. However, there's no reason that this behavior needs to be
specific ClangASTContext. Instead, I think it makes sense to ask
TypeSystems for the float semantics for a type of a given size.
Differential Revision: https://reviews.llvm.org/D67239
llvm-svn: 371258
Artem Dergachev [Fri, 6 Sep 2019 20:55:29 +0000 (20:55 +0000)]
[analyzer] Add minimal support for fix-it hints.
Allow attaching fixit hints to Static Analyzer BugReports.
Fixits are attached either to the bug report itself or to its notes
(path-sensitive event notes or path-insensitive extra notes).
Add support for fixits in text output (including the default text output that
goes without notes, as long as the fixit "belongs" to the warning).
Add support for fixits in the plist output mode.
Implement a fixit for the path-insensitive DeadStores checker. Only dead
initialization warning is currently covered.
Implement a fixit for the path-sensitive VirtualCall checker when the virtual
method is not pure virtual (in this case the "fix" is to suppress the warning
by qualifying the call).
Both fixits are under an off-by-default flag for now, because they
require more careful testing.
Differential Revision: https://reviews.llvm.org/D65182
llvm-svn: 371257
Artem Dergachev [Fri, 6 Sep 2019 20:55:24 +0000 (20:55 +0000)]
[analyzer] pr43179: Make CallDescription defensive against C variadic functions.
Most functions that our checkers react upon are not C-style variadic functions,
and therefore they have as many actual arguments as they have formal parameters.
However, it's not impossible to define a variadic function with the same name.
This will crash any checker that relies on CallDescription to check the number
of arguments but silently assumes that the number of parameters is the same.
Change CallDescription to check both the number of arguments and the number of
parameters by default.
If we're intentionally trying to match variadic functions, allow specifying
arguments and parameters separately (possibly omitting any of them).
For now we only have one CallDescription which would make use of those,
namely __builtin_va_start itself.
Differential Revision: https://reviews.llvm.org/D67019
llvm-svn: 371256
Lang Hames [Fri, 6 Sep 2019 20:50:00 +0000 (20:50 +0000)]
[ORC] Add a missing #include atomic.
Hopefully this will fix the bot build failures from r371245.
llvm-svn: 371255
Matt Arsenault [Fri, 6 Sep 2019 20:49:10 +0000 (20:49 +0000)]
GlobalISel: Add G_FMAD instruction
llvm-svn: 371254
Matt Arsenault [Fri, 6 Sep 2019 20:32:37 +0000 (20:32 +0000)]
GlobalISel: Support physical register inputs in patterns
llvm-svn: 371253
Richard Smith [Fri, 6 Sep 2019 20:32:01 +0000 (20:32 +0000)]
Update comment for <template-param-decl> mangling to match extended mangling rule in r371004.
llvm-svn: 371252
Reid Kleckner [Fri, 6 Sep 2019 20:12:44 +0000 (20:12 +0000)]
Remove dead .seh_stackalloc parsing method in X86AsmParser
The shared COFF asm parser code handles this directive, since it is
shared with AArch64. Spotted by Alexandre Ganea in review.
llvm-svn: 371251
Jan Korous [Fri, 6 Sep 2019 20:08:32 +0000 (20:08 +0000)]
[clang][Index][NFC] Put IndexingOptions to a separate header
llvm-svn: 371250
Matt Arsenault [Fri, 6 Sep 2019 20:00:22 +0000 (20:00 +0000)]
AMDGPU: Fix typo
llvm-svn: 371249
Puyan Lotfi [Fri, 6 Sep 2019 19:59:59 +0000 (19:59 +0000)]
[llvm-ifs] Improving detection of PlatformKind from triple for TBD generation.
It was pointed out that I had hard-coded PlatformKind. This is rectifying that.
Differential Revision: https://reviews.llvm.org/D67255
llvm-svn: 371248
Sean Fertile [Fri, 6 Sep 2019 19:55:44 +0000 (19:55 +0000)]
[PowerPC][XCOFF] Remove basic test. [NFC]
Test verified that we could compile an empty module and produce an XCOFF
object file. Newer tests superssed this coverage, its safe to remove.
llvm-svn: 371247
Evandro Menezes [Fri, 6 Sep 2019 19:41:49 +0000 (19:41 +0000)]
[ConstantFolding] Add new test cases for transcendentals (NFC)
llvm-svn: 371246
Lang Hames [Fri, 6 Sep 2019 19:21:59 +0000 (19:21 +0000)]
[ORC] Make sure RPC channel-send is called in blocking calls and responses.
ORC-RPC batches calls by default, and the channel's send method must be called
to transfer any buffered calls to the remote. The call to send was missing on
responses and blocking calls in the SingleThreadedRPCEndpoint. This patch adds
the necessary calls and modifies the RPC unit test to check for them.
llvm-svn: 371245
Lang Hames [Fri, 6 Sep 2019 19:21:55 +0000 (19:21 +0000)]
[llvm-jitlink] Add optional slab allocator for testing locality optimizations.
The llvm-jitlink utility now accepts a '-slab-allocate <size>' option. If given,
llvm-jitlink will use a slab-based memory manager rather than the default
InProcessMemoryManager. Using a slab allocator will allow reliable testing of
future locality based optimizations (e.g. PLT and GOT elimination) in JITLink.
The <size> argument is a number, optionally followed by a units specifier (Kb,
Mb, or Gb). If the units are not given then the number is assumed to be in Kb.
llvm-svn: 371244
Craig Topper [Fri, 6 Sep 2019 19:17:02 +0000 (19:17 +0000)]
[X86] Use MOVSX by default instead of CBW to extend i8 to AX for i8 sdivrem.
We can use a MOVSX16 here then rely on FixupBWInst to change to
MOVSX32 if the upper bits are dead. With a special case to
not promote if it could be turned into CBW.
Then we can rely on X86MCInstLower to turn the MOVSX into CBW
very late if register allocation worked out.
Using MOVSX gives an opportunity to use the MOVSX as a both a
copy and a sign extend since the input and output register aren't
tied together.
Differential Revision: https://reviews.llvm.org/D67192
llvm-svn: 371243
Craig Topper [Fri, 6 Sep 2019 19:15:04 +0000 (19:15 +0000)]
[X86] Use MOVZX16rr8/MOVZXrm8 when extending input for i8 udivrem.
We can rely on X86FixupBWInsts to turn these into MOVZX32. This
simplifies a follow up commit to use MOVSX for i8 sdivrem with
a late optimization to use CBW when register allocation works out.
llvm-svn: 371242
Matthias Gehre [Fri, 6 Sep 2019 19:15:02 +0000 (19:15 +0000)]
[LifetimeAnalysis] don't use raw string literals in macros
They broke the AArch64 bots (gcc does not support it)
llvm-svn: 371241
Craig Topper [Fri, 6 Sep 2019 19:14:49 +0000 (19:14 +0000)]
[X86] Teach FixupBWInsts to turn MOVSX16rr8/MOVZX16rr8/MOVSX16rm8/MOVZX16rm8 into their 32-bit dest equivalents when the upper part of the register is dead.
llvm-svn: 371240
Sean Fertile [Fri, 6 Sep 2019 18:56:14 +0000 (18:56 +0000)]
[PowerPC][XCOFF] Verify symbol table in xcoff object files. [NFC]
Extend the common/local-common testing for object files to also verify the
symbol table now that the needed functionality has landed in llvm-readobj.
Differential Revision: https://reviews.llvm.org/D66944
llvm-svn: 371237
Evandro Menezes [Fri, 6 Sep 2019 18:24:21 +0000 (18:24 +0000)]
[ConstantFolding] Refactor functions not available before C99 (NFC)
Note the cases when calling a function at compile time may fail if the host
does not support the C99 run time library.
llvm-svn: 371236
Kevin P. Neal [Fri, 6 Sep 2019 18:04:34 +0000 (18:04 +0000)]
[FPEnv] Teach the IRBuilder about constrained FPToSI and FPToUI.
The IRBuilder doesn't know that the two floating point to integer instructions
have constrained equivalents. This patch adds the support by building on
the strict FP mode now present in the IRBuilder.
Reviewed by: John McCall
Approved by: John McCall
Differential Revision: https://reviews.llvm.org/D67291
llvm-svn: 371235
Jan Kratochvil [Fri, 6 Sep 2019 17:52:27 +0000 (17:52 +0000)]
[lldb] Small optimization of FormatMap::Delete and FormatMap::Get
llvm-svn: 371234
Francis Visoiu Mistrih [Fri, 6 Sep 2019 17:22:51 +0000 (17:22 +0000)]
[Remarks] Add support for internalizing a remark in a string table
In order to keep remarks around, we need to make them tied to a string
table.
Users then can delete the parser and rely on the string table to keep
the memory of the strings alive and deduplicated.
llvm-svn: 371233
Oliver Cruickshank [Fri, 6 Sep 2019 17:02:42 +0000 (17:02 +0000)]
[ARM] Add patterns for VSUB with q and r registers
Added patterns for VSUB to support q and r registers, which reduces
pressure on q registers.
llvm-svn: 371231
Oliver Cruickshank [Fri, 6 Sep 2019 17:02:35 +0000 (17:02 +0000)]
[ARM] Add patterns for VADD with q and r registers
Added support for VADD to use q and r registers, which reduces pressure
on q registers.
llvm-svn: 371230
Oliver Cruickshank [Fri, 6 Sep 2019 17:02:21 +0000 (17:02 +0000)]
[ARM] Add patterns for VMUL with q and r registers
Added support for VMUL to use an r register, this reduces pressure on
the q registers.
llvm-svn: 371229
Evandro Menezes [Fri, 6 Sep 2019 16:49:49 +0000 (16:49 +0000)]
[ConstantFolding] Refactor function match for better speed (NFC)
Use an `enum` instead of string comparison to match the candidate function.
llvm-svn: 371228
Jessica Paquette [Fri, 6 Sep 2019 16:49:13 +0000 (16:49 +0000)]
[AArch64][GlobalISel] Always fall back on tail calls with -tailcallopt
-tailcallopt requires that we perform different stack adjustments than with
sibling calls. For example, the `@caller_to0_from8` function in
test/CodeGen/AArch64/tail-call.ll requires that we adjust SP. Without
-tailcallopt, this adjustment does not happen. With it, however, it is expected.
So, to ensure that adding sibling call support doesn't break -tailcallopt,
make CallLowering always fall back on possible tail calls when -tailcallopt
is passed in.
Update test/CodeGen/AArch64/tail-call.ll with a GlobalISel line to make sure
that we don't differ from the SDAG implementation at any point.
Differential Revision: https://reviews.llvm.org/D67245
llvm-svn: 371227
David Bolvansky [Fri, 6 Sep 2019 16:30:44 +0000 (16:30 +0000)]
[NFCI] Unbreak buildbots
llvm-svn: 371226
Fangrui Song [Fri, 6 Sep 2019 16:30:22 +0000 (16:30 +0000)]
[ELF] Replace error() with errorOrWarn() for the ASSERT command
Summary:
ld.bfd produces an output with --noinhibit-exec when an ASSERT fails.
Use errorOrWarn() so that we can produce an output as well.
An interesting case is that symbol assignments may execute multiple
times, so we probably want to suppress errors for non-final runs.
Reviewed By: peter.smith
Differential Revision: https://reviews.llvm.org/D67285
llvm-svn: 371225
JF Bastien [Fri, 6 Sep 2019 16:26:59 +0000 (16:26 +0000)]
[InstCombine] pow(x, +/- 0.0) -> 1.0
Summary:
This isn't an important optimization at all... We're already doing:
pow(x, 0.0) -> 1.0
My patch merely teaches instcombine that -0.0 does the same.
However, doing this fixes an AMAZING bug! Compile this program:
extern "C" double pow(double, double);
double boom(double base) {
return pow(base, -0.0);
}
With:
clang++ ~/Desktop/fast-math.cpp -ffast-math -O2 -S
And clang will crash with a signal. Wow, fast math is so fast it ICEs the
compiler! Arguably, the generated math is infinitely fast.
What's actually happening is that we recurse infinitely in getPow. In debug we
hit its assertion:
assert(Exp != 0 && "Incorrect exponent 0 not handled");
We avoid this entire mess if we instead recognize that an exponent of positive
and negative zero yield 1.0.
A separate commit, r371221, fixed the same problem. This only contains the added
tests.
<rdar://problem/
54598300>
Reviewers: scanon
Subscribers: hiraditya, jkorous, dexonsmith, ributzka, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67248
llvm-svn: 371224
David Bolvansky [Fri, 6 Sep 2019 16:18:18 +0000 (16:18 +0000)]
[NFC] Added new tests for r371222
llvm-svn: 371223
David Bolvansky [Fri, 6 Sep 2019 16:12:48 +0000 (16:12 +0000)]
[Diagnostics] Refactor code for -Wsizeof-pointer-div, catch more cases; also add -Wsizeof-array-div
Previously, -Wsizeof-pointer-div failed to catch:
const int *r;
sizeof(r) / sizeof(int);
Now fixed.
Also introduced -Wsizeof-array-div which catches bugs like:
sizeof(r) / sizeof(short);
(Array element type does not match type of sizeof operand).
llvm-svn: 371222
Sanjay Patel [Fri, 6 Sep 2019 16:10:18 +0000 (16:10 +0000)]
[SimplifyLibCalls] handle pow(x,-0.0) before it can assert (PR43233)
https://bugs.llvm.org/show_bug.cgi?id=43233
llvm-svn: 371221
Sam Tebbs [Fri, 6 Sep 2019 16:01:32 +0000 (16:01 +0000)]
[ARM] Sink add/mul(shufflevector(insertelement())) for MVE instruction selection
This patch sinks add/mul(shufflevector(insertelement())) into the basic block in which they are used so that they can then be selected together.
This is useful for various MVE instructions, such as vmla and others that take R registers.
Loop tests have been added to the vmla test file to make sure vmlas are generated in loops.
Differential revision: https://reviews.llvm.org/D66295
llvm-svn: 371218
Fangrui Song [Fri, 6 Sep 2019 15:57:44 +0000 (15:57 +0000)]
Reland D66717 [ELF] Do not ICF two sections with different output sections (by SECTIONS commands)
Recommit r370635 (reverted by r371202), with one change: move addOrphanSections() before ICF.
Before, orphan sections in two different partitions may be folded and
moved to the main partition.
Now, InputSection->OutputSection assignment for orphans happens before
ICF. ICF does not fold input sections with different output sections.
With the PR43241 reproduce,
`llvm-objcopy --extract-partition libvr.so libchrome__combined.so libvr.so` => no error
Updated description:
Fixes PR39418. Complements D47241 (the non-linker-script case).
processSectionCommands() assigns input sections to output sections.
ICF is called before it, so .text.foo and .text.bar may be folded even if
their output sections are made different by SECTIONS commands.
```
markLive<ELFT>()
doIcf<ELFT>() // During ICF, we don't know the output sections
writeResult()
combineEhSections<ELFT>()
script->processSectionCommands() // InputSection -> OutputSection assignment
```
This patch splits processSectionCommands() into processSectionCommands()
and processSymbolAssignments(), and moves
processSectionCommands()/addOrphanSections() before ICF:
```
markLive<ELFT>()
combineEhSections<ELFT>()
script->processSectionCommands()
script->addOrphanSections();
doIcf<ELFT>() // should remove folded input sections
writeResult()
script->processSymbolAssignments()
```
An alternative approach is to unfold a section `sec` in
processSectionCommands() when we find `sec` and `sec->repl` belong to
different output sections. I feel this patch is superior because this
can fold more sections and the decouple of
SectionCommand/SymbolAssignment gives flexibility:
* An ExprValue can't be evaluated before its section is assigned to an
output section -> we can delete getOutputSectionVA and simplify
another place where we had to check if the output section is null.
Moreover, a case in linkerscript/early-assign-symbol.s can be handled
now.
* processSectionCommands/processSymbolAssignments can be freely moved
around.
llvm-svn: 371216
Fangrui Song [Fri, 6 Sep 2019 15:57:24 +0000 (15:57 +0000)]
Revert "Revert r370635, it caused PR43241."
This reverts commit
50d2dca22b3b05d0ee4883b0cbf93d7d15f241fc.
llvm-svn: 371215
Valery Pykhtin [Fri, 6 Sep 2019 15:33:53 +0000 (15:33 +0000)]
[AMDGPU] Enable constant offset promotion to immediate operand for VMEM stores
Differential revision: https://reviews.llvm.org/D66958
llvm-svn: 371214
Fangrui Song [Fri, 6 Sep 2019 15:10:31 +0000 (15:10 +0000)]
[ELF][test] Simplify and reorganize tests
Add file-level comments
Delete insignificant addresses to make them more tolerant to layout changes
Simplify test output
Delete simple Inputs/*.s files
Delete version-script-copy-rel.s - covered by verdef-defaultver.s
Delete version-wildcard.test - covered by version-script-glob.s
llvm-svn: 371213
Guillaume Chatelet [Fri, 6 Sep 2019 15:03:49 +0000 (15:03 +0000)]
[Alignment][NFC] Use Align with TargetLowering::setPrefFunctionAlignment
Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790
Reviewers: courbet
Subscribers: nemanjai, javed.absar, hiraditya, kbarton, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, jsji, s.egerton, pzheng, ychen, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67267
llvm-svn: 371212
Cyndy Ishida [Fri, 6 Sep 2019 15:02:22 +0000 (15:02 +0000)]
[Object] remove struct constructor, NFC
Summary: make POD struct by removing ctors
Reviewers: avl, dblaikie
Reviewed By: dblaikie
Subscribers: ributzka, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67251
llvm-svn: 371211
Guillaume Chatelet [Fri, 6 Sep 2019 14:51:15 +0000 (14:51 +0000)]
[Alignment][NFC] Use Align with TargetLowering::setPrefLoopAlignment
Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790
Reviewers: courbet
Subscribers: nemanjai, hiraditya, kbarton, MaskRay, jsji, ychen, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67278
llvm-svn: 371210
Roman Lebedev [Fri, 6 Sep 2019 14:19:04 +0000 (14:19 +0000)]
[NFC][CodeGen][UBSan] EmitCheckedInBoundsGEP(): pass a vector to EmitCheck()
Will be easier to add a new 'check' in a follow-up.
This was originally part of https://reviews.llvm.org/D67122
llvm-svn: 371208
Roman Lebedev [Fri, 6 Sep 2019 14:18:57 +0000 (14:18 +0000)]
[NFC][CodeGen][UBSan] EmitCheckedInBoundsGEP(): refactor EmitGEPOffsetInBytes() helper
It shouldn't really be inlined into the EmitCheckedInBoundsGEP().
Refactoring it beforehand will make follow-up changes more obvious.
This was originally part of https://reviews.llvm.org/D67122
llvm-svn: 371207
Roman Lebedev [Fri, 6 Sep 2019 14:18:49 +0000 (14:18 +0000)]
[NFC][CodeGen][UBSan] EmitCheckedInBoundsGEP(): add some comments to pointer-overflow check
It's rather eye-twiching, some comments may help here..
This was originally part of https://reviews.llvm.org/D67122
llvm-svn: 371206
Nico Weber [Fri, 6 Sep 2019 13:57:12 +0000 (13:57 +0000)]
libclang depends on ClangDriverOptions since r352803
Without this, the build would sometimes fail with
In file included from clang/tools/libclang/CIndexer.cpp:17:
In file included from clang/include/clang/Driver/Driver.h:15:
clang/include/clang/Driver/Options.h:44:10: fatal error:
'clang/Driver/Options.inc' file not found
#include "clang/Driver/Options.inc"
^~~~~~~~~~~~~~~~~
if Options.inc wasn't generated before libclang was built
by coincidence.
(In the GN build, this works because lib/Driver there declares
the dep on tablegen as a public_dep since the generated file
is part of Driver's public interface, and then things work out
automatically without every client of Driver having to be careful.)
llvm-svn: 371205
Guillaume Chatelet [Fri, 6 Sep 2019 13:54:09 +0000 (13:54 +0000)]
[Alignment] fix dubious min function alignment
Summary:
This was discovered while introducing the llvm::Align type.
The original setMinFunctionAlignment used to take alignment as log2, looking at the comment it seems like instructions are to be 2-bytes aligned and not 4-bytes aligned.
Reviewers: uweigand
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67271
llvm-svn: 371204
Nico Weber [Fri, 6 Sep 2019 13:23:42 +0000 (13:23 +0000)]
Revert r370635, it caused PR43241.
llvm-svn: 371202
George Rimar [Fri, 6 Sep 2019 13:05:34 +0000 (13:05 +0000)]
[llvm-readelf] - Print unknown st_other value if present in GNU output.
This is a fix for https://bugs.llvm.org/show_bug.cgi?id=40785.
llvm-readelf does not print the st_value of the symbol when
st_value has any non-visibility bits set.
This patch:
* Aligns "Ndx" row for the default and a new cases.
(it was 1 space character off for the case when "PROTECTED" visibility was printed)
* Prints "[<other>: 0x??]" for symbols which has an additional st_other bits set.
In compare with GNU, this logic is a bit simpler and seems to be more consistent.
For MIPS GNU can print named flags, though can't print a mix of them:
0:
00000000 0 NOTYPE LOCAL DEFAULT UND
1:
00000000 0 NOTYPE GLOBAL DEFAULT [OPTIONAL] UND a1
2:
00000000 0 NOTYPE GLOBAL DEFAULT [MIPS PLT] UND a2
3:
00000000 0 NOTYPE GLOBAL DEFAULT [MIPS PIC] UND a3
4:
00000000 0 NOTYPE GLOBAL DEFAULT [MICROMIPS] UND a4
5:
00000000 0 NOTYPE GLOBAL DEFAULT [MIPS16] UND a5
6:
00000000 0 NOTYPE GLOBAL DEFAULT [<other>: c] UND b1
7:
00000000 0 NOTYPE GLOBAL DEFAULT [<other>: 28] UND b2
On PPC64 it can print a localentry value that is encoded in the high bits of st_other
63:
0000000000000850 208 FUNC GLOBAL DEFAULT [<localentry>: 8] 12
We chose to print the raw st_other field, prefixed with '0x'.
Differential revision: https://reviews.llvm.org/D67094
llvm-svn: 371201
Guillaume Chatelet [Fri, 6 Sep 2019 12:48:34 +0000 (12:48 +0000)]
[Alignment][NFC] Use Align with TargetLowering::setMinFunctionAlignment
Summary:
This is patch is part of a series to introduce an Alignment type.
See this thread for context: http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790
Reviewers: courbet
Subscribers: jyknight, sdardis, nemanjai, javed.absar, hiraditya, kbarton, fedor.sergeev, asb, rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, jrtc27, MaskRay, zzheng, edward-jones, atanasyan, rogfer01, MartinMosbeck, brucehoult, the_o, PkmX, jocewei, jsji, s.egerton, pzheng, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67229
llvm-svn: 371200
Djordje Todorovic [Fri, 6 Sep 2019 12:23:37 +0000 (12:23 +0000)]
[test] Update the name of the debug entry values option. NFC
llvm-svn: 371199
James Molloy [Fri, 6 Sep 2019 12:20:08 +0000 (12:20 +0000)]
[DFAPacketizer] Track resources for packetized instructions
This patch allows the DFAPacketizer to be queried after a packet is formed to work out which
resources were allocated to the packetized instructions.
This is particularly important for targets that do their own bundle packing - it's not
sufficient to know simply that instructions can share a packet; which slots are used is
also required for encoding.
This extends the emitter to emit a side-table containing resource usage diffs for each
state transition. The packetizer maintains a set of all possible resource states in its
current state. After packetization is complete, all remaining resource states are
possible packetization strategies.
The sidetable is only ~500K for Hexagon, but the extra tracking is disabled by default
(most uses of the packetizer like MachinePipeliner don't care and don't need the extra
maintained state).
Differential Revision: https://reviews.llvm.org/D66936
llvm-svn: 371198
Serge Guelton [Fri, 6 Sep 2019 11:06:23 +0000 (11:06 +0000)]
Remove call to obsolete gethostbyname, using getaddrinfo
Differential Revision: https://reviews.llvm.org/D67230
llvm-svn: 371195
Haojian Wu [Fri, 6 Sep 2019 10:24:39 +0000 (10:24 +0000)]
[clangd] Use override keyword to override the base class method, NFC
llvm-svn: 371194
Jeremy Morse [Fri, 6 Sep 2019 10:08:22 +0000 (10:08 +0000)]
[DebugInfo] LiveDebugValues: explicitly terminate overwritten stack locations
If a stack spill location is overwritten by another spill instruction,
any variable locations pointing at that slot should be terminated. We
cannot rely on spills always being restored to registers or variable
locations being moved by a DBG_VALUE: the register allocator is entitled
to spill a value and then forget about it when it goes out of liveness.
To address this, scan for memory writes to spill locations, even those we
don't consider to be normal "spills". isSpillInstruction and
isLocationSpill distinguish the two now. After identifying spill
overwrites, terminate the open range, and insert a $noreg DBG_VALUE for
that variable.
Differential Revision: https://reviews.llvm.org/D66941
llvm-svn: 371193
Jay Foad [Fri, 6 Sep 2019 10:07:28 +0000 (10:07 +0000)]
[AMDGPU] Mark s_barrier as having side effects but not accessing memory.
Summary:
This fixes poor scheduling in a function containing a barrier and a few
load instructions.
Without this fix, ScheduleDAGInstrs::buildSchedGraph adds an artificial
edge in the dependency graph from the barrier instruction to the exit
node representing live-out latency, with a latency of about 500 cycles.
Because of this it thinks the critical path through the graph also has
a latency of about 500 cycles. And because of that it does not think
that any of the load instructions are on the critical path, so it
schedules them with no regard for their (80 cycle) latency, which gives
poor results.
Reviewers: arsenm, dstuttard, tpr, nhaehnle
Subscribers: kzhuravl, jvesely, wdng, yaxunl, t-tye, hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67218
llvm-svn: 371192
Nico Weber [Fri, 6 Sep 2019 09:44:13 +0000 (09:44 +0000)]
gn build: Merge r371182
llvm-svn: 371191
Nico Weber [Fri, 6 Sep 2019 09:44:10 +0000 (09:44 +0000)]
gn build: Merge r371179
llvm-svn: 371190
Fangrui Song [Fri, 6 Sep 2019 09:39:48 +0000 (09:39 +0000)]
[ELF][test] Update test after r371185
llvm-svn: 371189
Sam Parker [Fri, 6 Sep 2019 09:36:23 +0000 (09:36 +0000)]
[ARM] Fix for buildbot
llvm-svn: 371187
Fangrui Song [Fri, 6 Sep 2019 09:23:17 +0000 (09:23 +0000)]
[yaml2obj] Rename SHOffset (e_shoff) field to SHOff. NFC
`struct Elf*_Shdr` has a field `sh_offset`, named `ShOffset` in
llvm::ELFYAML::Section. Rename SHOffset (e_shoff) to SHOff to prevent confusion.
Reviewed By: grimar
Differential Revision: https://reviews.llvm.org/D67254
llvm-svn: 371185
Matthias Gehre [Fri, 6 Sep 2019 08:56:30 +0000 (08:56 +0000)]
Reland [LifetimeAnalysis] Support more STL idioms (template forward declaration and DependentNameType)
Reland after https://reviews.llvm.org/D66806 fixed the false-positive diagnostics.
Summary:
This fixes inference of gsl::Pointer on std::set::iterator with libstdc++ (the typedef for iterator
on the template is a DependentNameType - we can only put the gsl::Pointer attribute
on the underlaying record after instantiation)
inference of gsl::Pointer on std::vector::iterator with libc++ (the class was forward-declared,
we added the gsl::Pointer on the canonical decl (the forward decl), and later when the
template was instantiated, there was no attribute on the definition so it was not instantiated).
and a duplicate gsl::Pointer on some class with libstdc++ (we first added an attribute to
a incomplete instantiation, and then another was copied from the template definition
when the instantiation was completed).
We now add the attributes to all redeclarations to fix thos issues and make their usage easier.
Reviewers: gribozavr
Subscribers: Szelethus, xazax.hun, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66179
llvm-svn: 371182