Commit Graph

2190 Commits

Author SHA1 Message Date
Duncan P. N. Exon Smith
41e362dd89 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265768 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 03:13:22 +00:00
Duncan P. N. Exon Smith
50c7f32d75 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265765 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 00:56:21 +00:00
Sanjoy Das
c9e3e3cbfd 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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265762 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 00:48:30 +00:00
Duncan P. N. Exon Smith
698c0a7097 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.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265759 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 00:33:44 +00:00
Davide Italiano
a63892db7c [IR/Verifier] Fix (yet another) crash.
We need to check that if we reference a retainedType from
DICompileUnit we're actually referencing a DICompositeType.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265752 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-08 00:01:32 +00:00
Davide Italiano
a2a5c796cb [IR/Verifier] Merge two ifs into one. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265688 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 15:55:28 +00:00
Dmitry Polukhin
ba4922356c [GCC] Attribute ifunc support in llvm
This patch add support for GCC attribute((ifunc("resolver"))) for
targets that use ELF as object file format. In general ifunc is a
special kind of function alias with type @gnu_indirect_function. Patch
for Clang http://reviews.llvm.org/D15524

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265667 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-07 12:32:19 +00:00
Peter Zotov
2a41371ff7 [llvm-c] Add LLVMGetValueKind.
Patch by Nicole Mazzuca <npmazzuca@gmail.com>.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265608 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 22:21:29 +00:00
JF Bastien
b36d1a86f1 NFC: make AtomicOrdering an enum class
Summary:
In the context of http://wg21.link/lwg2445 C++ uses the concept of
'stronger' ordering but doesn't define it properly. This should be fixed
in C++17 barring a small question that's still open.

The code currently plays fast and loose with the AtomicOrdering
enum. Using an enum class is one step towards tightening things. I later
also want to tighten related enums, such as clang's
AtomicOrderingKind (which should be shared with LLVM as a 'C++ ABI'
enum).

This change touches a few lines of code which can be improved later, I'd
like to keep it as NFC for now as it's already quite complex. I have
related changes for clang.

As a follow-up I'll add:
  bool operator<(AtomicOrdering, AtomicOrdering) = delete;
  bool operator>(AtomicOrdering, AtomicOrdering) = delete;
  bool operator<=(AtomicOrdering, AtomicOrdering) = delete;
  bool operator>=(AtomicOrdering, AtomicOrdering) = delete;
This is separate so that clang and LLVM changes don't need to be in sync.

Reviewers: jyknight, reames

Subscribers: jyknight, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265602 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 21:19:33 +00:00
Nicolai Haehnle
ea7a0c0467 AMDGPU: Add a shader calling convention
This makes it possible to distinguish between mesa shaders
and other kernels even in the presence of compute shaders.

Patch By: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265589 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 19:40:20 +00:00
Davide Italiano
fd0bc4ee66 [IRVerifier] Don't crash on invalid DIFile inside DISubprogram.
r265515, this time with the correct fix. file inside DISubprogram is not
mandatory.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265586 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 18:46:39 +00:00
Davide Italiano
eb6436d50f [IRVerifier] Prefer dyn_cast<> over isa<> + cast<>.
Thanks to Rafael for the suggestion!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265579 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 18:13:44 +00:00
Duncan P. N. Exon Smith
a15c0e9ce0 IR: Use DenseSet instead of DenseMap for ConstantUniqueMap; NFC
Use a DenseSet instead of a DenseMap for constants in LLVMContextImpl.
Last time I looked at this was some time before r223588, when
DenseSet<V> had no advantage over DenseMap<V,char>.  After r223588,
there's a 50% memory savings.

This is all mechanical.  There were little bits of missing API from
DenseSet so I added the trivial implementations:

  - iterator::operator++(int)
  - template <class LookupKeyT> insert_as(ValueTy, LookupKeyT)

