platform/upstream/llvm.git
8 years agoAdd help for our regular expression commands when aliased
Enrico Granata [Fri, 8 Apr 2016 17:56:26 +0000 (17:56 +0000)]
Add help for our regular expression commands when aliased

llvm-svn: 265819

8 years agoAppend a missing \n
Enrico Granata [Fri, 8 Apr 2016 17:55:59 +0000 (17:55 +0000)]
Append a missing \n

llvm-svn: 265818

8 years ago[llvm-objdump] Printing hex instead of dec by default
Colin LeMahieu [Fri, 8 Apr 2016 17:55:03 +0000 (17:55 +0000)]
[llvm-objdump] Printing hex instead of dec by default

Differential Revision: http://reviews.llvm.org/D18770

llvm-svn: 265817

8 years agoAlways have clang pass -pie-level and -pic-level values to the code generator.
Wei Mi [Fri, 8 Apr 2016 17:42:32 +0000 (17:42 +0000)]
Always have clang pass -pie-level and -pic-level values to the code generator.

Patch by tmsriram!

Differential Revision: http://reviews.llvm.org/D18843

llvm-svn: 265816

8 years ago[Object] Report an error if .alt_entry is used with ELF or COFF.
Lang Hames [Fri, 8 Apr 2016 17:38:51 +0000 (17:38 +0000)]
[Object] Report an error if .alt_entry is used with ELF or COFF.

I'm looking into a better way to do this long-term, but for now at least don't
crash.

llvm-svn: 265815

8 years ago[SystemZ] Support conditional sibling calls via BRCL
Ulrich Weigand [Fri, 8 Apr 2016 17:22:19 +0000 (17:22 +0000)]
[SystemZ] Support conditional sibling calls via BRCL

This adds a conditional variant of CallJG instruction, CallBRCL.
It can be used for conditional sibling calls. Unfortunately, due
to IfCvt limitations, it only really works well for functions without
arguments.

Author: koriakin
Differential Revision: http://reviews.llvm.org/D18864

llvm-svn: 265814

8 years ago[Release Notes] Sort checks alphabetically.
Eugene Zelenko [Fri, 8 Apr 2016 17:21:27 +0000 (17:21 +0000)]
[Release Notes] Sort checks alphabetically.

llvm-svn: 265813

8 years ago[RegBankSelect] Use reverse post order traversal.
Quentin Colombet [Fri, 8 Apr 2016 17:19:10 +0000 (17:19 +0000)]
[RegBankSelect] Use reverse post order traversal.

When assigning the register banks of an instruction, it is best to know
all the constraints of the input to have a good idea of how this will
impact the cost of the whole function.

llvm-svn: 265812

8 years ago[AArch64] Add a test case for the default mapping of RegBankSelect.
Quentin Colombet [Fri, 8 Apr 2016 17:11:51 +0000 (17:11 +0000)]
[AArch64] Add a test case for the default mapping of RegBankSelect.

llvm-svn: 265811

8 years ago[RegisterBankInfo] Change the implementation for the default mapping.
Quentin Colombet [Fri, 8 Apr 2016 16:59:50 +0000 (16:59 +0000)]
[RegisterBankInfo] Change the implementation for the default mapping.

Do not give that much importance to the current register bank of an
operand. This is likely just a side effect of the current execution and
it is properly wise to prefer a register bank that can be extracted from
the information available statically (like encoding constraints and
type).

llvm-svn: 265810

8 years agoAdd testcase from PR27218. NFC.
Michael Kruse [Fri, 8 Apr 2016 16:54:53 +0000 (16:54 +0000)]
Add testcase from PR27218. NFC.

The the bug has already been fixed r265795, but this second testcase
still useful.

llvm-svn: 265809

8 years agoRemove bad indentation introduced in 263859
Luke Drummond [Fri, 8 Apr 2016 16:52:40 +0000 (16:52 +0000)]
Remove bad indentation introduced in 263859

This commit touches whitespace only.
This commit was the original intention of the botched 265797

llvm-svn: 265808

8 years agoMove EABIVersion from CodeGenOptions to TargetOptions
Saleem Abdulrasool [Fri, 8 Apr 2016 16:52:05 +0000 (16:52 +0000)]
Move EABIVersion from CodeGenOptions to TargetOptions

It is possible to argue that the EABIVersion field is similar in spirit to the
ABI field in TargetOptions.  It represents the embedded ABI that the target
follows.  This will allow us to thread this information into the target
information construction.

llvm-svn: 265807

8 years agorevert SVN r265702, r265640
Saleem Abdulrasool [Fri, 8 Apr 2016 16:52:00 +0000 (16:52 +0000)]
revert SVN r265702, r265640

Revert the two changes to thread CodeGenOptions into the TargetInfo allocation
and to fix the layering violation by moving CodeGenOptions into Basic.
Code Generation is arguably not particularly "basic".  This addresses Richard's
post-commit review comments.  This change purely does the mechanical revert and
will be followed up with an alternate approach to thread the desired information
into TargetInfo.

llvm-svn: 265806

8 years ago[InstCombine] Fix miscompile in FoldSPFofSPF
David Majnemer [Fri, 8 Apr 2016 16:51:49 +0000 (16:51 +0000)]
[InstCombine] Fix miscompile in FoldSPFofSPF

We had a select of a cast of a select but attempted to replace the outer
select with the inner select dispite their incompatible types.

Patch by Anton Korobeynikov!

This fixes PR27236.

llvm-svn: 265805

8 years ago[RegBankSelect] Improve debug output.
Quentin Colombet [Fri, 8 Apr 2016 16:48:16 +0000 (16:48 +0000)]
[RegBankSelect] Improve debug output.

Add verbose information when checking if the current and the desired
register banks match.
Detail what happens when we assign a register bank.

llvm-svn: 265804

8 years agoFix missing include on OpenBSD
Mehdi Amini [Fri, 8 Apr 2016 16:45:05 +0000 (16:45 +0000)]
Fix missing include on OpenBSD

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 265803

8 years ago[MIR] Teach the parser how to deal with register banks.
Quentin Colombet [Fri, 8 Apr 2016 16:40:43 +0000 (16:40 +0000)]
[MIR] Teach the parser how to deal with register banks.

llvm-svn: 265802

