OSDN Git Service
Konstantin Zhuravlyov [Mon, 15 Oct 2018 20:37:47 +0000 (20:37 +0000)]
AMDGPU: Generate .amdgcn_target for object code v3
Differential Revision: https://reviews.llvm.org/D53221
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344552
91177308-0d34-0410-b5e6-
96231b3b80d8
Jordan Rupprecht [Mon, 15 Oct 2018 20:15:58 +0000 (20:15 +0000)]
[llvm-objcopy] NFC: update TODO test comment
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344550
91177308-0d34-0410-b5e6-
96231b3b80d8
Vedant Kumar [Mon, 15 Oct 2018 19:22:20 +0000 (19:22 +0000)]
[CodeExtractor] Erase debug intrinsics in outlined thunks (fix PR22900)
Variable updates within the outlined function are invisible to
debuggers. This could be improved by defining a DISubprogram for the
new function. For the moment, simply erase the debug intrinsics instead.
This fixes verifier failures about function-local metadata being used in
the wrong function, seen while testing the hot/cold splitting pass.
rdar://
45142482
Differential Revision: https://reviews.llvm.org/D53267
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344545
91177308-0d34-0410-b5e6-
96231b3b80d8
Lang Hames [Mon, 15 Oct 2018 18:34:36 +0000 (18:34 +0000)]
[ADT] Fix a bug in DenseSet's initializer_list constructor.
Without this fix, DenseSet crashes with an assertion if constructed with an
initializer_list whose length is not a power of two.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344542
91177308-0d34-0410-b5e6-
96231b3b80d8
Sanjay Patel [Mon, 15 Oct 2018 18:05:34 +0000 (18:05 +0000)]
[SelectionDAG] allow FP binops in SimplifyDemandedVectorElts
This is intended to make the backend on par with functionality that was
added to the IR version of SimplifyDemandedVectorElts in:
rL343727
...and the original motivation is that we need to improve demanded-vector-elements
in several ways to avoid problems that would be exposed in D51553.
Differential Revision: https://reviews.llvm.org/D52912
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344541
91177308-0d34-0410-b5e6-
96231b3b80d8
Sanjay Patel [Mon, 15 Oct 2018 16:54:07 +0000 (16:54 +0000)]
[DAGCombiner] allow undef elts in vector fmul matching
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344534
91177308-0d34-0410-b5e6-
96231b3b80d8
Sanjay Patel [Mon, 15 Oct 2018 16:47:01 +0000 (16:47 +0000)]
[DAGCombiner] refactor folds for fadd (fmul X, -2.0), Y; NFCI
The transform doesn't work if the vector constant has undef elements.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344532
91177308-0d34-0410-b5e6-
96231b3b80d8
Sanjay Patel [Mon, 15 Oct 2018 16:44:00 +0000 (16:44 +0000)]
[AArch64] add tests for fmul x, -2.0 with undef elts; NFC
Also, add tests with commuted operands. There was no coverage for that case.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344531
91177308-0d34-0410-b5e6-
96231b3b80d8
Sanjay Patel [Mon, 15 Oct 2018 15:56:39 +0000 (15:56 +0000)]
[DAGCombiner] allow undef elts in vector fma matching
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344528
91177308-0d34-0410-b5e6-
96231b3b80d8
Sanjay Patel [Mon, 15 Oct 2018 15:47:37 +0000 (15:47 +0000)]
[x86] add tests for fma with undef elts; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344527
91177308-0d34-0410-b5e6-
96231b3b80d8
Sanjay Patel [Mon, 15 Oct 2018 15:38:38 +0000 (15:38 +0000)]
[DAGCombiner] allow undef elts in vector fma matching
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344525
91177308-0d34-0410-b5e6-
96231b3b80d8
Fedor Sergeev [Mon, 15 Oct 2018 15:36:08 +0000 (15:36 +0000)]
Revert "[NewPM] teach -passes= to emit meaningful error messages"
This reverts r344519 due to failures in pipeline-parsing test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344524
91177308-0d34-0410-b5e6-
96231b3b80d8
Sanjay Patel [Mon, 15 Oct 2018 15:28:44 +0000 (15:28 +0000)]
[x86] add tests for fma with undef elts; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344523
91177308-0d34-0410-b5e6-
96231b3b80d8
Lang Hames [Mon, 15 Oct 2018 15:26:47 +0000 (15:26 +0000)]
[ADT] Adds equality operators for DenseMap and DenseSet, and an initializer_list
constructor for DenseMap (DenseSet already had an initializer_list constructor).
These changes make it easier to migrate existing code that uses std::map and
std::set (which support initializer_list construction and equality comparison)
to DenseMap and DenseSet.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344522
91177308-0d34-0410-b5e6-
96231b3b80d8
Fedor Sergeev [Mon, 15 Oct 2018 15:00:18 +0000 (15:00 +0000)]
[NewPM] teach -passes= to emit meaningful error messages
Summary:
All the PassBuilder::parse interfaces now return descriptive StringError
instead of a plain bool. It allows to make -passes/aa-pipeline parsing
errors context-specific and thus less confusing.
TODO: ideally we should also make suggestions for misspelled pass names,
but that requires some extensions to PassBuilder.
Reviewed By: philip.pfaffe, chandlerc
Differential Revision: https://reviews.llvm.org/D53246
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344519
91177308-0d34-0410-b5e6-
96231b3b80d8
Aleksandar Beserminji [Mon, 15 Oct 2018 14:39:12 +0000 (14:39 +0000)]
[mips][micromips] Fix overlaping FDEs error
When compiling static executable for micromips, CFI symbols
are incorrectly labeled as MICROMIPS, which cause
".eh_frame_hdr refers to overlapping FDEs." error.
This patch does not label CFI symbols as MICROMIPS, and FDEs do not
overlap anymore. This patch also exposes another bug, which is fixed
here: https://reviews.llvm.org/D52985
Differential Revision: https://reviews.llvm.org/D52987
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344516
91177308-0d34-0410-b5e6-
96231b3b80d8
Aleksandar Beserminji [Mon, 15 Oct 2018 14:36:48 +0000 (14:36 +0000)]
[mips][micromips] Revert "Fix overlaping FDEs error"
This reverts r344511.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344515
91177308-0d34-0410-b5e6-
96231b3b80d8
Simon Pilgrim [Mon, 15 Oct 2018 13:20:41 +0000 (13:20 +0000)]
[ARM][NEON] Improve vector popcnt lowering with PADDL (PR39281)
As I suggested on PR39281, this patch uses PADDL pairwise addition to widen from the vXi8 CTPOP result to the target vector type.
This is a blocker for moving more x86 code to generic vector CTPOP expansion (P32655 + D53258) - ARM's vXi64 CTPOP currently expands, which would generate a vXi64 MUL but ARM's custom lowering expands the general MUL case and vectors aren't well handled in LegalizeDAG - improving the CTPOP lowering was a lot easier than fixing the MUL lowering for this one case......
Differential Revision: https://reviews.llvm.org/D53257
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344512
91177308-0d34-0410-b5e6-
96231b3b80d8
Aleksandar Beserminji [Mon, 15 Oct 2018 12:59:17 +0000 (12:59 +0000)]
[mips][micromips] Fix overlaping FDEs error
When compiling static executable for micromips, CFI symbols
are incorrectly labeled as MICROMIPS, which cause
".eh_frame_hdr refers to overlapping FDEs." error.
This patch does not label CFI symbols as MICROMIPS, and FDEs do not
overlap anymore. This patch also exposes another bug, which is fixed
here: https://reviews.llvm.org/D52985
Differential Revision: https://reviews.llvm.org/D52987
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344511
91177308-0d34-0410-b5e6-
96231b3b80d8
Nicolai Haehnle [Mon, 15 Oct 2018 11:37:04 +0000 (11:37 +0000)]
AMDGPU: Test showing a scalar buffer load deficiency
Change-Id: I5b64a565f22a8482aa0712488d85e45163ac3d12
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344506
91177308-0d34-0410-b5e6-
96231b3b80d8
Fedor Sergeev [Mon, 15 Oct 2018 10:46:35 +0000 (10:46 +0000)]
[NewPM] implement SCC printing for -print-before-all/-print-after-all
Removing deficiency of initial implementation of -print-before-all/-after-all
- it was effectively skipping IR printing for all the SCC passes.
Now LazyCallGraph:SCC gets its IR printed.
Reviewed By: skatkov
Differential Revision: https://reviews.llvm.org/D53270
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344505
91177308-0d34-0410-b5e6-
96231b3b80d8
Chandler Carruth [Mon, 15 Oct 2018 10:42:50 +0000 (10:42 +0000)]
[TI removal] Make `getTerminator()` return a generic `Instruction`.
This removes the primary remaining API producing `TerminatorInst` which
will reduce the rate at which code is introduced trying to use it and
generally make it much easier to remove the remaining APIs across the
codebase.
Also clean up some of the stragglers that the previous mechanical update
of variables missed.
Users of LLVM and out-of-tree code generally will need to update any
explicit variable types to handle this. Replacing `TerminatorInst` with
`Instruction` (or `auto`) almost always works. Most of these edits were
made in prior commits using the perl one-liner:
```
perl -i -ple 's/TerminatorInst(\b.* = .*getTerminator\(\))/Instruction\1/g'
```
This also my break some rare use cases where people overload for both
`Instruction` and `TerminatorInst`, but these should be easily fixed by
removing the `TerminatorInst` overload.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344504
91177308-0d34-0410-b5e6-
96231b3b80d8
Chandler Carruth [Mon, 15 Oct 2018 10:10:54 +0000 (10:10 +0000)]
[TI removal] Rework `InstVisitor` to support visiting instructions that
are terminators without relying on the specific `TerminatorInst` type.
This required cleaning up two users of `InstVisitor`s usage of
`TerminatorInst` as well.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344503
91177308-0d34-0410-b5e6-
96231b3b80d8
Chandler Carruth [Mon, 15 Oct 2018 10:04:59 +0000 (10:04 +0000)]
[TI removal] Make variables declared as `TerminatorInst` and initialized
by `getTerminator()` calls instead be declared as `Instruction`.
This is the biggest remaining chunk of the usage of `getTerminator()`
that insists on the narrow type and so is an easy batch of updates.
Several files saw more extensive updates where this would cascade to
requiring API updates within the file to use `Instruction` instead of
`TerminatorInst`. All of these were trivial in nature (pervasively using
`Instruction` instead just worked).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344502
91177308-0d34-0410-b5e6-
96231b3b80d8
Chandler Carruth [Mon, 15 Oct 2018 10:00:15 +0000 (10:00 +0000)]
[TI removal] Remove `TerminatorInst` from GVN.h and GVN.cpp.
This is the last interesting usage in all of LLVM's headers. The
remaining usages in headers are the core typesystem bits (Core.h,
instruction types, and InstVisitor) and as the return of
`BasicBlock::getTerminator`. The latter is the big remaining API point
that I'll remove after mass updates to user code.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344501
91177308-0d34-0410-b5e6-
96231b3b80d8
Chandler Carruth [Mon, 15 Oct 2018 09:47:26 +0000 (09:47 +0000)]
[TI removal] Remove `TerminatorInst` from SparsePropagation.h and
related code.
This is simple as we just need to replace the type and move to the
concept of visiting a "terminator" rather than a specific instruction
subclass.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344500
91177308-0d34-0410-b5e6-
96231b3b80d8
Chandler Carruth [Mon, 15 Oct 2018 09:34:31 +0000 (09:34 +0000)]
[TI removal] Remove a dead forward declaration of TerminatorInst. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344499
91177308-0d34-0410-b5e6-
96231b3b80d8
Chandler Carruth [Mon, 15 Oct 2018 09:34:05 +0000 (09:34 +0000)]
[TI removal] Remove `TerminatorInst` from BasicBlockUtils.h
This requires updating a number of .cpp files to adapt to the new API.
I've just systematically updated all uses of `TerminatorInst` within
these files te `Instruction` so thta I won't have to touch them again in
the future.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344498
91177308-0d34-0410-b5e6-
96231b3b80d8
Chandler Carruth [Mon, 15 Oct 2018 09:33:40 +0000 (09:33 +0000)]
[TI removal] Just use Instruction in the CFG printer code. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344497
91177308-0d34-0410-b5e6-
96231b3b80d8
Guillaume Chatelet [Mon, 15 Oct 2018 09:21:21 +0000 (09:21 +0000)]
[llvm-exegesis] Fix missing std::move.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344496
91177308-0d34-0410-b5e6-
96231b3b80d8
Chandler Carruth [Mon, 15 Oct 2018 09:17:38 +0000 (09:17 +0000)]
[TI removal] Remove a unnecessary use of `TerminatorInst` from an IR
header. NFC.
Part of the removal of `TerminatorInst` from the type hierarchy.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344495
91177308-0d34-0410-b5e6-
96231b3b80d8
Chandler Carruth [Mon, 15 Oct 2018 09:17:09 +0000 (09:17 +0000)]
[TI removal] Remove TerminatorInst as an input parameter from all public
LLVM APIs. There weren't very many.
We still have the instruction visitor, and APIs with TerminatorInst as
a return type or an output parameter.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344494
91177308-0d34-0410-b5e6-
96231b3b80d8
Guillaume Chatelet [Mon, 15 Oct 2018 09:09:19 +0000 (09:09 +0000)]
[llvm-exegesis][NFC] Return many CodeTemplates instead of one.
Summary: This is part one of the change where I simply changed the signature of the functions. More work need to be done to actually produce more than one CodeTemplate per instruction.
Reviewers: courbet
Subscribers: tschuett, llvm-commits
Differential Revision: https://reviews.llvm.org/D53209
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344493
91177308-0d34-0410-b5e6-
96231b3b80d8
Bjorn Pettersson [Mon, 15 Oct 2018 08:36:03 +0000 (08:36 +0000)]
[TwoAddressInstructionPass] Replace subregister uses when processing tied operands
Summary:
TwoAddressInstruction pass typically rewrites
%1:short = foo %0.sub_lo:long
as
%1:short = COPY %0.sub_lo:long
%1:short = foo %1:short
when having tied operands.
If there are extra un-tied operands that uses the same reg and
subreg, such as the second and third inputs to fie here:
%1:short = fie %0.sub_lo:long, %0.sub_hi:long, %0.sub_lo:long
then there was a bug which replaced the register %0 also for
the un-tied operand, but without changing the subregister indices.
So we used to get:
%1:short = COPY %0.sub_lo:long
%1:short = fie %1, %1.sub_hi:short, %1.sub_lo:short
With this fix we instead get:
%1:short = COPY %0.sub_lo:long
%1:short = fie %1, %0.sub_hi:long, %1
Reviewers: arsenm, JesperAntonsson, kparzysz, MatzeB
Reviewed By: MatzeB
Subscribers: bjope, kparzysz, wdng, llvm-commits
Differential Revision: https://reviews.llvm.org/D36224
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344492
91177308-0d34-0410-b5e6-
96231b3b80d8
Craig Topper [Mon, 15 Oct 2018 05:31:24 +0000 (05:31 +0000)]
[X86] Autogenerate checks. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344490
91177308-0d34-0410-b5e6-
96231b3b80d8
Lang Hames [Mon, 15 Oct 2018 05:07:54 +0000 (05:07 +0000)]
[ORC] Simplify naming for JITDylib definition generators.
Renames:
JITDylib's setFallbackDefinitionGenerator method to setGenerator.
DynamicLibraryFallbackGenerator class to DynamicLibrarySearchGenerator.
ReexportsFallbackDefinitionGenerator to ReexportsGenerator.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344489
91177308-0d34-0410-b5e6-
96231b3b80d8
Craig Topper [Mon, 15 Oct 2018 01:51:58 +0000 (01:51 +0000)]
[X86] Move promotion of vector and/or/xor from legalization to DAG combine
Summary:
I've noticed that the bitcasts we introduce for these make computeKnownBits and computeNumSignBits not work well in LegalizeVectorOps. LegalizeVectorOps legalizes bottom up while LegalizeDAG legalizes top down. The bottom up strategy for LegalizeVectorOps means operands are legalized before their uses. So we promote and/or/xor before we legalize the operands that use them making computeKnownBits/computeNumSignBits in places like LowerTruncate suboptimal. I looked at changing LegalizeVectorOps to be top down as well, but that was more disruptive and caused some regressions. I also looked at just moving promotion of binops to LegalizeDAG, but that had a few issues one around matching AND,ANDN,OR into VSELECT because I had to create ANDN as vXi64, but the other nodes hadn't legalized yet, I didn't look too hard at fixing that.
This patch seems to produce better results overall than my other attempts. We now form broadcasts of constants better in some cases. For at least some of them the AND was being introduced in LegalizeDAG, promoted to vXi64, and the BUILD_VECTOR was also legalized there. I think we got bad ordering of that. Now the promotion is out of the legalizer so we handle this better.
In the longer term I think we really should evaluate whether we should be doing this promotion at all. It's really there to reduce isel pattern count, but I'm wondering if we'd be better served just eating the pattern cost or doing C++ based isel for vector and/or/xor in X86ISelDAGToDAG. The masked and/or/xor will definitely be difficult in patterns if a bitcast gets between the vselect and the and/or/xor node. That becomes a lot of permutations to cover.
Reviewers: RKSimon, spatel
Reviewed By: RKSimon
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D53107
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344487
91177308-0d34-0410-b5e6-
96231b3b80d8
Craig Topper [Mon, 15 Oct 2018 01:51:53 +0000 (01:51 +0000)]
[X86] Add 128 MOVDDUP to the constant pool printing in X86AsmPrinter::EmitInstruction.
We use this instruction to broadcast a single 64-bit value to a v2i64/v2f64 vector.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344486
91177308-0d34-0410-b5e6-
96231b3b80d8
Craig Topper [Mon, 15 Oct 2018 01:51:50 +0000 (01:51 +0000)]
[X86] Autogenerate complete checks. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344485
91177308-0d34-0410-b5e6-
96231b3b80d8
Simon Pilgrim [Sun, 14 Oct 2018 20:14:33 +0000 (20:14 +0000)]
[InstCombine] Add PR27343 test cases
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344484
91177308-0d34-0410-b5e6-
96231b3b80d8
Ayal Zaks [Sun, 14 Oct 2018 17:53:02 +0000 (17:53 +0000)]
[LV] Fix comments reported when not vectorizing single iteration loops; NFC
Landing this as a separate part of https://reviews.llvm.org/D50480, being a
seemingly unrelated change ([LV] Vectorizing loops of arbitrary trip count
without remainder under opt for size).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344483
91177308-0d34-0410-b5e6-
96231b3b80d8
Simon Pilgrim [Sun, 14 Oct 2018 17:34:20 +0000 (17:34 +0000)]
[X86][AVX] Enable lowerVectorShuffleAsLanePermuteAndPermute v16i16/v32i8 shuffle lowering
Extends D53148 from v4f64 now that we have test coverage for v16i16/v32i8 shuffles.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344481
91177308-0d34-0410-b5e6-
96231b3b80d8
Simon Pilgrim [Sun, 14 Oct 2018 16:49:04 +0000 (16:49 +0000)]
[ARM] Regenerate cttz tests
Improve codegen view as part of PR32655
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344479
91177308-0d34-0410-b5e6-
96231b3b80d8
Lang Hames [Sun, 14 Oct 2018 16:09:59 +0000 (16:09 +0000)]
[ORC] Remove XXLayer::add methods that default to using the main JITDylib.
They're not currently used and may complicate upcoming changes to add's
signature and behavior.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344478
91177308-0d34-0410-b5e6-
96231b3b80d8
Simon Pilgrim [Sun, 14 Oct 2018 15:56:28 +0000 (15:56 +0000)]
[LegalizeDAG] Don't bother with final MUL+SRL stage for byte CTPOP.
The final stage of CTPOP expansion (v = (v * 0x01010101...) >> (Len - 8)) is completely pointless for the byte (Len = 8) case as it reduces to (v = (v * 0x01...) >> 0), but annoyingly this doesn't always get optimized away.
Found while investigating generic vector CTPOP expansion (PR32655).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344477
91177308-0d34-0410-b5e6-
96231b3b80d8
Sanjay Patel [Sun, 14 Oct 2018 15:25:06 +0000 (15:25 +0000)]
[InstCombine] combine a shuffle and an extract subvector shuffle
This is part of the missing IR-level folding noted in D52912.
This should be ok as a canonicalization because the new shuffle mask can't
be any more complicated than the existing shuffle mask. If there's some
target where the shorter vector shuffle is not legal, it should just end up
expanding to something like the pair of shuffles that we're starting with here.
Differential Revision: https://reviews.llvm.org/D53037
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344476
91177308-0d34-0410-b5e6-
96231b3b80d8
Dorit Nuzman [Sun, 14 Oct 2018 08:50:06 +0000 (08:50 +0000)]
recommit 344472 after fixing build failure on ARM and PPC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344475
91177308-0d34-0410-b5e6-
96231b3b80d8
Dorit Nuzman [Sun, 14 Oct 2018 07:21:20 +0000 (07:21 +0000)]
revert 344472 due to failures.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344473
91177308-0d34-0410-b5e6-
96231b3b80d8
Dorit Nuzman [Sun, 14 Oct 2018 07:06:16 +0000 (07:06 +0000)]
[IAI,LV] Add support for vectorizing predicated strided accesses using masked
interleave-group
The vectorizer currently does not attempt to create interleave-groups that
contain predicated loads/stores; predicated strided accesses can currently be
vectorized only using masked gather/scatter or scalarization. This patch makes
predicated loads/stores candidates for forming interleave-groups during the
Loop-Vectorizer's analysis, and adds the proper support for masked-interleave-
groups to the Loop-Vectorizer's planning and transformation stages. The patch
also extends the TTI API to allow querying the cost of masked interleave groups
(which each target can control); Targets that support masked vector loads/
stores may choose to enable this feature and allow vectorizing predicated
strided loads/stores using masked wide loads/stores and shuffles.
Reviewers: Ayal, hsaito, dcaballe, fhahn, javed.absar
Reviewed By: Ayal
Differential Revision: https://reviews.llvm.org/D53011
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344472
91177308-0d34-0410-b5e6-
96231b3b80d8
Craig Topper [Sun, 14 Oct 2018 04:01:40 +0000 (04:01 +0000)]
[X86] Fix bad indentation. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344471
91177308-0d34-0410-b5e6-
96231b3b80d8
Craig Topper [Sun, 14 Oct 2018 03:36:27 +0000 (03:36 +0000)]
[X86] Type legalize v2f32 stores by widening to v4f32, casting to v2f64, extracting f64 and storing.
Summary: This is similar to what D52528 did for loads. It should match what generic type legalization does in 64-bit mode where it uses a v2i64 cast and an i64 store.
Reviewers: RKSimon, spatel
Reviewed By: RKSimon
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D53173
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344470
91177308-0d34-0410-b5e6-
96231b3b80d8
Benjamin Kramer [Sat, 13 Oct 2018 22:18:22 +0000 (22:18 +0000)]
Move some helpers from the global namespace into anonymous ones.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344468
91177308-0d34-0410-b5e6-
96231b3b80d8
Lang Hames [Sat, 13 Oct 2018 21:53:40 +0000 (21:53 +0000)]
[ORC] During lookup, do not match against hidden symbols in other JITDylibs.
This adds two arguments to the main ExecutionSession::lookup method:
MatchNonExportedInJD, and MatchNonExported. These control whether and where
hidden symbols should be matched when searching a list of JITDylibs.
A similar effect could have been achieved by filtering search results, but
this would have involved materializing symbol definitions (since materialization
is triggered on lookup) only to throw the results away, among other issues.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344467
91177308-0d34-0410-b5e6-
96231b3b80d8
Simon Pilgrim [Sat, 13 Oct 2018 21:50:15 +0000 (21:50 +0000)]
[AARCH64] Regenerate popcnt tests
Improve codegen view as part of PR32655
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344466
91177308-0d34-0410-b5e6-
96231b3b80d8
Simon Pilgrim [Sat, 13 Oct 2018 21:32:49 +0000 (21:32 +0000)]
[ARM] Regenerate popcnt tests
Improve codegen view as part of PR32655
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344465
91177308-0d34-0410-b5e6-
96231b3b80d8
Simon Pilgrim [Sat, 13 Oct 2018 18:40:48 +0000 (18:40 +0000)]
Pull out repeated variables from SelectionDAGLegalize::ExpandBitCount.
The CTPOP case has been changed from VT.getSizeInBits to VT.getScalarSizeInBits - but this fits in with future work for vector support (PR32655) and doesn't affect any current (scalar) uses.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344461
91177308-0d34-0410-b5e6-
96231b3b80d8
Craig Topper [Sat, 13 Oct 2018 17:47:20 +0000 (17:47 +0000)]
[LegalizeTypes] Prevent an assertion from PromoteIntRes_BSWAP and PromoteIntRes_BITREVERSE if the shift amount is too large for the VT returned by getShiftAmountTy
Summary:
getShiftAmountTy for X86 returns MVT::i8. If a BSWAP or BITREVERSE is created that requires promotion and the difference between the original VT and the promoted VT is more than 255 then we won't able to create the constant.
This patch adds a check to replace the result from getShiftAmountTy to MVT::i32 if the difference won't fit. This should get legalized later when the shift is ultimately expanded since its clearly an illegal type that we're only promoting to make it a power of 2 bit width. Alternatively we could base the decision completely on the largest shift amount the promoted VT could use.
Vectors should be immune here because getShiftAmountTy always returns the incoming VT for vectors. Only the scalar shift amount can be changed by the targets.
Reviewers: eli.friedman, RKSimon, spatel
Reviewed By: RKSimon
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D53232
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344460
91177308-0d34-0410-b5e6-
96231b3b80d8
Thomas Lively [Sat, 13 Oct 2018 16:58:03 +0000 (16:58 +0000)]
[WebAssembly][NFC] Fix signed/unsigned comparison warning
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344459
91177308-0d34-0410-b5e6-
96231b3b80d8
Sanjay Patel [Sat, 13 Oct 2018 16:15:37 +0000 (16:15 +0000)]
[InstCombine] fix complexity canonicalization with fake unary vector ops
This is a preliminary step to avoid regressions when we add
an actual 'fneg' instruction to IR. See D52934 and D53205.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344458
91177308-0d34-0410-b5e6-
96231b3b80d8
Simon Pilgrim [Sat, 13 Oct 2018 16:11:15 +0000 (16:11 +0000)]
[X86][SSE] Remove most of vector CTTZ custom lowering and use LegalizeDAG instead.
There is one remnant - AVX1 custom splitting of 256-bit vectors - which is due to a regression where the X86ISD::ANDNP is still performed as a YMM.
I've also tightened the CTLZ or CTPOP lowering in SelectionDAGLegalize::ExpandBitCount to require a legal CTLZ - it doesn't affect existing users and fixes an issue with AVX512 codegen.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344457
91177308-0d34-0410-b5e6-
96231b3b80d8
Sanjay Patel [Sat, 13 Oct 2018 16:02:47 +0000 (16:02 +0000)]
[InstCombine] add tests for operand complexity canonicalization; NFC
The tests with undef vector elements demonstrate a hole in
the current pattern matching.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344456
91177308-0d34-0410-b5e6-
96231b3b80d8
David Bolvansky [Sat, 13 Oct 2018 15:26:13 +0000 (15:26 +0000)]
[NFC] Fixed duplicated test file
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344455
91177308-0d34-0410-b5e6-
96231b3b80d8
David Bolvansky [Sat, 13 Oct 2018 15:21:55 +0000 (15:21 +0000)]
[InstCombine] Fixed crash with aliased functions
Summary: Fixes PR39177
Reviewers: spatel, jbuening
Reviewed By: jbuening
Subscribers: jbuening, llvm-commits
Differential Revision: https://reviews.llvm.org/D53129
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344454
91177308-0d34-0410-b5e6-
96231b3b80d8
Simon Pilgrim [Sat, 13 Oct 2018 15:16:55 +0000 (15:16 +0000)]
[X86][SSE] Begin removing vector CTTZ custom lowering and use LegalizeDAG instead.
Adds CTTZ vector legalization support and begins the removal of the X86/SSE custom lowering.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344453
91177308-0d34-0410-b5e6-
96231b3b80d8
Simon Pilgrim [Sat, 13 Oct 2018 14:45:44 +0000 (14:45 +0000)]
[X86][SSE] combineIncDecVector - use isConstantSplat
Use isConstantSplat instead of ISD::isConstantSplatVector to let us us peek through to illegal types (in this case for i686 targets to recognise i64 constants)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344452
91177308-0d34-0410-b5e6-
96231b3b80d8
Simon Pilgrim [Sat, 13 Oct 2018 14:28:40 +0000 (14:28 +0000)]
[X86] Pull out target constant splat helper function. NFCI.
The code in LowerScalarImmediateShift is just a more powerful version of ISD::isConstantSplatVector.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344451
91177308-0d34-0410-b5e6-
96231b3b80d8
Simon Pilgrim [Sat, 13 Oct 2018 13:33:32 +0000 (13:33 +0000)]
Pull out repeated getOperand(). NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344450
91177308-0d34-0410-b5e6-
96231b3b80d8
Simon Pilgrim [Sat, 13 Oct 2018 13:30:10 +0000 (13:30 +0000)]
Remove unused variable. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344449
91177308-0d34-0410-b5e6-
96231b3b80d8
Simon Pilgrim [Sat, 13 Oct 2018 13:05:19 +0000 (13:05 +0000)]
[X86][SSE] Improve CTTZ lowering when CTLZ is legal
If we have better CTLZ support than CTPOP, then use cttz(x) = width - ctlz(~x & (x - 1)) - and remove the CTTZ_ZERO_UNDEF handling as it no longer gives better codegen.
Similar to rL344447, this is also closer to LegalizeDAG's approach
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344448
91177308-0d34-0410-b5e6-
96231b3b80d8
Simon Pilgrim [Sat, 13 Oct 2018 12:12:06 +0000 (12:12 +0000)]
[X86][SSE] Change CTTZ vector lowering to cttz(x) = ctpop(~x & (x - 1))
This patch changes the vector CTTZ lowering from:
cttz(x) = ctpop((x & -x) - 1)
to:
cttz(x) = ctpop(~x & (x - 1))
Not only does this make better use of the PANDN instruction, but it also matches the LegalizeDAG method which should allow us to remove the x86 specific code at some point in the future (we need to fix some issues with the bitcasted logic ops and CTPOP lowering first).
Differential Revision: https://reviews.llvm.org/D53214
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344447
91177308-0d34-0410-b5e6-
96231b3b80d8
Simon Pilgrim [Sat, 13 Oct 2018 11:38:10 +0000 (11:38 +0000)]
[X86][AVX] Add lowerVectorShuffleAsLanePermuteAndPermute for v4f64 shuffles (PR39161)
Add shuffle lowering for the case where we can shuffle the lanes into place followed by an in-lane permute.
This is mainly for cases where we can have non-repeating permutes in each lane, but for now I've just enabled it for v4f64 unary shuffles to fix PR39161 - there is no test coverage for other shuffles that might benefit yet.
We now have several cross-lane shuffle lowering methods that all do something similar - I've looked at merging some of these (notably by making the repeated mask mechanism in lowerVectorShuffleByMerging128BitLanes optional), but there is a lot of assertions/assumptions in the way that makes this tricky - I ended up going for adding yet another relatively simple method instead.
Differential Revision: https://reviews.llvm.org/D53148
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344446
91177308-0d34-0410-b5e6-
96231b3b80d8
Arnaud A. de Grandmaison [Sat, 13 Oct 2018 07:43:56 +0000 (07:43 +0000)]
[AArch64] Swap comparison operands if that enables some folding.
Summary:
AArch64 can fold some shift+extend operations on the RHS operand of
comparisons, so swap the operands if that makes sense.
This provides a fix for https://bugs.llvm.org/show_bug.cgi?id=38751
Reviewers: efriedma, t.p.northover, javed.absar
Subscribers: mcrosier, kristof.beyls, llvm-commits
Differential Revision: https://reviews.llvm.org/D53067
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344439
91177308-0d34-0410-b5e6-
96231b3b80d8
Thomas Lively [Sat, 13 Oct 2018 07:26:10 +0000 (07:26 +0000)]
[WebAssembly] SIMD min and max
Summary: Depends on D52324 and D52764.
Reviewers: aheejin, dschuff
Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits
Differential Revision: https://reviews.llvm.org/D52325
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344438
91177308-0d34-0410-b5e6-
96231b3b80d8
Thomas Lively [Sat, 13 Oct 2018 07:21:44 +0000 (07:21 +0000)]
[Intrinsic] Add llvm.minimum and llvm.maximum instrinsic functions
Summary:
These new intrinsics have the semantics of the `minimum` and `maximum`
operations specified by the latest draft of IEEE 754-2018. Unlike
llvm.minnum and llvm.maxnum, these new intrinsics propagate NaNs and
always treat -0.0 as less than 0.0. `minimum` and `maximum` lower
directly to the existing `fminnan` and `fmaxnan` ISel DAG nodes. It is
safe to reuse these DAG nodes because before this patch were only
emitted in situations where there were known to be no NaN arguments or
where NaN propagation was correct and there were known to be no zero
arguments. I know of only four backends that lower fminnan and
fmaxnan: WebAssembly, ARM, AArch64, and SystemZ, and each of these
lowers fminnan and fmaxnan to instructions that are compatible with
the IEEE 754-2018 semantics.
Reviewers: aheejin, dschuff, sunfish, javed.absar
Subscribers: kristof.beyls, dexonsmith, kristina, llvm-commits
Differential Revision: https://reviews.llvm.org/D52764
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344437
91177308-0d34-0410-b5e6-
96231b3b80d8
Thomas Lively [Sat, 13 Oct 2018 07:09:10 +0000 (07:09 +0000)]
[WebAssembly][NFC] Unify ARGUMENT classes
Reviewers: aheejin, dschuff
Subscribers: sbc100, jgravelle-google, sunfish, llvm-commits
Differential Revision: https://reviews.llvm.org/D53172
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344436
91177308-0d34-0410-b5e6-
96231b3b80d8
Kostya Serebryany [Fri, 12 Oct 2018 23:21:48 +0000 (23:21 +0000)]
move GetOrCreateFunctionComdat to Instrumentation.cpp/Instrumentation.h
Summary:
GetOrCreateFunctionComdat is currently used in SanitizerCoverage,
where it's defined. I'm planing to use it in HWASAN as well,
so moving it into a common location.
NFC
Reviewers: morehouse
Reviewed By: morehouse
Subscribers: llvm-commits
Differential Revision: https://reviews.llvm.org/D53218
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344433
91177308-0d34-0410-b5e6-
96231b3b80d8
Alex Bradbury [Fri, 12 Oct 2018 23:18:52 +0000 (23:18 +0000)]
[RISCV] Eliminate unnecessary masking of promoted shift amounts
SelectionDAGBuilder::visitShift will always zero-extend a shift amount when it
is promoted to the ShiftAmountTy. This results in zero-extension (masking)
which is unnecessary for RISC-V as the shift operations only read the lower 5
or 6 bits (RV32 or RV64).
I initially proposed adding a getExtendForShiftAmount hook so the shift amount
can be any-extended (D52975). @efriedma explained this was unsafe, so I have
instead eliminate the unnecessary and operations at instruction selection time
in a manner similar to X86InstrCompiler.td.
Differential Revision: https://reviews.llvm.org/D53224
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344432
91177308-0d34-0410-b5e6-
96231b3b80d8
Fangrui Song [Fri, 12 Oct 2018 22:57:57 +0000 (22:57 +0000)]
[llvm-readobj] Fix an error message about .llvm.call-graph-profile
.note.llvm.cgprofile was an obvious typo in rL333823
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344430
91177308-0d34-0410-b5e6-
96231b3b80d8
Craig Topper [Fri, 12 Oct 2018 22:55:17 +0000 (22:55 +0000)]
[LegalizeVectorTypes] Use TLI.getVectorIdxTy instead of DAG.getIntPtrConstant.
There's no guarantee that vector indices should use pointer types. So use the correct query method.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344428
91177308-0d34-0410-b5e6-
96231b3b80d8
Craig Topper [Fri, 12 Oct 2018 22:00:04 +0000 (22:00 +0000)]
[X86] Improve type legalization of (v2i32/v4i16/v8i16 (bitcast (v2f32))) to avoid a stack stack temporary.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344425
91177308-0d34-0410-b5e6-
96231b3b80d8
Craig Topper [Fri, 12 Oct 2018 22:00:00 +0000 (22:00 +0000)]
[X86] Simplify the end of custom type legalization for (v2i32/v4i16/v8i8 (bitcast (f64))) by just emitting an EXTRACT_SUBVECTOR instead of a BUILD_VECTOR.
Generic legalization should be able to finish legalizing the EXTRACT_SUBVECTOR probably by turning it into a BUILD_VECTOR. But we should emit the simplest sequence.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344424
91177308-0d34-0410-b5e6-
96231b3b80d8
Craig Topper [Fri, 12 Oct 2018 21:59:58 +0000 (21:59 +0000)]
[X86] Skip (v2i32/v4i16/v8i8 (bitcast (f64))) handling in ReplaceNodeResults if the dest type can be widened by generic legalization. NFCI
The algorithm we would do previously was identical to generic legalization. If we ever switch to legalizing integer vectors via widening we'll be able to kill off the code since it now only runs for promotion.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344423
91177308-0d34-0410-b5e6-
96231b3b80d8
Craig Topper [Fri, 12 Oct 2018 21:59:55 +0000 (21:59 +0000)]
[LegalizeVectorTypes] When widening the result of a bitcast from a scalar type, use a scalar_to_vector to turn the scalar into a vector intead of a build vector full of mostly undefs.
This is more consistent with what we usually do and matches some code X86 custom emits in some cases that I think I can cleanup.
The MIPS test change just looks to be an instruction ordering change.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344422
91177308-0d34-0410-b5e6-
96231b3b80d8
Eli Friedman [Fri, 12 Oct 2018 19:41:05 +0000 (19:41 +0000)]
Revert BTF commit series.
The initial patch was not reviewed, and does not have any tests;
it should not have been merged.
This reverts 344395, 344390, 344387, 344385, 344381, 344376,
and 344366.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344405
91177308-0d34-0410-b5e6-
96231b3b80d8
Craig Topper [Fri, 12 Oct 2018 19:37:49 +0000 (19:37 +0000)]
[LegalizeVectorTypes] When widening the operands to a concat_vectors, see if we can use the widened operand 0 if the width matches and the other operands are undef.
This saves a conversion to extracts and build_vector. We already do this when both the result and the input need to be widened to the same type.
This changed the sse-intrinsics-fast-isel test because we don't lower (insert_vector_elt (scalar_to_vector X), Y, 1) well. We turn it into (vector_shuffle (scalar_to_vector X), (scalar_to_vector Y), <0, 4, 2, 3>) losing track of the fact that the upper elts could be undef.
We should probably find a way to prevent the scalarization of the <2 x f32> load on these tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344404
91177308-0d34-0410-b5e6-
96231b3b80d8
Craig Topper [Fri, 12 Oct 2018 19:37:47 +0000 (19:37 +0000)]
[LegalizeVectorTypes] When unrolling in WidenVecRes_Convert, make sure we use the original vector element count. Not min of the widened result type and the possibly widened input type.
If the input type is widened as well, but we still were forced to unroll, we shouldn't be considering the widened input element count. We should only create as many scalar operations as the original type called for.
This will be important for an upcoming patch.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344403
91177308-0d34-0410-b5e6-
96231b3b80d8
Simon Pilgrim [Fri, 12 Oct 2018 19:30:43 +0000 (19:30 +0000)]
Fix Wdocumentation warning. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344402
91177308-0d34-0410-b5e6-
96231b3b80d8
Simon Pilgrim [Fri, 12 Oct 2018 19:03:54 +0000 (19:03 +0000)]
Regenerate test. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344399
91177308-0d34-0410-b5e6-
96231b3b80d8
Rui Ueyama [Fri, 12 Oct 2018 18:29:30 +0000 (18:29 +0000)]
Replace assert() with llvm_unreachable because it's obviously a typo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344395
91177308-0d34-0410-b5e6-
96231b3b80d8
Reid Kleckner [Fri, 12 Oct 2018 18:19:06 +0000 (18:19 +0000)]
[codeview] Emit S_BUILDINFO and LF_BUILDINFO with cwd and source file
Summary: We can fill in the command line and compiler path later if we want.
Reviewers: zturner
Subscribers: hiraditya, llvm-commits
Differential Revision: https://reviews.llvm.org/D53179
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344393
91177308-0d34-0410-b5e6-
96231b3b80d8
Andrea Di Biagio [Fri, 12 Oct 2018 18:18:53 +0000 (18:18 +0000)]
[llvm-mca] Correctly set aliases for register writes introduced by optimized register moves.
This fixes a problem introduced by r344334. A write from a non-zero move
eliminated at register renaming stage was not correctly handled by the PRF. This
would have led to an assertion failure if the processor model declares a PRF
that enables non-zero move elimination.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344392
91177308-0d34-0410-b5e6-
96231b3b80d8
Jonathan Metzman [Fri, 12 Oct 2018 18:11:47 +0000 (18:11 +0000)]
[SanitizerCoverage] Prevent /OPT:REF from stripping constructors
Summary:
Linking with the /OPT:REF linker flag when building COFF files causes
the linker to strip SanitizerCoverage's constructors. Prevent this by
giving the constructors WeakODR linkage and by passing the linker a
directive to include sancov.module_ctor.
Include a test in compiler-rt to verify libFuzzer can be linked using
/OPT:REF
Reviewers: morehouse, rnk
Reviewed By: morehouse, rnk
Subscribers: rnk, morehouse, hiraditya
Differential Revision: https://reviews.llvm.org/D52119
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344391
91177308-0d34-0410-b5e6-
96231b3b80d8
Simon Pilgrim [Fri, 12 Oct 2018 18:10:04 +0000 (18:10 +0000)]
Fix MCBTF string array initialization so its MSVC friendly. NFCI.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344390
91177308-0d34-0410-b5e6-
96231b3b80d8
Fangrui Song [Fri, 12 Oct 2018 17:57:07 +0000 (17:57 +0000)]
[BPF] Use cstdint {,u}int*_t instead of linux/types.h __u32 __u16 ...
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344387
91177308-0d34-0410-b5e6-
96231b3b80d8
Eric Liu [Fri, 12 Oct 2018 17:55:21 +0000 (17:55 +0000)]
Disambiguate: s/make_unique/llvm::make_unique/. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344385
91177308-0d34-0410-b5e6-
96231b3b80d8
Fangrui Song [Fri, 12 Oct 2018 17:41:12 +0000 (17:41 +0000)]
[BPF] Don't include linux/types.h and fix style
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344381
91177308-0d34-0410-b5e6-
96231b3b80d8
Zachary Turner [Fri, 12 Oct 2018 17:26:19 +0000 (17:26 +0000)]
Better support for POSIX paths in PDBs.
This a resubmission of a patch which was previously reverted
due to breaking several lld tests. The issues causing those
failures have been fixed, so the patch is now resubmitted.
---Original Commit Message---
While it doesn't make a *ton* of sense for POSIX paths to be
in PDBs, it's possible to occur in real scenarios involving
cross compilation.
The tools need to be able to handle this, because certain types
of debugging scenarios are possible without a running process
and so don't necessarily require you to be on a Windows system.
These include post-mortem debugging and binary forensics (e.g.
using a debugger to disassemble functions and examine symbols
without running the process).
There's changes in clang, LLD, and lldb in this patch. After
this the cross-platform disassembly and source-list tests pass
on Linux.
Furthermore, the behavior of LLD can now be summarized by a much
simpler rule than before: Unless you specify /pdbsourcepath and
/pdbaltpath, the PDB ends up with paths that are valid within
the context of the machine that the link is performed on.
Differential Revision: https://reviews.llvm.org/D53149
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344377
91177308-0d34-0410-b5e6-
96231b3b80d8
Fangrui Song [Fri, 12 Oct 2018 17:23:25 +0000 (17:23 +0000)]
[BPF] Some fixes after rL344366
* Move #include outside of namespaces
* Add missing #include
* Add out-of-line virtual destructor to BTFTypeEntry
designated initializers should also be fixed
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344376
91177308-0d34-0410-b5e6-
96231b3b80d8
Nick Desaulniers [Fri, 12 Oct 2018 17:22:07 +0000 (17:22 +0000)]
[Support] exit with custom return code for SIGPIPE
Summary:
We tell the user to file a bug report on LLVM right now, and
SIGPIPE isn't LLVM's fault so our error message is wrong.
Allows frontends to detect SIGPIPE from writing to closed readers.
This can be seen commonly from piping into head, tee, or split.
Fixes PR25349, rdar://problem/
14285346, b/
77310947
Reviewers: jfb
Reviewed By: jfb
Subscribers: majnemer, kristina, llvm-commits, thakis, srhines
Differential Revision: https://reviews.llvm.org/D53000
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344372
91177308-0d34-0410-b5e6-
96231b3b80d8
Yonghong Song [Fri, 12 Oct 2018 17:01:46 +0000 (17:01 +0000)]
[BPF] Add BTF generation for BPF target
BTF is the debug format for BPF, a kernel virtual machine
and widely used for tracing, networking and security, etc ([1]).
Currently only instruction streams are passed to kernel,
the kernel verifier verifies them before execution. In order to
provide better visibility of bpf programs to user space
tools, some debug information, e.g., function names and
debug line information are desirable for kernel so tools
can get such information with better annotation
for jited instructions for performance or other reasons.
The dwarf is too complicated in kernel and for BPF.
Hence, BTF is designed to be the debug format for BPF ([2]).
Right now, pahole supports BTF for types, which
are generated based on dwarf sections in the ELF file.
In order to annotate performance metrics for jited bpf insns,
it is necessary to pass debug line info to the kernel.
Furthermore, we want to pass the actual code to the
kernel because of the following reasons:
. bpf program typically is small so storage overhead
should be small.
. in bpf land, it is totally possible that
an application loads the bpf program into the
kernel and then that application quits, so
holding debug info by the user space application
is not practical.
. having source codes directly kept by kernel
would ease deployment since the original source
code does not need ship on every hosts and
kernel-devel package does not need to be
deployed even if kernel headers are used.
The only reliable time to get the source code is
during compilation time. This will result in both more
accurate information and easier deployment as
stated in the above.
Another consideration is for JIT. The project like bcc
use MCJIT to compile a C program into bpf insns and
load them to the kernel ([3]). The generated BTF sections
will be readily available for such cases as well.
This patch implemented generation of BTF info in llvm
compiler. The BTF related sections will be generated
when both -target bpf and -g are specified. Two sections
are generated:
.BTF contains all the type and string information, and
.BTF.ext contains the func_info and line_info.
The separation is related to how two sections are used
differently in bpf loader, e.g., linux libbpf ([4]).
The .BTF section can be loaded into the kernel directly
while .BTF.ext needs loader manipulation before loading
to the kernel. The format of the each section is roughly
defined in llvm:include/llvm/MC/MCBTFContext.h and
from the implementation in llvm:lib/MC/MCBTFContext.cpp.
A later example also shows the contents in each section.
The type and func_info are gathered during CodeGen/AsmPrinter
by traversing dwarf debug_info. The line_info is
gathered in MCObjectStreamer before writing to
the object file. After all the information is gathered,
the two sections are emitted in MCObjectStreamer::finishImpl.
With cmake CMAKE_BUILD_TYPE=Debug, the compiler can
dump out all the tables except insn offset, which
will be resolved later as relocation records.
The debug type "btf" is used for BTFContext dump.
Dwarf tests the debug info generation with
llvm-dwarfdump to decode the binary sections and
check whether the result is expected. Currently
we do not have such a tool yet. We will implement
btf dump functionality in bpftool ([5]) as the bpftool is
considered the recommended tool for bpf introspection.
The implementation for type and func_info is tested
with linux kernel test cases. The line_info is visually
checked with dump from linux kernel libbpf ([4]) and
checked with readelf dumping section raw data.
Note that the .BTF and .BTF.ext information will not
be emitted to assembly code and there is no assembler
support for BTF either.
In the below, with a clang/llvm built with CMAKE_BUILD_TYPE=Debug,
Each table contents are shown for a simple C program.
-bash-4.2$ cat -n test.c
1 struct A {
2 int a;
3 char b;
4 };
5
6 int test(struct A *t) {
7 return t->a;
8 }
-bash-4.2$ clang -O2 -target bpf -g -mllvm -debug-only=btf -c test.c
Type Table:
[1] FUNC name_off=1 info=0x0c000001 size/type=2
param_type=3
[2] INT name_off=12 info=0x01000000 size/type=4
desc=0x01000020
[3] PTR name_off=0 info=0x02000000 size/type=4
[4] STRUCT name_off=16 info=0x04000002 size/type=8
name_off=18 type=2 bit_offset=0
name_off=20 type=5 bit_offset=32
[5] INT name_off=22 info=0x01000000 size/type=1
desc=0x02000008
String Table:
0 :
1 : test
6 : .text
12 : int
16 : A
18 : a
20 : b
22 : char
27 : test.c
34 : int test(struct A *t) {
58 : return t->a;
FuncInfo Table:
sec_name_off=6
insn_offset=<Omitted> type_id=1
LineInfo Table:
sec_name_off=6
insn_offset=<Omitted> file_name_off=27 line_off=34 line_num=6 column_num=0
insn_offset=<Omitted> file_name_off=27 line_off=58 line_num=7 column_num=3
-bash-4.2$ readelf -S test.o
......
[12] .BTF PROGBITS
0000000000000000 0000028d
00000000000000c1 0000000000000000 0 0 1
[13] .BTF.ext PROGBITS
0000000000000000 0000034e
0000000000000050 0000000000000000 0 0 1
[14] .rel.BTF.ext REL
0000000000000000 00000648
0000000000000030 0000000000000010 16 13 8
......
-bash-4.2$
The latest linux kernel ([6]) can already support .BTF with type information.
The [7] has the reference implementation in linux kernel side
to support .BTF.ext func_info. The .BTF.ext line_info support is not
implemented yet. If you have difficulty accessing [6], you can
manually do the following to access the code:
git clone https://github.com/yonghong-song/bpf-next-linux.git
cd bpf-next-linux
git checkout btf
The change will push to linux kernel soon once this patch is landed.
References:
[1]. https://www.kernel.org/doc/Documentation/networking/filter.txt
[2]. https://lwn.net/Articles/750695/
[3]. https://github.com/iovisor/bcc
[4]. https://github.com/torvalds/linux/tree/master/tools/lib/bpf
[5]. https://github.com/torvalds/linux/tree/master/tools/bpf/bpftool
[6]. https://github.com/torvalds/linux
[7]. https://github.com/yonghong-song/bpf-next-linux/tree/btf
Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Yonghong Song <yhs@fb.com>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Differential Revision: https://reviews.llvm.org/D52950
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@344366
91177308-0d34-0410-b5e6-
96231b3b80d8