platform/upstream/llvm.git
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

8 years ago[AArch64][CallLowering] Do not build the API if GlobalISel is not built.
Quentin Colombet [Thu, 7 Apr 2016 20:47:51 +0000 (20:47 +0000)]
[AArch64][CallLowering] Do not build the API if GlobalISel is not built.
This gets rid of some ifdefs and dummy implementations that were here
just to fill the blanks.

llvm-svn: 265719

8 years ago[modules] Allow differences in flags that only affect preprocessor predefines
Richard Smith [Thu, 7 Apr 2016 20:47:37 +0000 (20:47 +0000)]
[modules] Allow differences in flags that only affect preprocessor predefines
(and __has_feature checks) between explicitly-specified module files and the
current compilation.

llvm-svn: 265718

8 years agoELF: Add --no-gnu-unique option.
Rui Ueyama [Thu, 7 Apr 2016 20:41:41 +0000 (20:41 +0000)]
ELF: Add --no-gnu-unique option.

When the option is specified, then all STB_GNU_UNIQUE symbols are
converted to STB_GLOBAL symbols.

llvm-svn: 265717

8 years ago[GlobalISel] Add RegBankSelect hooks into the pass pipeline.
Quentin Colombet [Thu, 7 Apr 2016 20:27:33 +0000 (20:27 +0000)]
[GlobalISel] Add RegBankSelect hooks into the pass pipeline.
Now, RegBankSelect will happen after the IRTranslation and the target
may optionally add additional passes in between.

llvm-svn: 265716

8 years ago[sanitizer] Fix sem_init_glibc.cc test on __HAVE_64B_ATOMIC arches.
Evgeniy Stepanov [Thu, 7 Apr 2016 20:26:28 +0000 (20:26 +0000)]
[sanitizer] Fix sem_init_glibc.cc test on __HAVE_64B_ATOMIC arches.

glibc can use one of 2 layouts for semaphores: architectures that
don't HAVE_64B_ATOMIC use an uint32_t field with semaphore value,
then a private field, then a waiting thread count field - this is
the layout currently assumed by the test. However, HAVE_64B_ATOMIC
arches use a fused uint64_t field that contains the value in low bits
and waiting thread count in high bits, followed by a private field.

This resulted in taking private field from the wrong offset on 64-bit
atomic platforms (the test still passed, but didn't actually test
the private field). On big-endian platforms, this resulted in a fail,
since the first 4 bytes overlay the thread count field, and not
the value field.

Found while porting ASan to s390x.

Patch by Marcin KoÅ›cielnicki.

llvm-svn: 265715

8 years ago[sancov] updaing android test after enabling cc edge pruning
Mike Aizatsky [Thu, 7 Apr 2016 20:21:21 +0000 (20:21 +0000)]
[sancov] updaing android test after enabling cc edge pruning

llvm-svn: 265714

8 years ago[AMDGPU] Implement get_local_size for amdgcn--amdhsa triple
Konstantin Zhuravlyov [Thu, 7 Apr 2016 19:54:19 +0000 (19:54 +0000)]
[AMDGPU] Implement get_local_size for amdgcn--amdhsa triple

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

llvm-svn: 265713

8 years ago[ObjC kindof] Use type bound to filter out the candidate methods.
Manman Ren [Thu, 7 Apr 2016 19:32:24 +0000 (19:32 +0000)]
[ObjC kindof] Use type bound to filter out the candidate methods.

rdar://21306753

llvm-svn: 265712

8 years agoNFC: simplify code in BuildInstanceMessage.
Manman Ren [Thu, 7 Apr 2016 19:30:20 +0000 (19:30 +0000)]
NFC: simplify code in BuildInstanceMessage.

Instead of searching the global pool multiple times: in
LookupFactoryMethodInGlobalPool, LookupInstanceMethodInGlobalPool,
CollectMultipleMethodsInGlobalPool, and AreMultipleMethodsInGlobalPool,
we now collect the method candidates in CollectMultipleMethodsInGlobalPool
only, and other functions will use the collected method set.

This commit adds parameter "Methods" to AreMultipleMethodsInGlobalPool,
and SelectBestMethod. It also changes the implementation of
CollectMultipleMethodsInGlobalPool to collect the desired kind first, if none is
found, to collect the other kind. This avoids the need to call both
LookupFactoryMethodInGlobalPool and LookupInstanceMethodInGlobalPool.