8 years ago[InstCombine] Add a peephole for redundant assumes
David Majnemer [Fri, 8 Apr 2016 16:37:12 +0000 (16:37 +0000)]
[InstCombine] Add a peephole for redundant assumes

Two or more identical assumes are occasionally next to each other in a
basic block.
While our generic machinery will turn a redundant assume into a no-op,
it is not super cheap.
We can perform a simpler check to achieve the same result for this case.

llvm-svn: 265801

8 years ago[LoopVectorize] Register cloned assumptions
David Majnemer [Fri, 8 Apr 2016 16:37:10 +0000 (16:37 +0000)]
[LoopVectorize] Register cloned assumptions

InstCombine cannot effectively remove redundant assumptions without them
registered in the assumption cache.  The vectorizer can create identical
assumptions but doesn't register them with the cache, resulting in
slower compile times because InstCombine tries to reason about a lot
more assumptions.

Fix this by registering the cloned assumptions.

llvm-svn: 265800

8 years agoRevert bad commit 265797.
Luke Drummond [Fri, 8 Apr 2016 16:35:58 +0000 (16:35 +0000)]
Revert bad commit 265797.

llvm-svn: 265799

8 years ago[MachineVerifier] Teach how to check some of the properties of generic
Quentin Colombet [Fri, 8 Apr 2016 16:35:22 +0000 (16:35 +0000)]
[MachineVerifier] Teach how to check some of the properties of generic
virtual registers.

Generic virtual registers:
- May not have a register class
- May not have a register bank
- If they do not have a register class they must have a size
- If they have a register bank, the size of the register bank must be
  greater or equal to the size of the virtual register (basically check
  that the virtual register will fit into that register class)

llvm-svn: 265798

8 years agoFix indentation for commit 263859.
Luke Drummond [Fri, 8 Apr 2016 16:30:55 +0000 (16:30 +0000)]
Fix indentation for commit 263859.

llvm-svn: 265797

8 years ago[MIR] Teach the mir printer how to print the register bank.
Quentin Colombet [Fri, 8 Apr 2016 16:26:22 +0000 (16:26 +0000)]
[MIR] Teach the mir printer how to print the register bank.

For now, we put the register bank in the Class field since a register
may only have one of those at a given time. The downside of that
representation is that if a register class and a register bank have the
same name, we will not be able to distinguish them.

llvm-svn: 265796

8 years ago[ScopInfo] Fix check for element size mismatch.
Michael Kruse [Fri, 8 Apr 2016 16:20:08 +0000 (16:20 +0000)]
[ScopInfo] Fix check for element size mismatch.

The way to get the elements size with getPrimitiveSizeInBits() is not
the same as used in other parts of Polly which should use
DataLayout::getTypeAllocSize(). Its use only queries the size of the
pointer and getPrimitiveSizeInBits returns 0 for types that require a
DataLayout object such as pointers.

Together with r265379, this should fix PR27195.

llvm-svn: 265795

8 years agoDon't lower the visibility because of shared symbols.
Rafael Espindola [Fri, 8 Apr 2016 16:11:42 +0000 (16:11 +0000)]
Don't lower the visibility because of shared symbols.

If a shared library has a protected symbol 'foo', that doesn't imply
that the symbol 'foo' in the output should be protected or not.

llvm-svn: 265794

8 years ago[ARM] Enable SMLAW[B|T] and SMLUW[B|T] instruction selection
Sam Parker [Fri, 8 Apr 2016 16:02:53 +0000 (16:02 +0000)]
[ARM] Enable SMLAW[B|T] and SMLUW[B|T] instruction selection

Added ISelDAGToDAG functions to enable selection of the smlawb, smlawt,
smulwb and smulwt instructions for the ARM backend. Also updated the smul
CodeGen test and removed the smulw one.

Differential Revision: http://reviews.llvm.org/D18892

llvm-svn: 265793

8 years agoProduce STV_DEFAULT for symbols in shared libraries.
Rafael Espindola [Fri, 8 Apr 2016 15:43:43 +0000 (15:43 +0000)]
Produce STV_DEFAULT for symbols in shared libraries.

The spec says:
If a symbol definition with STV_PROTECTED visibility from a shared
object is taken as resolving a reference from an executable or another
shared object, the SHN_UNDEF symbol table entry created has STV_DEFAULT
visibility.

llvm-svn: 265792

8 years agoMake getSymbolBinding a local static. NFC.
Rafael Espindola [Fri, 8 Apr 2016 15:30:56 +0000 (15:30 +0000)]
Make getSymbolBinding a local static. NFC.

llvm-svn: 265791

8 years agoRevert r265547 "Recommit r265309 after fixed an invalid memory reference bug happened"
Hans Wennborg [Fri, 8 Apr 2016 15:17:43 +0000 (15:17 +0000)]
Revert r265547 "Recommit r265309 after fixed an invalid memory reference bug happened"

It caused PR27275: "ARM: Bad machine code: Using an undefined physical register"

Also reverting the following commits that were landed on top:
r265610 "Fix the compare-clang diff error introduced by r265547."
r265639 "Fix the sanitizer bootstrap error in r265547."
r265657 "InlineSpiller.cpp: Escap \@ in r265547. [-Wdocumentation]"

llvm-svn: 265790

8 years ago[X86][SSE] Added 32-bit tests for vector lzcnt/tzcnt tests
Simon Pilgrim [Fri, 8 Apr 2016 15:01:31 +0000 (15:01 +0000)]
[X86][SSE] Added 32-bit tests for vector lzcnt/tzcnt tests

v2i64 tests are particularly bad on 32-bit targets.

llvm-svn: 265789

8 years ago[ScopInfo] Rename variable to AccType. NFC.
Michael Kruse [Fri, 8 Apr 2016 14:35:59 +0000 (14:35 +0000)]
[ScopInfo] Rename variable to AccType. NFC.

This avoids a name clash with the type llvm::Type.

llvm-svn: 265788

8 years agoFix-up LLDB build after rL13179
Tamas Berghammer [Fri, 8 Apr 2016 14:31:13 +0000 (14:31 +0000)]
Fix-up LLDB build after rL13179

llvm-svn: 265787

8 years agoRe-commit [SCEV] Introduce a guarded backedge taken count and use it in LAA and LV
Silviu Baranga [Fri, 8 Apr 2016 14:29:09 +0000 (14:29 +0000)]
Re-commit [SCEV] Introduce a guarded backedge taken count and use it in LAA and LV