There should be no functionality change, just reduced memory consumption
(this wasn't on a profile or anything; just a cleanup I stumbled on).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265577 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 17:56:08 +00:00
Duncan P. N. Exon Smith
9148a0a560 IR: Stop explicitly clearing the MDStringCache
The MDStringCache doesn't need to be explicitly cleared before
destruction.  The destructor handles it at least as efficiently.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265576 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 17:56:05 +00:00
Duncan P. N. Exon Smith
adb72b91cb IR: Move MDStrings to a BumpPtrAllocator
We never delete any MDString until the context is destroyed.  Might as
well throw them onto a BumpPtrAllocator.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265520 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 06:41:54 +00:00
Duncan P. N. Exon Smith
e49dfa7e9a IRMover: Steal arguments when moving functions, NFC
Instead of copying arguments from the source function to the
destination, steal them.  This has a few advantages.

  - The ValueMap doesn't need to be seeded with (or cleared of)
    Arguments.

  - Often the destination function won't have created any arguments yet,
    so this avoids malloc traffic.

  - Argument names don't need to be copied.

Because argument lists are lazy, this required a new
Function::stealArgumentListFrom helper.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265519 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 06:38:15 +00:00
Davide Italiano
f504f6f4f7 Revert "[IRVerifier] Don't crash on invalid DIFile inside DISubprogram."
This reverts commit r265515 as lots of tests need to be fixed before
this actually can go in.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265517 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 04:34:38 +00:00
Davide Italiano
ce42332d64 [IRVerifier] Don't crash on invalid DIFile inside DISubprogram.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265515 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 03:57:47 +00:00
Davide Italiano
d7975248c1 [IRVerifier] Avoid crashing on an invalid compile unit.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265514 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-06 03:07:58 +00:00
Manman Ren
1f7638e1cb Swift Calling Convention: add swiftcc.
Differential Revision: http://reviews.llvm.org/D17863


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265480 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 22:41:47 +00:00
Duncan P. N. Exon Smith
d7773c0d39 IR: Introduce ConstantAggregate, NFC
Add a common parent class for ConstantArray, ConstantVector, and
ConstantStruct called ConstantAggregate.  These are the aggregate
subclasses of Constant that take operands.

This is mainly a cleanup, adding common `isa` target and removing
duplicated code.  However, it also simplifies caching which constants
point transitively at `GlobalValue` (a possible future direction).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265466 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 21:10:45 +00:00
Duncan P. N. Exon Smith
ef94029809 IR: Add missing assertion for ConstantVector::ConstantVector
Use the same assertion as ConstantArray.  Vectors should have the right
number of elements.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265463 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 20:53:47 +00:00
Sanjay Patel
25f2ff181c fix documentation comments; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265434 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 18:23:30 +00:00
Peter Zotov
2b8aed70d6 [llvm-c] Expose LLVM{Get,Set}ModuleIdentifier
Patch by Nicole Mazzuca <npmazzuca@gmail.com>.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265394 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 13:56:59 +00:00
Haojian Wu
f0a7cfdba2 Add parentheses around && within || to avoid compiler warning message.
Summary: The assert code is introduced by r265370.

Reviewers: bkramer

Subscribers: tejohnson

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265383 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 09:07:47 +00:00
Dmitry Polukhin
51a06a2c66 [IFUNC] Use GlobalIndirectSymbol when aliases and ifuncs have something similar
Second part extracted from http://reviews.llvm.org/D15525

Use GlobalIndirectSymbol in all cases when aliases and ifuncs have
something in common.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265382 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 08:47:51 +00:00
Teresa Johnson
3890d33905 [ThinLTO] Refactor some common code into getGlobalValueInfo method (NFC)
Refactor common code that queries the ModuleSummaryIndex for a value's
GlobalValueInfo struct into getGlobalValueInfo helper methods, which
will also be used by D18763.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265370 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-05 00:40:16 +00:00
Teresa Johnson
218731256d Don't fold double constant to an integer if dest type not integral
Summary:
I encountered this issue when constant folding during inlining tried to
fold away a bitcast of a double to an x86_mmx, which is not an integral
type. The test case exposes the same issue with a smaller code snippet
during early CSE.

Subscribers: llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265367 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-04 23:50:46 +00:00
Reid Kleckner
3918651b89 Fix non-determinism in order of LLVM attributes
We were using array_pod_sort on an array of type 'Attribute', which
wraps a pointer to AttributeImpl. For the most part this didn't matter
because the printing code prints enum attributes in a defined order, but
integer attributes such as 'align' and 'dereferenceable' were not
ordered.

Furthermore, AttributeImpl::operator< was broken for integer attributes.
An integer attribute is a kind and an integer value, and both pieces
need to be compared.

By fixing the comparison operator, we can go back to std::sort, and
things look good now.  This should fix clang arm-swiftcall.c test
failures on Windows.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265361 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-04 23:06:05 +00:00
Amaury Sechet
45cace0d9a Style update in Core.h/Core.cpp . NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265353 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-04 22:00:25 +00:00
Duncan P. N. Exon Smith
0568c3d1ac IR: Lazily create ReplaceableMetadataImpl on MDNode
RAUW support on MDNode usually requires an extra allocation for
ReplaceableMetadataImpl.  This is only strictly necessary if there are
tracking references to the MDNode.  Make the construction of
ReplaceableMetadataImpl lazy, so that we don't get allocations if we
don't need them.

Since MDNode::isResolved now checks MDNode::isTemporary and
MDNode::NumUnresolved instead of whether a ReplaceableMetadataImpl is
allocated, the internal changes are intrusive (at various internal
checkpoints, isResolved now has a different answer).

However, there should be no real functionality change here; just
slightly lazier allocation behaviour.  The external semantics should be
identical.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265279 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-03 21:23:52 +00:00
Amaury Sechet
7527b8c02a Various style fix in Core.h/Core.cpp . NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265277 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-03 21:06:04 +00:00
Mehdi Amini
398341689b constify GlobalValue::getGUID() and GlobalValue::getGlobalIdentifier() (NFC)
From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265217 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-02 05:25:27 +00:00
Mehdi Amini
5f76ad9dd7 Create a typedef GlobalValue::GUID for uint64_t and RAUW (NFC)
Summary: This should make the code more readable, especially all the map declarations.

Reviewers: tejohnson

Subscribers: llvm-commits

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

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265215 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-02 05:07:53 +00:00
Mehdi Amini
b3cb9bc147 80 lines column after renaming "shouldDiscardValueNames" (NFC)
From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265212 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-02 03:59:58 +00:00
Mehdi Amini
64a77d0033 Rename Context::discardValueNames() to shouldDiscardValueNames() (NFC)
Suggested by Sean Silva.

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265211 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-02 03:46:17 +00:00
Manman Ren
4bda882517 Swift Calling Convention: add swifterror attribute.
A ``swifterror`` attribute can be applied to a function parameter or an
AllocaInst.

This commit does not include any target-specific change. The target-specific
optimization will come as a follow-up patch.

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


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265189 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 21:41:15 +00:00
Mehdi Amini
d2f4701e4a Add a module Hash in the bitcode and the combined index, implementing a kind of "build-id"
This is intended to be used for ThinLTO incremental build.

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

This is a recommit of r265095 after fixing the Windows issues.

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265111 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 05:33:11 +00:00
Mehdi Amini
1fc660ff51 Revert "Add support for computing SHA1 in LLVM"
This reverts commit r265096, r265095, and r265094.
Windows build is broken, and the validation does not pass.

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265102 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 03:03:21 +00:00
Mehdi Amini
515396cd38 Add a module Hash in the bitcode and the combined index, implementing a kind of "build-id"
This is intended to be used for ThinLTO incremental build.

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

From: Mehdi Amini <mehdi.amini@apple.com>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265095 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 01:30:06 +00:00
Akira Hatanaka
5fe8a3c994 [LoopVectorize] Don't unconditionally print vectorization diagnostics
when compiling with LTO.

r244523 a new class DiagnosticInfoOptimizationRemarkAnalysisAliasing for
optimization analysis remarks related to pointer aliasing without
guarding it in isDiagnosticEnabled in LLVMContext.cpp. This caused the
diagnostic message to be printed unconditionally when compiling with
LTO.

This commit cleans up isDiagnosticEnabled and makes sure all the
vectorization optimization remarks are guarded.

rdar://problem/25382153


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265084 91177308-0d34-0410-b5e6-96231b3b80d8
2016-04-01 00:34:39 +00:00
Adrian Prantl
39bb84a097 Move the DebugEmissionKind enum from DIBuilder into DICompileUnit.
This mostly cosmetic patch moves the DebugEmissionKind enum from DIBuilder
into DICompileUnit. DIBuilder is not the right place for this enum to live
in — a metadata consumer should not have to include DIBuilder.h.
I also added a Verifier check that checks that the emission kind of a
DICompileUnit is actually legal.

http://reviews.llvm.org/D18612
<rdar://problem/25427165>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265077 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-31 23:56:58 +00:00
Dmitry Polukhin
dc022bad27 [IFUNC] Introduce GlobalIndirectSymbol as a base class for alias and ifunc
This patch is a part of http://reviews.llvm.org/D15525

GlobalIndirectSymbol class contains common implementation for both
aliases and ifuncs. This patch should be NFC change that just prepare
common code for ifunc support.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@265016 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-31 14:16:21 +00:00
Sanjoy Das
de765686f8 Introduce a @llvm.experimental.guard intrinsic
Summary:
As discussed on llvm-dev[1].

This change adds the basic boilerplate code around having this intrinsic
in LLVM:

 - Changes in Intrinsics.td, and the IR Verifier
 - A lowering pass to lower @llvm.experimental.guard to normal
   control flow
 - Inliner support

[1]: http://lists.llvm.org/pipermail/llvm-dev/2016-February/095523.html

Reviewers: reames, atrick, chandlerc, rnk, JosephTremoulet, echristo

Subscribers: mcrosier, llvm-commits

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264976 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-31 00:18:46 +00:00
Teresa Johnson
d47ed92bc6 Use existing PrintEscapedString in AssemblyWriter
r264884 introduced a helper to escape the backslashes in the source file
path, but I since discovered an existing mechanism to escape strings.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264936 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-30 22:17:28 +00:00
Teresa Johnson
2dec5fc2c0 Restore "[ThinLTO] Serialize the Module SourceFileName to/from LLVM assembly"
This restores commit 264869, with a fix for windows bots to properly
escape '\' in the path when serializing out. Added test.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264884 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-30 18:15:08 +00:00
Teresa Johnson
e1eb43b8cf Revert "[ThinLTO] Serialize the Module SourceFileName to/from LLVM assembly"
This reverts commit r264869. I am seeing Windows bot failures due to the
"\" in the path being mishandled at some point (seems to be interpreted
wrongly at some point and llvm-as | llvm-dis is yielding some junk
characters). Need to investigate.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264871 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-30 15:16:04 +00:00
Teresa Johnson
a6e6ae2836 [ThinLTO] Serialize the Module SourceFileName to/from LLVM assembly
Summary:
This change serializes out and in the SourceFileName to LLVM assembly
so that it is preserved through "llvm-dis | llvm-as". This is
necessary to ensure that the global identifiers created for local values
in the module summary index are the same even if the bitcode is
streamed out and read back from LLVM assembly.

Serializing the summary itself to LLVM assembly is in progress.

Reviewers: joker.eph

Subscribers: llvm-commits, joker.eph

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264869 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-30 14:00:02 +00:00
Duncan P. N. Exon Smith
540e0f57f5 IR: Constify LLVMContext::discardValueNames, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264823 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-30 04:32:29 +00:00
Duncan P. N. Exon Smith
0ee5788656 IR: Add DbgInfoIntrinsic::getVariableLocation
Create a common accessor, DbgInfoIntrinsic::getVariableLocation, which
doesn't care about the type of debug info intrinsic.  Use this to
further unify the implementations of DbgDeclareInst::getAddress and
DbgValueInst::getValue.

Besides being a cleanup, I'm planning to use this to prepare DEBUG
output without having to branch on the concrete type.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@264767 91177308-0d34-0410-b5e6-96231b3b80d8
2016-03-29 18:56:03 +00:00