llvm-svn: 265711

8 years agoELF: Implement --start-lib and --end-lib
Rui Ueyama [Thu, 7 Apr 2016 19:24:51 +0000 (19:24 +0000)]
ELF: Implement --start-lib and --end-lib

start-lib and end-lib are options to link object files in the same
semantics as archive files. If an object is in start-lib and end-lib,
the object is linked only when the file is needed to resolve
undefined symbols. That means, if an object is in start-lib and end-lib,
it behaves as if it were in an archive file.

In this patch, I introduced a new notion, LazyObjectFile. That is
analogous to Archive file type, but that works for a single object
file instead of for an archive file.

http://reviews.llvm.org/D18814

llvm-svn: 265710

8 years agoAMDGPU/SI: Implement atomic load/store for i32 and i64
Jan Vesely [Thu, 7 Apr 2016 19:23:11 +0000 (19:23 +0000)]
AMDGPU/SI: Implement atomic load/store for i32 and i64

Standard load/store instructions with GLC bit set.

Reviewers: tstellardAMD, arsenm

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

llvm-svn: 265709

8 years agoAMDGPU/SI: Add latency for export instructions
Tom Stellard [Thu, 7 Apr 2016 18:30:05 +0000 (18:30 +0000)]
AMDGPU/SI: Add latency for export instructions

Reviewers: arsenm, nhaehnle

Subscribers: nhaehnle, arsenm, llvm-commits

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

llvm-svn: 265708

8 years ago[RegBankSelect] Initial implementation for non-optimized output.
Quentin Colombet [Thu, 7 Apr 2016 18:19:27 +0000 (18:19 +0000)]
[RegBankSelect] Initial implementation for non-optimized output.
The pass walk through the machine function and assign the register banks
using the default mapping. In other words, there is no attempt to reduce
cross register copies.

llvm-svn: 265707

8 years agoRecommit r263036 with additional inlining, so that it will continue to work with...
Marshall Clow [Thu, 7 Apr 2016 18:13:41 +0000 (18:13 +0000)]
Recommit r263036 with additional inlining, so that it will continue to work with existing system dylibs. Implements LWG#2583

llvm-svn: 265706

8 years ago[sanitizer] Add early call handling to strlen interceptor
Derek Bruening [Thu, 7 Apr 2016 18:07:09 +0000 (18:07 +0000)]
[sanitizer] Add early call handling to strlen interceptor

Summary:
The strlen interceptor is sometimes invoked too early for REAL(strlen) to
be initialized.  A special check is added to use internal_strlen for this
situation.

Reviewers: dim

Subscribers: llvm-commits, samsonov

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

Change-Id: I3acc58f4abbae1904f25324abd84efea67aad0a2
llvm-svn: 265705

8 years ago[RegisterBankInfo] Add more details on the expectation of
Quentin Colombet [Thu, 7 Apr 2016 18:07:07 +0000 (18:07 +0000)]
[RegisterBankInfo] Add more details on the expectation of
getInstrMapping.

llvm-svn: 265704

8 years ago[RegisterBankInfo] Provide a target independent helper function to guess
Quentin Colombet [Thu, 7 Apr 2016 18:01:19 +0000 (18:01 +0000)]
[RegisterBankInfo] Provide a target independent helper function to guess
the mapping of an instruction on register bank.

For most instructions, it is possible to guess the mapping of the
instruciton by using the encoding constraints.
It remains instructions without encoding constraints.
For copy-like instructions, we try to propagate the information we get
from the other operands. Otherwise, the target has to give this
information.

llvm-svn: 265703

8 years agoBasic: move CodeGenOptions from Frontend
Saleem Abdulrasool [Thu, 7 Apr 2016 17:49:44 +0000 (17:49 +0000)]
Basic: move CodeGenOptions from Frontend

This is a mechanical move of CodeGenOptions from libFrontend to libBasic.  This
fixes the layering violation introduced earlier by threading CodeGenOptions into
TargetInfo.  It should also fix the modules based self-hosting builds.  NFC.

llvm-svn: 265702

8 years ago[RegisterBankInfo] Change the signature of getSizeInBits to factor out
Quentin Colombet [Thu, 7 Apr 2016 17:44:54 +0000 (17:44 +0000)]
[RegisterBankInfo] Change the signature of getSizeInBits to factor out
the access to MRI and TRI.

llvm-svn: 265701