This re-commits r265535 which was reverted in r265541 because it
broke the windows bots. The problem was that we had a PointerIntPair
which took a pointer to a struct allocated with new. The problem
was that new doesn't provide sufficient alignment guarantees.
This pattern was already present before r265535 and it just happened
to work. To fix this, we now separate the PointerToIntPair from the
ExitNotTakenInfo struct into a pointer and a bool.

Original commit message:

Summary:
When the backedge taken codition is computed from an icmp, SCEV can
deduce the backedge taken count only if one of the sides of the icmp
is an AddRecExpr. However, due to sign/zero extensions, we sometimes
end up with something that is not an AddRecExpr.

However, we can use SCEV predicates to produce a 'guarded' expression.
This change adds a method to SCEV to get this expression, and the
SCEV predicate associated with it.

In HowManyGreaterThans and HowManyLessThans we will now add a SCEV
predicate associated with the guarded backedge taken count when the
analyzed SCEV expression is not an AddRecExpr. Note that we only do
this as an alternative to returning a 'CouldNotCompute'.

We use new feature in Loop Access Analysis and LoopVectorize to analyze
and transform more loops.

Reviewers: anemet, mzolotukhin, hfinkel, sanjoy

Subscribers: flyingforyou, mcrosier, atrick, mssimpso, sanjoy, mzolotukhin, llvm-commits

Differential Revision: http://reviews.llvm.org/D17201

llvm-svn: 265786

8 years ago[X86] Tidied up shuffle decode function doxygen descriptions
Simon Pilgrim [Fri, 8 Apr 2016 14:17:07 +0000 (14:17 +0000)]
[X86] Tidied up shuffle decode function doxygen descriptions

As discussed on D18441 - auto brief is used so we don't need /brief, we don't need to include the function name and added some missing descriptions.

llvm-svn: 265785

8 years ago[lld] [ELF/AARCH64] Fix dynamic relocation from PIC GOT access
Adhemerval Zanella [Fri, 8 Apr 2016 14:10:41 +0000 (14:10 +0000)]
[lld] [ELF/AARCH64] Fix dynamic relocation from PIC GOT access

This patch fixes dynamic relocation creation from GOT access in dynamic
objects on aarch64. Current code creates a plt relative one
(R_AARCH64_JUMP_SLOT) instead of a got relative (R_AARCH64_GLOB_DAT).

It leads the programs fails with:

$ cat t.cc

std::string test = "hello...\n";

int main ()
{
  printf ("%s\n", test.c_str());
  return 0;
}
$ clang++ t.cc -fpic -o t
$ ./t
hello...

Segmentation fault (core dumped)

Due the fact it will try to access the plt instead of the got for
__cxa_atexit registration for the std::string destruction.  It will
lead in a bogus function address in atexit.

llvm-svn: 265784

8 years ago[OpenCL] Complete image types support.
Alexey Bader [Fri, 8 Apr 2016 13:40:33 +0000 (13:40 +0000)]
[OpenCL] Complete image types support.

I. Current implementation of images is not conformant to spec in the following points:
  1. It makes no distinction with respect to access qualifiers and therefore allows to use images with different access type interchangeably. The following code would compile just fine:

        void write_image(write_only image2d_t img);
        kernel void foo(read_only image2d_t img) { write_image(img); } // Accepted code

     which is disallowed according to s6.13.14.

  2. It discards access qualifier on generated code, which leads to generated code for the above example:

        call void @write_image(%opencl.image2d_t* %img);

     In OpenCL2.0 however we can have different calls into write_image with read_only and wite_only images.
     Also generally following compiler steps have no easy way to take different path depending on the image access: linking to the right implementation of image types, performing IR opts and backend codegen differently.

  3. Image types are language keywords and can't be redeclared s6.1.9, which can happen currently as they are just typedef names.
  4. Default access qualifier read_only is to be added if not provided explicitly.

II. This patch corrects the above points as follows:
  1. All images are encapsulated into a separate .def file that is inserted in different points where image handling is required. This avoid a lot of code repetition as all images are handled the same way in the code with no distinction of their exact type.
  2. The Cartesian product of image types and image access qualifiers is added to the builtin types. This simplifies a lot handling of access type mismatch as no operations are allowed by default on distinct Builtin types. Also spec intended access qualifier as special type qualifier that are combined with an image type to form a distinct type (see statement above - images can't be created w/o access qualifiers).
  3. Improves testing of images in Clang.

Author: Anastasia Stulova
Reviewers: bader, mgrang.
Subscribers: pxli168, pekka.jaaskelainen, yaxunl.
Differential Revision: http://reviews.llvm.org/D17821

llvm-svn: 265783

8 years agoSilencing a 32-bit shift implicit conversion warning from MSVC; NFC.
Aaron Ballman [Fri, 8 Apr 2016 12:21:58 +0000 (12:21 +0000)]
Silencing a 32-bit shift implicit conversion warning from MSVC; NFC.

llvm-svn: 265782

8 years agoCXX_FAST_TLS calling convention: performance improvement for PPC64
Chuang-Yu Cheng [Fri, 8 Apr 2016 12:04:32 +0000 (12:04 +0000)]
CXX_FAST_TLS calling convention: performance improvement for PPC64

This is the same change on PPC64 as r255821 on AArch64. I have even borrowed
his commit message.

The access function has a short entry and a short exit, the initialization
block is only run the first time. To improve the performance, we want to
have a short frame at the entry and exit.

We explicitly handle most of the CSRs via copies. Only the CSRs that are not
handled via copies will be in CSR_SaveList.

Frame lowering and prologue/epilogue insertion will generate a short frame
in the entry and exit according to CSR_SaveList. The majority of the CSRs will
be handled by register allcoator. Register allocator will try to spill and
reload them in the initialization block.

We add CSRsViaCopy, it will be explicitly handled during lowering.

1> we first set FunctionLoweringInfo->SplitCSR if conditions are met (the target
   supports it for the given machine function and the function has only return
   exits). We also call TLI->initializeSplitCSR to perform initialization.
2> we call TLI->insertCopiesSplitCSR to insert copies from CSRsViaCopy to
   virtual registers at beginning of the entry block and copies from virtual
   registers to CSRsViaCopy at beginning of the exit blocks.
3> we also need to make sure the explicit copies will not be eliminated.

Author: Tom Jablin (tjablin)
Reviewers: hfinkel kbarton cycheng

http://reviews.llvm.org/D17533

llvm-svn: 265781

8 years ago[mips] Use range-based for loops. NFC.
Vasileios Kalintiris [Fri, 8 Apr 2016 10:33:00 +0000 (10:33 +0000)]
[mips] Use range-based for loops. NFC.

llvm-svn: 265780

8 years ago[FIX] Allow to lookup domains for non-affine subregion blocks
Johannes Doerfert [Fri, 8 Apr 2016 10:32:26 +0000 (10:32 +0000)]
[FIX] Allow to lookup domains for non-affine subregion blocks

llvm-svn: 265779

8 years ago[FIX] Adjust execution context of hoisted loads wrt. error domains
Johannes Doerfert [Fri, 8 Apr 2016 10:30:09 +0000 (10:30 +0000)]
[FIX] Adjust execution context of hoisted loads wrt. error domains

  If we build the domains for error blocks and later remove them we lose
  the information that they are not executed. Thus, in the SCoP it looks
  like the control will always reach the statement S:

            for (i = 0 ... N)
                if (*valid == 0)
                  doSth(&ptr);
          S:    A[i] = *ptr;

  Consequently, we would have assumed "ptr" to be always accessed and
  preloaded it unconditionally. However, only if "*valid != 0" we would
  execute the optimized version of the SCoP. Nevertheless, we would have
  hoisted and accessed "ptr"regardless of "*valid". This changes the
  semantic of the program as the value of "*valid" can cause a change of
  "ptr" and control if it is executed or not.

  To fix this problem we adjust the execution context of hoisted loads
  wrt. error domains. To this end we introduce an ErrorDomainCtxMap that
  maps each basic block to the error context under which it might be
  executed. Thus, to the context under which it is executed but an error
  block would have been executed to. To fill this map one traversal of
  the blocks in the SCoP suffices. During this traversal we do also
  "remove" error statements and those that are only reachable via error
  statements. This was previously done by the removeErrorBlockDomains
  function which is therefor not needed anymore.

  This fixes bug PR26683 and thereby several SPEC miscompiles.

Differential Revision: http://reviews.llvm.org/D18822

llvm-svn: 265778

8 years ago[FIX] Handle multiplications in the SCEVAffinator again
Johannes Doerfert [Fri, 8 Apr 2016 10:27:40 +0000 (10:27 +0000)]
[FIX] Handle multiplications in the SCEVAffinator again

  If ScalarEvolution cannot look through some expression but we do, it
  might happen that a multiplication will arrive at the
  SCEVAffinator::visitMulExpr. While we could always try to improve the
  extractConstantFactor function we might still miss something, thus we
  reintroduce the code to generate multiplicative piecewise-affine
  functions as a fall-back.

llvm-svn: 265777

8 years agoAdd test cases for the removal of error blocks
Johannes Doerfert [Fri, 8 Apr 2016 10:26:39 +0000 (10:26 +0000)]
Add test cases for the removal of error blocks

llvm-svn: 265776

8 years ago[FIX] Look through div & srem instructions in SCEVs
Johannes Doerfert [Fri, 8 Apr 2016 10:25:58 +0000 (10:25 +0000)]
[FIX] Look through div & srem instructions in SCEVs

  The findValues() function did not look through div & srem instructions
  that were part of the argument SCEV. However, in different other
  places we already look through it. This mismatch caused us to preload
  values in the wrong order.

llvm-svn: 265775

8 years ago[clang-tidy] cppcoreguidelines-interfaces-global-init
Alexander Kornienko [Fri, 8 Apr 2016 09:51:06 +0000 (09:51 +0000)]
[clang-tidy] cppcoreguidelines-interfaces-global-init

Summary:
This check flags initializers of globals that access extern objects, and therefore can lead to order-of-initialization problems (this recommandation is part of CPP core guidelines).
Note that this only checks half of the guideline for now (it does not enforce using constexpr functions).

Reviewers: aaron.ballman, alexfh

Subscribers: aaron.ballman, etienneb, Eugene.Zelenko, cfe-commits

Patch by Clement Courbet!

Differential Revision: http://reviews.llvm.org/D18649

llvm-svn: 265774

8 years ago[llvm-c] Expose LLVMContextGetDiagnostic{Handler,Context}
Jeroen Ketema [Fri, 8 Apr 2016 09:19:02 +0000 (09:19 +0000)]
[llvm-c] Expose LLVMContextGetDiagnostic{Handler,Context}

Differential Revision: http://reviews.llvm.org/D18820

llvm-svn: 265773

8 years ago[mips][microMIPS] Add CodeGen support for ADD, ADDIU*, ADDU* and DADD* instructions
Zlatko Buljan [Fri, 8 Apr 2016 07:27:26 +0000 (07:27 +0000)]
[mips][microMIPS] Add CodeGen support for ADD, ADDIU*, ADDU* and DADD* instructions
Differential Revision: http://reviews.llvm.org/D16454

llvm-svn: 265772

8 years agoUse std::fill to simplify some code. NFC
Craig Topper [Fri, 8 Apr 2016 07:10:46 +0000 (07:10 +0000)]
Use std::fill to simplify some code. NFC

llvm-svn: 265771

8 years ago[IFUNC] Fix ifunc-asm.ll test
Dmitry Polukhin [Fri, 8 Apr 2016 06:45:19 +0000 (06:45 +0000)]
[IFUNC] Fix ifunc-asm.ll test

It seems that llc cannot be called used in assembler tests so test that
checks asm for particular target needs to be moved to codegen.

llvm-svn: 265770

8 years ago[AMDGPU] Add some VI disassembler tests missing from previous autogeneration due...
Valery Pykhtin [Fri, 8 Apr 2016 05:42:20 +0000 (05:42 +0000)]
[AMDGPU] Add some VI disassembler tests missing from previous autogeneration due to different filecheck prefix. NFC.

llvm-svn: 265769

8 years agoReapply "ValueMapper: Treat LocalAsMetadata more like function-local Values"
Duncan P. N. Exon Smith [Fri, 8 Apr 2016 03:13:22 +0000 (03:13 +0000)]
Reapply "ValueMapper: Treat LocalAsMetadata more like function-local Values"

This reverts commit r265765, reapplying r265759 after changing a call from
LocalAsMetadata::get to ValueAsMetadata::get (and adding a unit test).  When a
local value is mapped to a constant (like "i32 %a" => "i32 7"), the new debug
intrinsic operand may no longer be pointing at a local.

    http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_build/19020/

The previous coommit message follows:

--

This is a partial re-commit -- maybe more of a re-implementation -- of
r265631 (reverted in r265637).

This makes RF_IgnoreMissingLocals behave (almost) consistently between
the Value and the Metadata hierarchy.  In particular:

  - MapValue returns nullptr or "metadata !{}" for missing locals in
    MetadataAsValue/LocalAsMetadata bridging paris, depending on
    the RF_IgnoreMissingLocals flag.

  - MapValue doesn't memoize LocalAsMetadata-related results.

  - MapMetadata no longer deals with LocalAsMetadata or
    RF_IgnoreMissingLocals at all.  (This wasn't in r265631 at all, but
    I realized during testing it would make the patch simpler with no
    loss of generality.)

r265631 went too far, making both functions universally ignore
RF_IgnoreMissingLocals.  This broke building (e.g.) compiler-rt.
Reassociate (and possibly other passes) don't currently maintain
dominates-use invariants for metadata operands, resulting in IR like
this:

    define void @foo(i32 %arg) {
      call void @llvm.some.intrinsic(metadata i32 %x)
      %x = add i32 1, i32 %arg
    }

If the inliner chooses to inline @foo into another function, then
RemapInstruction will call `MapValue(metadata i32 %x)` and assert that
the return is not nullptr.

I've filed PR27273 to add a Verifier check and fix the underlying
problem in the optimization passes.

As a workaround, return `!{}` instead of nullptr for unmapped
LocalAsMetadata when RF_IgnoreMissingLocals is unset.  Otherwise, match
the behaviour of r265631.

Original commit message:

    ValueMapper: Make LocalAsMetadata match function-local Values

    Start treating LocalAsMetadata similarly to function-local members of
    the Value hierarchy in MapValue and MapMetadata.

      - Don't memoize them.
      - Return nullptr if they are missing.

    This also cleans up ConstantAsMetadata to stop listening to the
    RF_IgnoreMissingLocals flag.

llvm-svn: 265768

8 years agoAdapt to LLVM API change
Sanjoy Das [Fri, 8 Apr 2016 01:31:02 +0000 (01:31 +0000)]
Adapt to LLVM API change

Replace mayBeOverridden with isInterposable

llvm-svn: 265767

8 years ago[modules] Add a comment to explain why -E leaves some #includes in the preprocessed...
Richard Smith [Fri, 8 Apr 2016 01:23:59 +0000 (01:23 +0000)]
[modules] Add a comment to explain why -E leaves some #includes in the preprocessed output.

llvm-svn: 265766

8 years agoRevert "ValueMapper: Treat LocalAsMetadata more like function-local Values"
Duncan P. N. Exon Smith [Fri, 8 Apr 2016 00:56:21 +0000 (00:56 +0000)]
Revert "ValueMapper: Treat LocalAsMetadata more like function-local Values"

This reverts commit r265759, since even this limited version breaks some
bots:
  http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/3311
  http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-autoconf/builds/17696

This also reverts r265761 "ValueMapper: Unduplicate
RF_NoModuleLevelChanges check, NFC", since I had trouble separating it
from r265759.

llvm-svn: 265765

8 years ago[TargetRegisterInfo] Re-apply r265734.
Quentin Colombet [Fri, 8 Apr 2016 00:51:00 +0000 (00:51 +0000)]
[TargetRegisterInfo] Re-apply r265734.

Original commit message:
[TargetRegisterInfo] Refactor the code to use BitMaskClassIterator.

llvm-svn: 265764

8 years ago[TargetRegisterInfo] Fix BitMaskClassIterator::moveToNextID implementation.
Quentin Colombet [Fri, 8 Apr 2016 00:50:58 +0000 (00:50 +0000)]
[TargetRegisterInfo] Fix BitMaskClassIterator::moveToNextID implementation.

Make sure we do not read past the size of the mask. Although we were not using
the value read, this is bad and makes ASan complain.

llvm-svn: 265763

8 years agoDon't IPO over functions that can be de-refined
Sanjoy Das [Fri, 8 Apr 2016 00:48:30 +0000 (00:48 +0000)]
Don't IPO over functions that can be de-refined

Summary:
Fixes PR26774.

If you're aware of the issue, feel free to skip the "Motivation"
section and jump directly to "This patch".

Motivation:

I define "refinement" as discarding behaviors from a program that the
optimizer has license to discard.  So transforming:

```
void f(unsigned x) {
  unsigned t = 5 / x;
  (void)t;
}
```

to

```
void f(unsigned x) { }
```

is refinement, since the behavior went from "if x == 0 then undefined
else nothing" to "nothing" (the optimizer has license to discard
undefined behavior).