8 years agoMinor Wdocumentation fix. NFCI.
Simon Pilgrim [Thu, 7 Apr 2016 17:38:24 +0000 (17:38 +0000)]
Minor Wdocumentation fix. NFCI.

llvm-svn: 265700

8 years ago[RegisterBankInfo] Provide a default constructor for InstructionMapping
Quentin Colombet [Thu, 7 Apr 2016 17:30:18 +0000 (17:30 +0000)]
[RegisterBankInfo] Provide a default constructor for InstructionMapping
helper class.

The default constructor creates invalid (isValid() == false) instances
and may be used to communicate that a mapping was not found.

llvm-svn: 265699

8 years agoMention readability-static-definition-in-anonymous-namespace in release notes.
Eugene Zelenko [Thu, 7 Apr 2016 17:28:35 +0000 (17:28 +0000)]
Mention readability-static-definition-in-anonymous-namespace in release notes.

Consistency in using ` and ``.

Differential revision: http://reviews.llvm.org/D18797

llvm-svn: 265698

8 years ago[X86][SSE] Added bitmask pattern shuffle tests
Simon Pilgrim [Thu, 7 Apr 2016 17:23:55 +0000 (17:23 +0000)]
[X86][SSE] Added bitmask pattern shuffle tests

Based on OR(AND(MASK,V0),AND(~MASK,V1)) style patterns

llvm-svn: 265697

8 years ago[MachineRegisterInfo] Track register bank for virtual registers.
Quentin Colombet [Thu, 7 Apr 2016 17:20:29 +0000 (17:20 +0000)]
[MachineRegisterInfo] Track register bank for virtual registers.
A virtual register may have either a register bank or a register class.
This is represented by a PointerUnion between the related classes.

Typically, a virtual register went through the following states
regarding register class and register bank:

1. Creation: None is set. Virtual registers are fully generic.
2. Register bank assignment: Register bank is set. Virtual registers
live into a register bank, but we do not know the constraints they need
to fulfil.
3. Instruction selection: Register class is set. Virtual registers are
bound by encoding constraints.

To map these states to GlobalISel, the IRTranslator implements #1,
RegBankSelect #2, and Select #3.

llvm-svn: 265696

8 years ago[RegisterBank] Rename RegisterBank::contains into RegisterBank::covers.
Quentin Colombet [Thu, 7 Apr 2016 17:09:39 +0000 (17:09 +0000)]
[RegisterBank] Rename RegisterBank::contains into RegisterBank::covers.

llvm-svn: 265695

8 years ago[PPC] Added a note to release notes
Ehsan Amiri [Thu, 7 Apr 2016 16:47:35 +0000 (16:47 +0000)]
[PPC] Added a note to release notes

A draft line added to release notes for PPC, to keep a record of changes.
This is just a draft and will be rewritten towards the end of release.

llvm-svn: 265694

8 years ago[SystemZ] Fix build break from r265689
Ulrich Weigand [Thu, 7 Apr 2016 16:33:25 +0000 (16:33 +0000)]
[SystemZ] Fix build break from r265689

Fix build error seen on some build bots due to:
error: default label in switch which covers all enumeration values

llvm-svn: 265693

8 years ago[sancov] updaing android test
Mike Aizatsky [Thu, 7 Apr 2016 16:22:34 +0000 (16:22 +0000)]
[sancov] updaing android test

llvm-svn: 265692

8 years ago[clang-tidy] add new checker for string literal with NUL character.
Etienne Bergeron [Thu, 7 Apr 2016 16:16:36 +0000 (16:16 +0000)]
[clang-tidy] add new checker for string literal with NUL character.

Summary:
This patch adds the support for detecting suspicious string
literals and their //incorrect// usage.

The following example shows a incorrect character escaping leading
to an embedded NUL character.
```
  std::string str = "\0x42";   // Should be "\x42".