Refinement is a fundamental aspect of many mid-level optimizations done
by LLVM.  For instance, transforming `x == (x + 1)` to `false` also
involves refinement since the expression's value went from "if x is
`undef` then { `true` or `false` } else { `false` }" to "`false`" (by
definition, the optimizer has license to fold `undef` to any non-`undef`
value).

Unfortunately, refinement implies that the optimizer cannot assume
that the implementation of a function it can see has all of the
behavior an unoptimized or a differently optimized version of the same
function can have.  This is a problem for functions with comdat
linkage, where a function can be replaced by an unoptimized or a
differently optimized version of the same source level function.

For instance, FunctionAttrs cannot assume a comdat function is
actually `readnone` even if it does not have any loads or stores in
it; since there may have been loads and stores in the "original
function" that were refined out in the currently visible variant, and
at the link step the linker may in fact choose an implementation with
a load or a store.  As an example, consider a function that does two
atomic loads from the same memory location, and writes to memory only
if the two values are not equal.  The optimizer is allowed to refine
this function by first CSE'ing the two loads, and the folding the
comparision to always report that the two values are equal.  Such a
refined variant will look like it is `readonly`.  However, the
unoptimized version of the function can still write to memory (since
the two loads //can// result in different values), and selecting the
unoptimized version at link time will retroactively invalidate
transforms we may have done under the assumption that the function
does not write to memory.

Note: this is not just a problem with atomics or with linking
differently optimized object files.  See PR26774 for more realistic
examples that involved neither.

This patch:

This change introduces a new set of linkage types, predicated as
`GlobalValue::mayBeDerefined` that returns true if the linkage type
allows a function to be replaced by a differently optimized variant at
link time.  It then changes a set of IPO passes to bail out if they see
such a function.

Reviewers: chandlerc, hfinkel, dexonsmith, joker.eph, rnk

Subscribers: mcrosier, llvm-commits

Differential Revision: http://reviews.llvm.org/D18634

llvm-svn: 265762

8 years agoValueMapper: Unduplicate RF_NoModuleLevelChanges check, NFC
Duncan P. N. Exon Smith [Fri, 8 Apr 2016 00:41:10 +0000 (00:41 +0000)]
ValueMapper: Unduplicate RF_NoModuleLevelChanges check, NFC

llvm-svn: 265761

8 years agoDwarfDebug: Support floating point constants in location lists.
Adrian Prantl [Fri, 8 Apr 2016 00:38:37 +0000 (00:38 +0000)]
DwarfDebug: Support floating point constants in location lists.

This patch closes a gap in the DWARF backend that caused LLVM to drop
debug info for floating point variables that were constant for part of
their scope. Floating point constants are emitted as one or more
DW_OP_constu joined via DW_OP_piece.

This fixes a regression caught by the LLDB testsuite that I introduced
in r262247 when we stopped blindly expanding the range of singular
DBG_VALUEs to span the entire scope and started to emit location lists
with accurate ranges instead.

Also deletes a now-impossible testcase (debug-loc-empty-entries).

<rdar://problem/25448338>

llvm-svn: 265760

8 years agoValueMapper: Treat LocalAsMetadata more like function-local Values
Duncan P. N. Exon Smith [Fri, 8 Apr 2016 00:33:44 +0000 (00:33 +0000)]
ValueMapper: Treat LocalAsMetadata more like function-local Values

This is a partial re-commit -- maybe more of a re-implementation -- of
r265631 (reverted in r265637).

This makes RF_IgnoreMissingLocals behave (almost) consistently between
the Value and the Metadata hierarchy.  In particular:

  - MapValue returns nullptr or "metadata !{}" for missing locals in
    MetadataAsValue/LocalAsMetadata bridging paris, depending on
    the RF_IgnoreMissingLocals flag.

  - MapValue doesn't memoize LocalAsMetadata-related results.

  - MapMetadata no longer deals with LocalAsMetadata or
    RF_IgnoreMissingLocals at all.  (This wasn't in r265631 at all, but
    I realized during testing it would make the patch simpler with no
    loss of generality.)

r265631 went too far, making both functions universally ignore
RF_IgnoreMissingLocals.  This broke building (e.g.) compiler-rt.
Reassociate (and possibly other passes) don't currently maintain
dominates-use invariants for metadata operands, resulting in IR like
this:

    define void @foo(i32 %arg) {
      call void @llvm.some.intrinsic(metadata i32 %x)
      %x = add i32 1, i32 %arg
    }

If the inliner chooses to inline @foo into another function, then
RemapInstruction will call `MapValue(metadata i32 %x)` and assert that
the return is not nullptr.

I've filed PR27273 to add a Verifier check and fix the underlying
problem in the optimization passes.

As a workaround, return `!{}` instead of nullptr for unmapped
LocalAsMetadata when RF_IgnoreMissingLocals is unset.  Otherwise, match
the behaviour of r265631.

Original commit message:

    ValueMapper: Make LocalAsMetadata match function-local Values

    Start treating LocalAsMetadata similarly to function-local members of
    the Value hierarchy in MapValue and MapMetadata.

      - Don't memoize them.
      - Return nullptr if they are missing.

    This also cleans up ConstantAsMetadata to stop listening to the
    RF_IgnoreMissingLocals flag.

llvm-svn: 265759

8 years agoSimplify createELFFile. NFC.
Rui Ueyama [Fri, 8 Apr 2016 00:18:25 +0000 (00:18 +0000)]
Simplify createELFFile. NFC.

llvm-svn: 265758

8 years agoDefine a helper function to simplify. NFC.
Rui Ueyama [Fri, 8 Apr 2016 00:14:55 +0000 (00:14 +0000)]
Define a helper function to simplify. NFC.

llvm-svn: 265757

8 years ago[modules] Don't write @import in -E output if the current language mode doesn't
Richard Smith [Fri, 8 Apr 2016 00:09:53 +0000 (00:09 +0000)]
[modules] Don't write @import in -E output if the current language mode doesn't
support @import; use the form as written instead.

llvm-svn: 265756

8 years agoRevert "[TargetRegisterInfo] Refactor the code to use BitMaskClassIterator."
Quentin Colombet [Fri, 8 Apr 2016 00:03:51 +0000 (00:03 +0000)]
Revert "[TargetRegisterInfo] Refactor the code to use BitMaskClassIterator."

This reverts commit r265734.
Looks like ASan is not happy about it.
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/11741

Looking.

llvm-svn: 265755

8 years ago[RegisterBankInfo] Make the debug output more compact.
Quentin Colombet [Fri, 8 Apr 2016 00:03:49 +0000 (00:03 +0000)]
[RegisterBankInfo] Make the debug output more compact.

Print the mask of the partial mapping as an hexadecimal instead of a
binary value.

llvm-svn: 265754

8 years agoFix formatting and wording of llvm-ranlib error message. NFC.
Sunil Srivastava [Fri, 8 Apr 2016 00:02:14 +0000 (00:02 +0000)]
Fix formatting and wording of llvm-ranlib error message. NFC.

Patch by Douglas Yung!

Reviewed by Rafael Espindola

llvm-svn: 265753

8 years ago[IR/Verifier] Fix (yet another) crash.
Davide Italiano [Fri, 8 Apr 2016 00:01:32 +0000 (00:01 +0000)]
[IR/Verifier] Fix (yet another) crash.

We need to check that if we reference a retainedType from
DICompileUnit we're actually referencing a DICompositeType.

llvm-svn: 265752

8 years ago[CUDA] Tweak math forward declares so we're compatible with libstdc++4.9.
Justin Lebar [Thu, 7 Apr 2016 23:55:53 +0000 (23:55 +0000)]
[CUDA] Tweak math forward declares so we're compatible with libstdc++4.9.

Summary:
See comments in patch; we were assuming that some stdlib math functions
would be defined in namespace std, when in fact the spec says they
should be defined in the global namespace.  libstdc++4.9 became more
conforming and broke us.

This new implementation seems to cover the known knowns.

Reviewers: rsmith

Subscribers: cfe-commits, tra

Differential Revision: http://reviews.llvm.org/D18882

llvm-svn: 265751

8 years agoUse EM_NONE instead of 0 to represent an invalid value. NFC.
Rui Ueyama [Thu, 7 Apr 2016 23:54:33 +0000 (23:54 +0000)]
Use EM_NONE instead of 0 to represent an invalid value. NFC.

llvm-svn: 265750

8 years ago[RegBankSelect] Add a few debug statements.
Quentin Colombet [Thu, 7 Apr 2016 23:53:55 +0000 (23:53 +0000)]
[RegBankSelect] Add a few debug statements.

llvm-svn: 265749

8 years agoELF: Add --build-id=sha1 option.
Rui Ueyama [Thu, 7 Apr 2016 23:51:56 +0000 (23:51 +0000)]
ELF: Add --build-id=sha1 option.

llvm-svn: 265748

8 years ago[RegisterBankInfo] Add print and dump method to the InstructionMapping
Quentin Colombet [Thu, 7 Apr 2016 23:31:58 +0000 (23:31 +0000)]
[RegisterBankInfo] Add print and dump method to the InstructionMapping
helper class.

llvm-svn: 265747

8 years ago[RegisterBankInfo] Add print and dump method to the ValueMapping helper
Quentin Colombet [Thu, 7 Apr 2016 23:25:43 +0000 (23:25 +0000)]
[RegisterBankInfo] Add print and dump method to the ValueMapping helper
class.

llvm-svn: 265746

8 years ago[MachineInstr] Teach the print method about RegisterBank.
Quentin Colombet [Thu, 7 Apr 2016 23:18:11 +0000 (23:18 +0000)]
[MachineInstr] Teach the print method about RegisterBank.

Properly print either the register class or the register bank or a
virtual register.
Get rid of a few ifdefs in the process.

llvm-svn: 265745

8 years agoELF: Ignore --detect-odr-violations flag.
Peter Collingbourne [Thu, 7 Apr 2016 23:15:50 +0000 (23:15 +0000)]
ELF: Ignore --detect-odr-violations flag.

Differential Revision: http://reviews.llvm.org/D18877

llvm-svn: 265744

8 years ago[AArch64] Fix a typo in the register class to register bank mapping.
Quentin Colombet [Thu, 7 Apr 2016 23:10:14 +0000 (23:10 +0000)]
[AArch64] Fix a typo in the register class to register bank mapping.

For GPR family we want the GPR register bank, not FPR!

llvm-svn: 265743

8 years ago[RegisterBankInfo] Escap \@ in r265741. [-Wdocumentation]
Quentin Colombet [Thu, 7 Apr 2016 23:08:52 +0000 (23:08 +0000)]
[RegisterBankInfo] Escap \@ in r265741. [-Wdocumentation]

llvm-svn: 265742

8 years ago[RegisterBankInfo] Change the semantic of recordRegBankForType.
Quentin Colombet [Thu, 7 Apr 2016 23:02:00 +0000 (23:02 +0000)]
[RegisterBankInfo] Change the semantic of recordRegBankForType.

Now, recordRegBankForType records only the first register bank that
covers a type instead of the last. This behavior can, nevertheless, be
override with the additional Force parameter to force the update.

llvm-svn: 265741

8 years agollvm-dwarfdump: Use deque rather than vector to preserve object reference/pointer...
David Blaikie [Thu, 7 Apr 2016 22:59:58 +0000 (22:59 +0000)]
llvm-dwarfdump: Use deque rather than vector to preserve object reference/pointer identity

TUs in each unit refer to the unit they are in, if the unit is moved
this reference is invalidated & things break.

No test case because UB isn't testable - ASan would likely catch this on
a large enough test case (just needs to have enough TUs that a
reallocation of the vector would occur) but didn't seem worthwhile. Up
for debate/revisiting if anyone feels strongly.

llvm-svn: 265740

8 years ago[RegisterBankInfo] Strengthen getInstrMappingImpl.
Quentin Colombet [Thu, 7 Apr 2016 22:52:49 +0000 (22:52 +0000)]
[RegisterBankInfo] Strengthen getInstrMappingImpl.

Teach the target independent code how to take advantage of type
information to get the mapping of an instruction.

llvm-svn: 265739

8 years agoFix TestImport for Windows by ensuring backslashes in the directory paths are properl...
Adrian McCarthy [Thu, 7 Apr 2016 22:52:12 +0000 (22:52 +0000)]
Fix TestImport for Windows by ensuring backslashes in the directory paths are properly escaped in Python.

The Python import works by ensuring the directory of the module or package is in sys.path, and then it does a Python `import foo`.  The original code was not escaping the backslashes in the directory path, so this wasn't working.

Differential Revision: http://reviews.llvm.org/D18873

llvm-svn: 265738

8 years agoELF: Implement --build-id=md5.
Rui Ueyama [Thu, 7 Apr 2016 22:49:21 +0000 (22:49 +0000)]
ELF: Implement --build-id=md5.

Previously, we supported only one hash function, FNV-1, so
BuildIdSection directly handled hash computation. In this patch,
I made BuildIdSection an abstract class and defined two subclasses,
BuildIdFnv1 and BuildIdMd5.

llvm-svn: 265737

8 years ago[RegisterBankInfo] Add a way to record what register bank covers a
Quentin Colombet [Thu, 7 Apr 2016 22:45:42 +0000 (22:45 +0000)]
[RegisterBankInfo] Add a way to record what register bank covers a
specific type.

This will be used to find the default mapping of the instruction.
Also, this information is recorded, instead of computed, because it is
expensive from a type to know which register bank maps it.
Indeed, we need to iterate through all the register classes of all the
register banks to find the one that maps the given type.

llvm-svn: 265736

8 years ago[RegisterBankInfo] Introduce getRegBankFromConstraints as an helper
Quentin Colombet [Thu, 7 Apr 2016 22:35:03 +0000 (22:35 +0000)]
[RegisterBankInfo] Introduce getRegBankFromConstraints as an helper
method.

NFC.

The refactoring intends to make the code more readable and expose
more features to potential derived classes.

llvm-svn: 265735

8 years ago[TargetRegisterInfo] Refactor the code to use BitMaskClassIterator.
Quentin Colombet [Thu, 7 Apr 2016 22:16:56 +0000 (22:16 +0000)]
[TargetRegisterInfo] Refactor the code to use BitMaskClassIterator.

llvm-svn: 265734

8 years ago[RegisterBankInfo] Refactor the code to use BitMaskClassIterator.
Quentin Colombet [Thu, 7 Apr 2016 22:08:56 +0000 (22:08 +0000)]
[RegisterBankInfo] Refactor the code to use BitMaskClassIterator.

llvm-svn: 265733

8 years agoIn GDBRemoteCommunicationClient::GetHostInfo, don't set the
Jason Molenda [Thu, 7 Apr 2016 22:00:55 +0000 (22:00 +0000)]
In GDBRemoteCommunicationClient::GetHostInfo, don't set the
os to "ios" or "macosx" if it is unspecified.  For environments
where there genuinely is no os, we don't want to errantly
convert that to ios/macosx, e.g. bare board debugging.

Change PlatformRemoteiOS, PlatformRemoteAppleWatch, and
PlatformRemoteAppleTV to not create themselves if we have
an unspecified OS.  Same problem - these are not appropriate
platforms for bare board debugging environments.

Have Process::Attach's logging take place if either
process or target logging is enabled.

<rdar://problem/25592378>

llvm-svn: 265732

8 years agoConst correctness for BranchProbabilityInfo (NFC)
Mehdi Amini [Thu, 7 Apr 2016 21:59:28 +0000 (21:59 +0000)]
Const correctness for BranchProbabilityInfo (NFC)

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 265731

8 years ago[TargetRegisterInfo] Introduce a helper class, BitMaskClassIterator, to
Quentin Colombet [Thu, 7 Apr 2016 21:55:21 +0000 (21:55 +0000)]
[TargetRegisterInfo] Introduce a helper class, BitMaskClassIterator, to
iterate over register class bitmask.

Thanks to this helper class, it would not require for each user of the
register classes bitmask to actually know how they are represents.
Moreover, it will make the code much easier to read.

llvm-svn: 265730

8 years agoRename parameter I to Index for WriteCombinedGlobalValueSummary() (NFC)
Mehdi Amini [Thu, 7 Apr 2016 21:49:31 +0000 (21:49 +0000)]
Rename parameter I to Index for WriteCombinedGlobalValueSummary() (NFC)

From: Mehdi Amini <mehdi.amini@apple.com>
llvm-svn: 265729

8 years agoReplace Sema-level implementation of -fassume-sane-operator-new with a
Richard Smith [Thu, 7 Apr 2016 21:46:12 +0000 (21:46 +0000)]
Replace Sema-level implementation of -fassume-sane-operator-new with a
CodeGen-level implementation. Instead of adding an attribute to clang's
FunctionDecl, add the IR attribute directly. This means a module built with
this flag is now compatible with code built without it and vice versa.

This change also results in the 'noalias' attribute no longer being added to
calls to operator new in the IR; it's now only added to the declaration. It
also fixes a bug where we failed to add the attribute to the 'nothrow' versions
(because we didn't implicitly declare them, there was no good time to inject a
fake attribute).

llvm-svn: 265728

8 years ago[RegBankSelect] Reuse RegisterBankInfo logic to get to the register bank
Quentin Colombet [Thu, 7 Apr 2016 21:32:23 +0000 (21:32 +0000)]
[RegBankSelect] Reuse RegisterBankInfo logic to get to the register bank
from a register.
On top of duplicating the logic, it was buggy! It would assert on
physical registers, since MachineRegisterInfo does not have any
information regarding register classes/banks for them.

llvm-svn: 265727

8 years agoDo not select EhPad BB in MachineBlockPlacement when there is regular BB to schedule
Amaury Sechet [Thu, 7 Apr 2016 21:29:39 +0000 (21:29 +0000)]
Do not select EhPad BB in MachineBlockPlacement when there is regular BB to schedule

Summary:
EHPad BB are not entered the classic way and therefor do not need to be placed after their predecessors. This patch make sure EHPad BB are not chosen amongst successors to form chains, and are selected as last resort when selecting the best candidate.

EHPad are scheduled in reverse probability order in order to have them flow into each others naturally.

Reviewers: chandlerc, majnemer, rafael, MatzeB, escha, silvas

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D17625

llvm-svn: 265726

8 years ago[AArch64] Get rid of some GlobalISel ifdefs.
Quentin Colombet [Thu, 7 Apr 2016 21:24:40 +0000 (21:24 +0000)]
[AArch64] Get rid of some GlobalISel ifdefs.

llvm-svn: 265725

8 years agoSort options.
Rui Ueyama [Thu, 7 Apr 2016 21:10:42 +0000 (21:10 +0000)]
Sort options.

llvm-svn: 265724

8 years agoELF: Define -S as an alias for --strip-debug.
Rui Ueyama [Thu, 7 Apr 2016 21:10:09 +0000 (21:10 +0000)]
ELF: Define -S as an alias for --strip-debug.

llvm-svn: 265723

8 years agoELF: Add --strip-debug option.
Rui Ueyama [Thu, 7 Apr 2016 21:04:51 +0000 (21:04 +0000)]
ELF: Add --strip-debug option.

If --strip-debug option is given, then all sections whose names start
with ".debug" are removed from output.

llvm-svn: 265722

8 years ago[TargetRegisterInfo] Fix the comment of SuperRegClassIterator::getMask.
Quentin Colombet [Thu, 7 Apr 2016 21:04:30 +0000 (21:04 +0000)]
[TargetRegisterInfo] Fix the comment of SuperRegClassIterator::getMask.

llvm-svn: 265721

8 years ago[AArch64] gcc does not like litteral without quotes even on preprocessor macros.
Quentin Colombet [Thu, 7 Apr 2016 20:49:15 +0000 (20:49 +0000)]
[AArch64] gcc does not like litteral without quotes even on preprocessor macros.

llvm-svn: 265720