```

The patch also add detection of truncated literal when a literal
is passed to a string constructor.

Reviewers: hokein, alexfh

Subscribers: LegalizeAdulthood, bcraig, Eugene.Zelenko, bkramer, cfe-commits

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

llvm-svn: 265691

8 years ago[X86]: Fix for PR27251.
Kevin B. Smith [Thu, 7 Apr 2016 16:15:34 +0000 (16:15 +0000)]
[X86]: Fix for PR27251.
Differential Revision: http://reviews.llvm.org/D18850

llvm-svn: 265690

8 years ago[SystemZ] Implement conditional returns
Ulrich Weigand [Thu, 7 Apr 2016 16:11:44 +0000 (16:11 +0000)]
[SystemZ] Implement conditional returns

Return is now considered a predicable instruction, and is converted
to a newly-added CondReturn (which maps to BCR to %r14) instruction by
the if conversion pass.

Also, fused compare-and-branch transform knows about conditional
returns, emitting the proper fused instructions for them.

This transform triggers on a *lot* of tests, hence the huge diffstat.
The changes are mostly jX to br %r14 -> bXr %r14.

Author: koriakin

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

llvm-svn: 265689

8 years ago[IR/Verifier] Merge two ifs into one. NFC.
Davide Italiano [Thu, 7 Apr 2016 15:55:28 +0000 (15:55 +0000)]
[IR/Verifier] Merge two ifs into one. NFC.

llvm-svn: 265688

8 years ago[GVN] Address review comments for D18662
Ulrich Weigand [Thu, 7 Apr 2016 15:55:11 +0000 (15:55 +0000)]
[GVN] Address review comments for D18662

As suggested by Chandler in his review comments for D18662, this
follow-on patch renames some variables in GetLoadValueForLoad and
CoerceAvailableValueToLoadType to hopefully make it more obvious
which variables hold value sizes and which hold load/store sizes.

No functional change intended.

llvm-svn: 265687

8 years agoFix an use after free.
Rafael Espindola [Thu, 7 Apr 2016 15:50:23 +0000 (15:50 +0000)]
Fix an use after free.

Thanks to asan for pointing it out that OutputSections was being
resized.

llvm-svn: 265686

8 years agoNFC: disallow comparison of AtomicOrdering
JF Bastien [Thu, 7 Apr 2016 15:50:05 +0000 (15:50 +0000)]
NFC: disallow comparison of AtomicOrdering

Follow-up to D18775 and related clang change. AtomicOrdering is a lattice, 'stronger' is the right thing to do, direct comparison is fraught with peril.

llvm-svn: 265685

8 years ago[GVN] Fix handling of sub-byte types in big-endian mode
Ulrich Weigand [Thu, 7 Apr 2016 15:45:02 +0000 (15:45 +0000)]
[GVN] Fix handling of sub-byte types in big-endian mode

When GVN wants to re-interpret an already available value in a smaller
type, it needs to right-shift the value on big-endian systems to ensure
the correct bytes are accessed.  The shift value is the difference of
the sizes of the two types.

This is correct as long as both types occupy multiples of full bytes.
However, when one of them is a sub-byte type like i1, this no longer
holds true: we still need to shift, but only to access the correct
*byte*.  Accessing bits within the byte requires no shift in either
endianness; e.g. an i1 resides in the least-significant bit of its
containing byte on both big- and little-endian systems.

Therefore, the appropriate shift value to be used is the difference of
the *storage* sizes of the two types.  This is already handled correctly
in one place where such a shift takes place (GetStoreValueForLoad), but
is incorrect in two other places: GetLoadValueForLoad and
CoerceAvailableValueToLoadType.

This patch changes both places to use the storage size as well.

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

llvm-svn: 265684

8 years ago[PPC] Enable transformations in PPCPassConfig::addIRPasses at O2
Ehsan Amiri [Thu, 7 Apr 2016 15:30:55 +0000 (15:30 +0000)]
[PPC] Enable transformations in PPCPassConfig::addIRPasses at O2

http://reviews.llvm.org/D18562

A large number of testcases has been modified so they pass after this test.
One testcase is deleted, because I realized even after undoing the original
change that was committed with this testcase, the testcase still passes. So
I removed it. The change to one other testcase (test/CodeGen/PowerPC/pr25802.ll)
is an arbitrary change to keep it passing. Given the original intention of the
testcase, and the fact that fixing it will require some time to change the testcase,
we concluded that this quick change will be enough.

llvm-svn: 265683

8 years agoSimplify dynamic relocation creation.
Rafael Espindola [Thu, 7 Apr 2016 15:20:56 +0000 (15:20 +0000)]
Simplify dynamic relocation creation.

The position of a relocation can always be expressed as an offset in an
output section.

llvm-svn: 265682

8 years ago[clang-tidy] fix a crash with -fdelayed-template-parsing in UnnecessaryValueParamCheck.
Etienne Bergeron [Thu, 7 Apr 2016 14:58:13 +0000 (14:58 +0000)]
[clang-tidy] fix a crash with -fdelayed-template-parsing in UnnecessaryValueParamCheck.

Summary:
This is the same kind of bug than [[ http://reviews.llvm.org/D18238 | D18238 ]].

Fix crashes caused by deferencing null pointer when declarations parsing may be delayed.
The body of the declarations may be null.

The crashes were observed with a Windows build of clang-tidy and the following command-line.
```
command-line switches: -fms-compatibility-version=19 -fms-compatibility
```

Reviewers: alexfh

Subscribers: kimgr, LegalizeAdulthood, cfe-commits

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

llvm-svn: 265681

8 years ago[clang-tidy] Remove unnecessary getName() on Decls and Types feeding into a Diagnosti...
Benjamin Kramer [Thu, 7 Apr 2016 14:55:25 +0000 (14:55 +0000)]
[clang-tidy] Remove unnecessary getName() on Decls and Types feeding into a DiagnosticBuilder

Going through a string removes some of the smarts of the diagnosic printer
and makes the code more complicated. This change has some cosmetic impact
on the output but that's mostly minor.

llvm-svn: 265680

8 years ago[clang-tidy] Fix infinite loop in MisplacedWideningCastCheck.
Etienne Bergeron [Thu, 7 Apr 2016 14:52:52 +0000 (14:52 +0000)]
[clang-tidy] Fix infinite loop in MisplacedWideningCastCheck.

Summary:
In Release mode, the check was infinite looping over chromium code base.

It seems there is something strange with the creation of the Maps.
I believe the compiler is making some assumption with the implicit conversion from enum <-> int.

By moving the map to a standard switch/cases, we no longer allocate memory and we can keep the same behavior. For a small amount of elements, this is fine.

Reviewers: alexfh

Subscribers: cfe-commits

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

llvm-svn: 265679

8 years agoAMDGPU/SI: Add MachineBasicBlock parameter to SIInstrInfo::insertWaitStates
Tom Stellard [Thu, 7 Apr 2016 14:47:07 +0000 (14:47 +0000)]
AMDGPU/SI: Add MachineBasicBlock parameter to SIInstrInfo::insertWaitStates

Summary: This makes it possible to insert nops at the end of blocks.

Reviewers: arsenm

Subscribers: arsenm, llvm-commits

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

llvm-svn: 265678

8 years agoFixing duplicate declaration "_mm256 _mm_set_epi32" in revision 262177
Michael Zuckerman [Thu, 7 Apr 2016 14:44:08 +0000 (14:44 +0000)]
Fixing duplicate declaration "_mm256 _mm_set_epi32" in revision 262177

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

llvm-svn: 265677

8 years agoDelete Off_Bss.
Rafael Espindola [Thu, 7 Apr 2016 14:34:15 +0000 (14:34 +0000)]
Delete Off_Bss.

It is now just a special case of Off_Sec.

llvm-svn: 265676

8 years agomake __builtin_isfinite more efficient (PR27145)
Sanjay Patel [Thu, 7 Apr 2016 14:29:05 +0000 (14:29 +0000)]
make __builtin_isfinite more efficient (PR27145)

isinf (is infinite) and isfinite should be implemented with the same function
except we change the comparison operator.

See PR27145 for more details:
https://llvm.org/bugs/show_bug.cgi?id=27145

Ref: forked off of the discussion in D18513.

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

llvm-svn: 265675

8 years agoAdded a noexcept test
Marshall Clow [Thu, 7 Apr 2016 14:24:16 +0000 (14:24 +0000)]
Added a noexcept test

llvm-svn: 265674

8 years agoDon't create dynamic relocs for discarded .eh_frame entries.
Rafael Espindola [Thu, 7 Apr 2016 14:22:09 +0000 (14:22 +0000)]
Don't create dynamic relocs for discarded .eh_frame entries.

This requires knowing input section offsets in output sections before
scanRelocs. This is generally a good thing and should allow further
simplifications in the creation of dynamic relocations.

llvm-svn: 265673

8 years agoFix bug #27260 - add missing swap(reference, reference) to vector<bool>.
Marshall Clow [Thu, 7 Apr 2016 14:20:31 +0000 (14:20 +0000)]
Fix bug #27260 - add missing swap(reference, reference) to vector<bool>.

llvm-svn: 265672