Commit Graph

2924 Commits

Author SHA1 Message Date
Peter Collingbourne
b64e9f11ab Bitcode: Do not remove empty summary entries when reading a per-module summary.
This became no longer necessary after D19462 landed, and will be incompatible
with an upcoming change to the summary data structures that changes how we
represent references.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301660 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 17:41:43 +00:00
Andrew Ng
9d0dc96310 [DebugInfo][X86] Improve X86 Optimize LEAs handling of debug values.
This is a follow up to the fix in r298360 to improve the handling of debug
values when redundant LEAs are removed. The fix in r298360 effectively
discarded the debug values. This patch now attempts to preserve the debug
values by using the DWARF DW_OP_stack_value operation via prependDIExpr.

Moved functions appendOffset and prependDIExpr from Local.cpp to
DebugInfoMetadata.cpp and made them available as static member functions of
DIExpression.

Differential Revision: https://reviews.llvm.org/D31604

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301630 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-28 08:44:30 +00:00
Sanjoy Das
9f5bf2cd28 Use accessors for ValueHandleBase::V; NFC
This changes code that touches ValueHandleBase::V to go through
getValPtr and (newly added) setValPtr.  This functionality will be
used later, but also seemed like a generally good cleanup.

I also renamed the field to Val, but that's just to make it obvious
that I fixed all the uses.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301518 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 06:02:18 +00:00
Craig Topper
e5cb2e5840 [Metadata] Fix typos in comments. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301517 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-27 05:48:29 +00:00
Adrian Prantl
9d291ed9ad Turn DISubprogram into a variable-length node.
DISubprogram currently has 10 pointer operands, several of which are
often nullptr. This patch reduces the amount of memory allocated by
DISubprogram by rearranging the operands such that containing type,
template params, and thrown types come last, and are only allocated
when they are non-null (or followed by non-null operands).

This patch also eliminates the entirely unused DisplayName operand.

This saves up to 4 pointer operands per DISubprogram. (I tried
measuring the effect on peak memory usage on an LTO link of an X86
llc, but the results were very noisy).

This reapplies r301498 with an attempted workaround for g++.

Differential Revision: https://reviews.llvm.org/D32560

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301501 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 23:59:52 +00:00
Adrian Prantl
589155c2d7 Revert "Turn DISubprogram into a variable-length node."
This reverts commit r301498 while investigating bot breakage.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301499 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 23:49:30 +00:00
Adrian Prantl
6c938e5225 Turn DISubprogram into a variable-length node.
DISubprogram currently has 10 pointer operands, several of which are
often nullptr. This patch reduces the amount of memory allocated by
DISubprogram by rearranging the operands such that containing type,
template params, and thrown types come last, and are only allocated
when they are non-null (or followed by non-null operands).

This patch also eliminates the entirely unused DisplayName operand.

This saves up to 4 pointer operands per DISubprogram. (I tried
measuring the effect on peak memory usage on an LTO link of an X86
llc, but the results were very noisy).

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301498 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 23:44:54 +00:00
Adrian Prantl
1bf6297ee8 Add support for DW_TAG_thrown_type.
For Swift we would like to be able to encode the error types that a
function may throw, so the debugger can display them alongside the
function's return value when finish-ing a function.

DWARF defines DW_TAG_thrown_type (intended to be used for C++ throw()
declarations) that is a perfect fit for this purpose. This patch wires
up support for DW_TAG_thrown_type in LLVM by adding a list of thrown
types to DISubprogram.

To offset the cost of the extra pointer, there is a follow-up patch
that turns DISubprogram into a variable-length node.

rdar://problem/29481673

Differential Revision: https://reviews.llvm.org/D32559

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301489 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 22:56:44 +00:00
Sanjoy Das
263da12ab2 Reverts commit r301424, r301425 and r301426
Commits were:

"Use WeakVH instead of WeakTrackingVH in AliasSetTracker's UnkownInsts"
"Add a new WeakVH value handle; NFC"
"Rename WeakVH to WeakTrackingVH; NFC"

The changes assumed pointers are 8 byte aligned on all architectures.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301429 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 16:37:05 +00:00
Sanjoy Das
147a8edb1b Add a new WeakVH value handle; NFC
Summary:
WeakVH nulls itself out if the value it was tracking gets deleted, but
it does not track RAUW.

Reviewers: dblaikie, davide

Subscribers: mcrosier, llvm-commits

Differential Revision: https://reviews.llvm.org/D32267

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301425 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 16:20:59 +00:00
Sanjoy Das
d0cf26e443 Rename WeakVH to WeakTrackingVH; NFC
Summary:
I plan to use WeakVH to mean "nulls itself out on deletion, but does
not track RAUW" in a subsequent commit.

Reviewers: dblaikie, davide

Reviewed By: davide

Subscribers: arsenm, mehdi_amini, mcrosier, mzolotukhin, jfb, llvm-commits, nhaehnle

Differential Revision: https://reviews.llvm.org/D32266

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301424 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 16:20:52 +00:00
Vedant Kumar
4bfa64aac5 [gcov] Sort file info before printing it
The order in which GCOV file info is printed depends on the string hash
function. This makes some GCOV tests brittle, because the tests must be
updated whenever the hash function changes.

Sort the filenames before printing out the file info to solve the
problem. This should be relatively cheap.

Differential Revision: https://reviews.llvm.org/D32512

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301371 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-26 00:16:10 +00:00
Reid Kleckner
d2cbf1a6a4 Make getSlotAttributes return an AttributeSet instead of a wrapper list
Remove the temporary, poorly named getSlotSet method which did the same
thing. Also remove getSlotNode, which is a hold-over from when we were
dealing with AttributeSetNode* instead of AttributeSet.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301267 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-24 22:25:02 +00:00
Reid Kleckner
b680aedb53 [Bitcode] Refactor attribute group writing to avoid getSlotAttributes
Summary:
That API creates a temporary AttributeList to carry an index and a
single AttributeSet. We need to carry the index in addition to the set,
because that is how attribute groups are currently encoded.

NFC

Reviewers: pcc

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D32262

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301245 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-24 20:38:30 +00:00
Piotr Padlewski
698667025a Handle invariant.group.barrier in BasicAA
Summary:
llvm.invariant.group.barrier returns pointer that mustalias
pointer it takes. It can't be marked with `returned` attribute,
because it would be remove easily. The other reason is that
only Alias Analysis can know about this, because if any other
pass would know it, then the result would be replaced with it's
argument, which would be invalid.

We can think about returned pointer as something that mustalias, but
it doesn't have to be bitwise the same as the argument.

Reviewers: dberlin, chandlerc, hfinkel, sanjoy

Subscribers: reames, nlewycky, rsmith, anna, amharc

Differential Revision: https://reviews.llvm.org/D31585

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@301227 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-24 19:37:17 +00:00
Serguei Katkov
9bb6c3a55b [AsmWriter] Eliminate warning. NFC
This patch eliminates the following warning

lib/IR/AsmWriter.cpp:1128:57: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
                 (StrVal[1] >= '0' && StrVal[1] <= '9')) &&

Reviewers: timshen, rnk, davide
Reviewed By: davide
Subscribers: davide, llvm-commits
Differential Revision: https://reviews.llvm.org/D32337


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300950 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-21 06:14:38 +00:00
Serguei Katkov
c849a0cc07 [AsmWriter/APFloat] FP constant printing: Avoid usage of locale dependent snprinf
This should fix the bug https://bugs.llvm.org/show_bug.cgi?id=12906

To print the FP constant AsmWriter does the following:

  1) convert FP value to String (actually using snprintf function which is locale dependent).
  2) Convert String back to FP Value
  3) Compare original and got FP values. If they are not equal just dump as hex.

The problem happens on the 2nd step when APFloat does not expect group delimiter or
fraction delimiter other than period symbol and so on, which can be produced on the
first step if LLVM library is used in an environment with corresponding locale set.

To fix this issue the locale independent APFloat:toString function is used.
However it prints FP values slightly differently than snprintf does. Specifically
it suppress trailing zeros in significant, use capital E and so on.
It results in 117 test failures during make check.
To avoid this I've also updated APFloat.toString a bit to pass make check at least.

Reviewers: sberg, bogner, majnemer, sanjoy, timshen, rnk

Reviewed By: timshen, rnk

Subscribers: rnk, llvm-commits

Differential Revision: https://reviews.llvm.org/D32276


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300943 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-21 02:52:17 +00:00
Reid Kleckner
4d00a6147f Remove duplicate AttributeList::removeAttributes implementation
Have the AttributeList overload delegate to the AttrBuilder one.
Simplify the AttrBuilder overload by avoiding getSlotAttributes, which
creates temporary AttributeLists.

Simplify `AttrBuilder::removeAttributes(AttributeList, unsigned)` by
using getAttributes instead of manually iterating over slots.

Extracted from https://reviews.llvm.org/D32262

NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300863 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-20 18:08:36 +00:00
Reid Kleckner
d6b4b10a39 Prefer addAttr(Attribute::AttrKind) over the AttributeList overload
This should simplify the call sites, which typically want to tweak one
attribute at a time. It should also avoid creating ephemeral
AttributeLists that live forever.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300718 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-19 17:28:52 +00:00
Sanjay Patel
af30bb9796 use 'auto' with 'dyn_cast' and fix formatting; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300713 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-19 16:22:19 +00:00
Reid Kleckner
4bc9eb623d Remove buggy 'addAttributes(unsigned, AttrBuilder)' overload
The 'addAttributes(unsigned, AttrBuilder)' overload delegated to 'get'
instead of 'addAttributes'.

Since we can implicitly construct an AttrBuilder from an AttributeSet,
just standardize on AttrBuilder.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300651 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-19 01:51:13 +00:00
Craig Topper
fb21a1a779 [DataLayout] Removed default value from a variable that isn't used without being overwritten. Make variable an enum instead of an int to avoid a cast later. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300634 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-19 00:31:38 +00:00
Craig Topper
19d17b65bd [ConstantRange] Optimize APInt creation in getSignedMax/getSignedMin.
We were creating an APInt at the top of these methods that isn't always returned. For ranges wider than 64-bits this results in an allocation and deallocation when its not used.

In getSignedMax we were creating Upper-1 to use in a compare and then creating it again for a return value. The compiler is unable to determine that these can be shared. So help it out and create the Upper-1 in a temporary that can be reused.

This provides a little compile time improvement.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300621 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-18 23:02:39 +00:00
Reid Kleckner
129271c86a Fix crash in AttributeList::addAttributes, add test
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300614 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-18 22:10:18 +00:00
Craig Topper
df22034939 [APInt] Use lshrInPlace to replace lshr where possible
This patch uses lshrInPlace to replace code where the object that lshr is called on is being overwritten with the result.

This adds an lshrInPlace(const APInt &) version as well.

Differential Revision: https://reviews.llvm.org/D32155




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300566 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-18 17:14:21 +00:00
Sanjay Patel
ddb79e619d [ConstantRange] fix doxygen comment formatting; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300554 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-18 14:27:24 +00:00
Craig Topper
7b19c164ad [IR] Implement DataLayout::getPointerTypeSizeInBits using getPointerSizeInBits directly
Currently we use getTypeSizeInBits which contains a switch statement to dispatch based on what the Type is. We know we always have a pointer type here, but the compiler isn't able to figure out that out to remove the switch.

This patch changes it to just call handle the pointer type directly by calling getPointerSizeInBits without going through a switch.

getPointerTypeSizeInBits is called pretty often, particularly by getOrEnforceKnownAlignment which is used by InstCombine. This should speed that up a little bit.

Differential Revision: https://reviews.llvm.org/D31841



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300475 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-17 18:22:36 +00:00
Amaury Sechet
603e72e193 Introducing LLVMMetadataRef
Summary:
This seems like an uncontroversial first step toward providing access to the metadata hierarchy that now exists in LLVM. This should allow for good debug info support from C.

Future plans are to deprecate API that take mixed bags of values and metadata (mainly the LLVMMDNode family of functions) and migrate the rest toward the use of LLVMMetadataRef.

Once this is in place, mapping of DIBuilder will be able to start.

Reviewers: mehdi_amini, echristo, whitequark, jketema, Wallbraker

Reviewed By: Wallbraker

Subscribers: Eugene.Zelenko, axw, mehdi_amini, llvm-commits

Differential Revision: https://reviews.llvm.org/D19448

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300447 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-17 11:52:54 +00:00
Sanjay Patel
997ed308f7 [Constants] simplify get true/false code; NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300424 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-16 17:00:21 +00:00
Reid Kleckner
1f8f049069 [IR] Make paramHasAttr to use arg indices instead of attr indices
This avoids the confusing 'CS.paramHasAttr(ArgNo + 1, Foo)' pattern.

Previously we were testing return value attributes with index 0, so I
introduced hasReturnAttr() for that use case.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300367 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 20:19:02 +00:00
Simon Pilgrim
99a634fdf1 [X86][SSE] Update MOVNTDQA non-temporal loads to generic implementation (LLVM)
MOVNTDQA non-temporal aligned vector loads can be correctly represented using generic builtin loads, allowing us to remove the existing x86 intrinsics.

Clang companion patch: D31766.

Differential Revision: https://reviews.llvm.org/D31767

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300325 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 15:05:35 +00:00
Reid Kleckner
fefad770b8 Simplify some Verifier attribute checks with AttributeSet
Now that we have a type that can represent the attributes on a single
return, function, or parameter, we can pass it around directly rather
than passing around AttributeList and Idx. Removes some more one-based
argument attribute index counting.

NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300285 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-14 00:06:06 +00:00
Reid Kleckner
1c35defd74 [IR] Make getParamAttributes take argument numbers, not ArgNo+1
Add hasParamAttribute() and use it instead of hasAttribute(ArgNo+1,
Kind) everywhere.

The fact that the AttributeList index for an argument is ArgNo+1 should
be a hidden implementation detail.

NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300272 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-13 23:12:13 +00:00
Reid Kleckner
e9a46bf123 [IR] Take func, ret, and arg attrs separately in AttributeList::get
This seems like a much more natural API, based on Derek Schuff's
comments on r300015. It further hides the implementation detail of
AttributeList that function attributes come last and appear at index
~0U, which is easy for the user to screw up. git diff says it saves code
as well: 97 insertions(+), 137 deletions(-)

This also makes it easier to change the implementation, which I want to
do next.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300153 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-13 00:58:09 +00:00
Craig Topper
2d32ddf143 [IR] Remove the APIntMoveTy typedef from ConstantRange. Use APInt type directly.
This typedef used to be conditional based on whether rvalue references were supported. Looks like it got left behind when we switched to always having rvalue references with c++11. I don't think it provides any value now.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300146 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-13 00:20:31 +00:00
Konstantin Zhuravlyov
fae6220cbb Fix compiler error in Attributes.cpp
```
Compiling Attributes.cpp ...
../../../Attributes.cpp: In member function 'std::__1::pair<unsigned int, llvm::Optional<unsigned int> > llvm::AttributeSet::getAllocSizeArgs() const':
../../../Attributes.cpp:542:69: error: operands to ?: have different types 'std::__1::pair<unsigned int, llvm::Optional<unsigned int> >' and 'std::__1::pair<int, int>'
   return SetNode ? SetNode->getAllocSizeArgs() : std::make_pair(0, 0);
                                                                     ^
../../../Attributes.cpp:543:1: error: control reaches end of non-void function [-Werror=return-type]
 }
 ^
```

Differential Revision: https://reviews.llvm.org/D31981


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300143 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-12 23:57:37 +00:00
Reid Kleckner
7c6ef2a299 [IR] Assert that we never create an empty AttributeListImpl, NFC
Delete following conditional that is always true as a result.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300117 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-12 22:22:01 +00:00
Chandler Carruth
ddfada260a [IR] Redesign the case iterator in SwitchInst to actually be an iterator
and to expose a handle to represent the actual case rather than having
the iterator return a reference to itself.

All of this allows the iterator to be used with common STL facilities,
standard algorithms, etc.

Doing this exposed some missing facilities in the iterator facade that
I've fixed and required some work to the actual iterator to fully
support the necessary API.

Differential Revision: https://reviews.llvm.org/D31548

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300032 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-12 07:27:28 +00:00
Reid Kleckner
06090406b0 [IR] Add AttributeSet to hide AttributeSetNode* again, NFC
Summary:
For now, it just wraps AttributeSetNode*. Eventually, it will hold
AvailableAttrs as an inline bitset, and adding and removing enum
attributes will be super cheap.

This sinks AttributeSetNode back down to lib/IR/AttributeImpl.h.

Reviewers: pete, chandlerc

Subscribers: llvm-commits, jfb

Differential Revision: https://reviews.llvm.org/D31940

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300014 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-12 00:38:00 +00:00
Serge Guelton
9d54400bba Module::getOrInsertFunction is using C-style vararg instead of variadic templates.
From a user prospective, it forces the use of an annoying nullptr to mark the end of the vararg, and there's not type checking on the arguments.
The variadic template is an obvious solution to both issues.

Differential Revision: https://reviews.llvm.org/D31070



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299949 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-11 15:01:18 +00:00
Vassil Vassilev
afa9824a92 Remove unused functions. Remove static qualifier from functions in header files. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299947 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-11 14:55:32 +00:00
Keno Fischer
1a173576c9 [StripDeadDebug/DIFinder] Track inlined SPs
Summary:
In rL299692 I improved strip-dead-debug-info's ability to drop CUs that are not
referenced from the current module. However, in doing so I neglected to realize
that some SPs could be referenced entirely from inlined functions. It appears
I was not the only one to make this mistake, because DebugInfoFinder, doesn't
find those SPs either. Fix this in DebugInfoFinder and then use that to make
sure not to drop those CUs in strip-dead-debug-info.

Reviewers: aprantl

Reviewed By: aprantl

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D31904

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299936 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-11 13:32:11 +00:00
Diana Picus
1d02724c71 Revert "Turn some C-style vararg into variadic templates"
This reverts commit r299925 because it broke the buildbots. See e.g.
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/6008

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299928 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-11 10:07:12 +00:00
Serge Guelton
ec124b3a6f Turn some C-style vararg into variadic templates
Module::getOrInsertFunction is using C-style vararg instead of
variadic templates.

From a user prospective, it forces the use of an annoying nullptr
to mark the end of the vararg, and there's not type checking on the
arguments. The variadic template is an obvious solution to both
issues.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299925 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-11 08:36:52 +00:00
Craig Topper
cd0241d19a [IR] Fix a typo in a comment. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299918 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-11 06:41:55 +00:00
Reid Kleckner
a8ca30150c [IR] Sink some AttributeListImpl methods out of headers NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299906 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-11 00:16:00 +00:00
Reid Kleckner
e937c5e12f Remove AttributeSetNode::get(AttributeList, unsigned) and sink constructor
The getter was equivalent to AttributeList::getAttributes(unsigned),
which seems like a better way to express getting the AttributeSet for a
given index. This static helper was only used in one place anyway.

The constructor doesn't benefit from inlining and doesn't need to be in
a header.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299900 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-10 23:46:08 +00:00
Reid Kleckner
7dde8e89fc Reland "[IR] Make AttributeSetNode public, avoid temporary AttributeList copies"
This re-lands r299875.

I introduced a bug in Clang code responsible for replacing K&R, no
prototype declarations with a real function definition with a prototype.
The bug was here:

       // Collect any return attributes from the call.
  -    if (oldAttrs.hasAttributes(llvm::AttributeList::ReturnIndex))
  -      newAttrs.push_back(llvm::AttributeList::get(newFn->getContext(),
  -                                                  oldAttrs.getRetAttributes()));
  +    newAttrs.push_back(oldAttrs.getRetAttributes());

Previously getRetAttributes() carried AttributeList::ReturnIndex in its
AttributeList. Now that we return the AttributeSetNode* directly, it no
longer carries that index, and we call this overload with a single node:
  AttributeList::get(LLVMContext&, ArrayRef<AttributeSetNode*>)

That aborted with an assertion on x86_32 targets. I added an explicit
triple to the test and added CHECKs to help find issues like this in the
future sooner.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299899 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-10 23:31:05 +00:00
Matt Arsenault
e0b3c335a2 Allow DataLayout to specify addrspace for allocas.
LLVM makes several assumptions about address space 0. However,
alloca is presently constrained to always return this address space.
There's no real way to avoid using alloca, so without this
there is no way to opt out of these assumptions.

The problematic assumptions include:
- That the pointer size used for the stack is the same size as
  the code size pointer, which is also the maximum sized pointer.

- That 0 is an invalid, non-dereferencable pointer value.

These are problems for AMDGPU because alloca is used to
implement the private address space, which uses a 32-bit
index as the pointer value. Other pointers are 64-bit
and behave more like LLVM's notion of generic address
space. By changing the address space used for allocas,
we can change our generic pointer type to be LLVM's generic
pointer type which does have similar properties.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299888 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-10 22:27:50 +00:00
Reid Kleckner
d5d5d0b80e Revert "[IR] Make AttributeSetNode public, avoid temporary AttributeList copies"
This reverts r299875. A Linux bot came back with a test failure:
http://bb.pgr.jp/builders/test-clang-i686-linux-RA/builds/741/steps/test_clang/logs/Clang%20%3A%3A%20CodeGen__2006-05-19-SingleEltReturn.c

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299878 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-10 20:34:19 +00:00
Matt Arsenault
bdbe8280f2 Add address space mangling to lifetime intrinsics
In preparation for allowing allocas to have non-0 addrspace.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299876 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-10 20:18:21 +00:00
Reid Kleckner
a8b5a980c8 [IR] Make AttributeSetNode public, avoid temporary AttributeList copies
Summary:
AttributeList::get(Fn|Ret|Param)Attributes no longer creates a temporary
AttributeList just to hide the AttributeSetNode type.

I've also added a factory method to create AttributeLists from a
parallel array of AttributeSetNodes. I think this simplifies
construction of AttributeLists when rewriting function prototypes.
Previously we would test if a particular index had attributes, and
conditionally add a temporary attribute list to a vector. Now the
attribute set vector is parallel to the argument vector already that
these passes already construct.

My long term vision is to wrap AttributeSetNode* inside an AttributeSet
type that holds the enum attributes, but that will come in a follow up
change.

I haven't done any performance measurements for this change because
profiling hasn't shown that any of the affected code is hot.

Reviewers: pete, chandlerc, sanjoy, hfinkel

Reviewed By: pete

Subscribers: jfb, llvm-commits

Differential Revision: https://reviews.llvm.org/D31198

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299875 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-10 20:18:10 +00:00
Craig Topper
0a13ad6637 [IR] Inline Type::getScalarType() by using isVectorTy() and getVectorElementType() that were already available inline.
Seems to have very little compiled code size impact. But might give a tiny performance boost.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299811 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-08 05:47:09 +00:00
Mehdi Amini
8701bbc75d Revert "Turn some C-style vararg into variadic templates"
This reverts commit r299699, the examples needs to be updated.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299702 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-06 20:23:57 +00:00
Mehdi Amini
753bd2a772 Turn some C-style vararg into variadic templates
Module::getOrInsertFunction is using C-style vararg instead of
variadic templates.

From a user prospective, it forces the use of an annoying nullptr
to mark the end of the vararg, and there's not type checking on the
arguments. The variadic template is an obvious solution to both
issues.

Patch by: Serge Guelton <serge.guelton@telecom-bretagne.eu>

Differential Revision: https://reviews.llvm.org/D31070

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299699 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-06 20:09:31 +00:00
Matt Arsenault
dce3b51aea Verifier: Check some amdgpu calling convention restrictions
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299457 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-04 18:43:11 +00:00
Michael Zuckerman
3341db988b [X86][LLVM] Converting __mm{|256|512}_movm_epi{8|16|32|64} LLVMIR call into generic intrinsics.
This patch is a part one of two reviews, one for the clang and the other for LLVM. 
The patch deletes the back-end intrinsics and adds support for them in the auto upgrade.

Differential Revision: https://reviews.llvm.org/D31393


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299432 91177308-0d34-0410-b5e6-96231b3b80d8
2017-04-04 13:32:14 +00:00
Dehao Chen
22478be44e Fix the InstCombine to reserve the VP metadata and sets correct call count.
Summary: Currently the VP metadata was dropped when InstCombine converts a call to direct call. This patch converts the VP metadata to branch_weights so that its hotness is recorded.

Reviewers: eraman, davidxl

Reviewed By: davidxl

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D31344

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299228 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-31 15:59:52 +00:00
Peter Collingbourne
8dc921e4a6 Move llvm::emitLinkerFlagsForGlobalCOFF() to Mangler.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299183 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-31 04:46:50 +00:00
Adrian Prantl
70eccef966 Teach stripNonLineTableDebugInfo() to remap DILocations in !llvm.loop nodes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@299107 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-30 20:10:56 +00:00
Adam Nemet
5c57c1108e [IR] Add AllowContract to FastMathFlags
-ffp-contract=fast does not currently work with LTO because it's passed as a
TargetOption to the backend rather than in the IR. This adds it to
FastMathFlags.

This is toward fixing PR25721

Differential Revision: https://reviews.llvm.org/D31164

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298939 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-28 20:11:52 +00:00
Craig Topper
306a7df3fb [IR] Implement pairs of non-const and const methods using the const version instead of the non-const version. NFCI
This removes a const_cast of the this pointer.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298831 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-27 05:47:03 +00:00
Craig Topper
4f2f5a394a [IR] Share implementation for pairs of const and non-const methods using const_cast. NFCI
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298830 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-27 05:46:58 +00:00
Craig Topper
170b761d4e [IR] Share implementation of pairs of const and non-const methods in BasicBlock using the const version instead of the non-const version
Summary:
During post-commit review of a previous change I made it was pointed out that const casting 'this' is technically a bad practice. This patch re-implements all of the methods in BasicBlock that do this to use the const BasicBlock version and const_cast the return value instead.

I think there are still many other classes that do similar things. I may look at more in the future.

Reviewers: dblaikie

Reviewed By: dblaikie

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D31377

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298827 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-27 02:38:17 +00:00
Craig Topper
8a88c23612 [IR] Make Instruction::isAssociative method inline. Add LLVM_READONLY to the static version.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298826 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-26 23:23:29 +00:00
Chandler Carruth
627e0f9985 [IR] Make SwitchInst::CaseIt almost a normal iterator.
This moves it to the iterator facade utilities giving it full random
access semantics, etc. It can also now be used with standard algorithms
like std::all_of and std::any_of and range adaptors like llvm::reverse.

Also make the semantics of iterating match what every other iterator
uses and forbid decrementing past the begin iterator. This was used as
a hacky way to work around iterator invalidation. However, every
instance trying to do this failed to actually avoid touching invalid
iterators despite the clear documentation that the removed and all
subsequent iterators become invalid including the end iterator. So I've
added a return of the next iterator to removeCase and rewritten the
loops that were doing this to correctly follow the iterator pattern of
either incremneting or removing and assigning fresh values to the
iterator and the end.

In one case we were trying to go backwards to make this cleaner but it
doesn't actually work. I've made that code match the code we use
everywhere else to remove cases as we iterate. This changes the order of
cases in one test output and I moved that test to CHECK-DAG so it
wouldn't care -- the order isn't semantically meaningful anyways.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298791 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-26 02:49:23 +00:00
Dehao Chen
f62637a837 Set the prof weight correctly for call instructions in DeadArgumentElimination.
Summary: In DeadArgumentElimination, the call instructions will be replaced. We also need to set the prof weights so that function inlining can find the correct profile.

Reviewers: eraman

Reviewed By: eraman

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D31143

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298660 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-23 23:26:00 +00:00
Craig Topper
ba5e420976 [IR] Use a binary search in DataLayout::getAlignmentInfo
Summary:
We currently do a linear scan through all of the Alignments array entries anytime getAlignmentInfo is called. I noticed while profiling compile time on a -O2 opt run that this function can be called quite frequently and was showing about as about 1% of the time in callgrind.

This patch puts the Alignments array into a sorted order by type and then by bitwidth. We can then do a binary search. And use the sorted nature to handle the special cases for INTEGER_ALIGN. Some of this is modeled after the sorting/searching we do for pointers already.

This reduced the time spent in this routine by about 2/3 in the one compilation I was looking at.

We could maybe improve this more by using a DenseMap to cache the results, but just sorting was easy and didn't require extra data structure. And I think it made the integer handling simpler.

Reviewers: sanjoy, davide, majnemer, resistor, arsenm, mehdi_amini

Reviewed By: arsenm

Subscribers: arsenm, llvm-commits

Differential Revision: https://reviews.llvm.org/D31232

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298579 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-23 06:15:56 +00:00
Craig Topper
a28580d8ef [IR] Remove validAlignment and validPointer methods DataLayout as they aren't used.
I don't think validAlignment has been used since r34358 in 2007. I think validPointer was copied from validAlignment some time later, but it definitely wasn't used in the first commit that contained it.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298458 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-21 23:04:23 +00:00
George Burgess IV
3479ed63a6 Let llvm.objectsize be conservative with null pointers
This adds a parameter to @llvm.objectsize that makes it return
conservative values if it's given null.

This fixes PR23277.

Differential Revision: https://reviews.llvm.org/D28494


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298430 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-21 20:08:59 +00:00
Reid Kleckner
6707770d48 Rename AttributeSet to AttributeList
Summary:
This class is a list of AttributeSetNodes corresponding the function
prototype of a call or function declaration. This class used to be
called ParamAttrListPtr, then AttrListPtr, then AttributeSet. It is
typically accessed by parameter and return value index, so
"AttributeList" seems like a more intuitive name.

Rename AttributeSetImpl to AttributeListImpl to follow suit.

It's useful to rename this class so that we can rename AttributeSetNode
to AttributeSet later. AttributeSet is the set of attributes that apply
to a single function, argument, or return value.

Reviewers: sanjoy, javed.absar, chandlerc, pete

Reviewed By: pete

Subscribers: pete, jholewinski, arsenm, dschuff, mehdi_amini, jfb, nhaehnle, sbc100, void, llvm-commits

Differential Revision: https://reviews.llvm.org/D31102

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298393 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-21 16:57:19 +00:00
Dehao Chen
c7322dafb1 Updates branch_weights annotation for call instructions during inlining.
Summary: Inliner should update the branch_weights annotation to scale it to proper value.

Reviewers: davidxl, eraman

Reviewed By: eraman

Subscribers: zzheng, llvm-commits

Differential Revision: https://reviews.llvm.org/D30767

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298270 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-20 16:40:44 +00:00
Craig Topper
09aeefe613 [IR] Move a few static functions in Instruction class inline.
They just check for certain opcodes and opcode enums are available in Instruction.h.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298237 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-20 06:40:39 +00:00
Michael Zolotukhin
63f2656869 [ConstantRange] Add setSizeSmallerThanOf method.
Summary:
ConstantRange class currently has a method getSetSize, which is mostly used to
compare set sizes of two constant ranges (there is only one spot where it's used
in a slightly different scenario). This patch introduces setSizeSmallerThanOf
method, which does such comparison in a more efficient way. In the original
method we have to extend our types to (BitWidth+1), which can result it using
slow case of APInt, extra memory allocations, etc.

The change is supposed to not change any functionality, but it slightly improves
compile time. Here is compile time improvements that I observed on CTMark:
* tramp3d-v4	-2.02%
* pairlocalalign	-1.82%
* lencod	-1.67%

Reviewers: sanjoy, atrick, pete

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D31104

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298236 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-20 06:33:07 +00:00
Craig Topper
21a749ea8f [IR] Remove some unneeded includes from Operator.h and fix cpp files that were transitively depending on it. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298235 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-20 05:08:41 +00:00
Craig Topper
b36778a76f [IR] Add missing copyright header.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298234 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-20 05:08:38 +00:00
Simon Pilgrim
33e1fb27fd Fix constant folding of fp2int to large integers
We make the assumption in most of our constant folding code that a fp2int will target an integer of 128-bits or less, calling the APFloat::convertToInteger with only uint64_t[2] of raw bits for the result.

Fuzz testing (PR24662) showed that we don't handle other cases at all, resulting in stack overflows and all sorts of crashes.

This patch uses the APSInt version of APFloat::convertToInteger instead to better handle such cases.

Differential Revision: https://reviews.llvm.org/D31074

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298226 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-19 16:50:25 +00:00
Teresa Johnson
ad346a2a0c Enable stripping of multiple DILocation on !llvm.loop metadata
Summary:
I found that stripDebugInfo was still leaving significant amounts of
debug info due to !llvm.loop that contained DILocation after stripping.
The support for stripping debug info on !llvm.loop added in r293377 only
removes a single DILocation. Enhance that to remove all DILocation from
!llvm.loop.

Reviewers: hfinkel, aprantl, dsanders

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D31117

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298213 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-19 13:54:57 +00:00
Nirav Dave
11fdc7845a Make library calls sensitive to regparm module flag (Fixes PR3997).
Reviewers: mkuper, rnk

Subscribers: mehdi_amini, jyknight, aemerson, llvm-commits, rengolin

Differential Revision: https://reviews.llvm.org/D27050

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298179 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-18 00:44:07 +00:00
Evgeniy Stepanov
df808fe215 Add !associated metadata.
This is an ELF-specific thing that adds SHF_LINK_ORDER to the global's section
pointing to the metadata argument's section. The effect of that is a reverse dependency
between sections for the linker GC.

!associated does not change the behavior of global-dce. The global
may also need to be added to llvm.compiler.used.

Since SHF_LINK_ORDER is per-section, !associated effectively enables
fdata-sections for the affected globals, the same as comdats do.

Differential Revision: https://reviews.llvm.org/D29104

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298157 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-17 22:17:24 +00:00
Reid Kleckner
2af0da9edd Store Arguments in a flat array instead of an iplist
This saves two pointers from Argument and eliminates some extra
allocations.

Arguments cannot be inserted or removed from a Function because that
would require changing its Type, which LLVM does not allow. Instead,
passes that change prototypes, like DeadArgElim, create a new Function
and copy over argument names and attributes. The primary benefit of
iplist is O(1) random insertion and removal. We just don't need that for
arguments, so don't use it.

Reviewed By: chandlerc

Subscribers: dlj, inglorion, llvm-commits

Differential Revision: https://reviews.llvm.org/D31058

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298105 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-17 17:16:39 +00:00
Reid Kleckner
3d207f385a Remove dead F parameter from Argument constructor
When Function creates its argument list, it does the ilist push_back
itself. No other caller passes in a parent function, so this is dead,
and it uses the soon-to-be-deleted getArgumentList accessor.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298009 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-16 22:58:56 +00:00
Reid Kleckner
36d60de9d6 Make Argument::getArgNo() constant time, not O(#args)
getArgNo is actually hot in LLVM, because its how we check for
attributes on arguments:
  bool Argument::hasNonNullAttr() const {
    if (!getType()->isPointerTy()) return false;
    if (getParent()->getAttributes().
          hasAttribute(getArgNo()+1, Attribute::NonNull))
      return true;

It actually shows up as the 23rd hottest leaf function in a 13s sample
of LTO of llc.

This grows Argument by four bytes, but I have another pending patch to
shrink it by removing its ilist_node base.

Reviewed By: chandlerc

Subscribers: inglorion, llvm-commits, mehdi_amini

Differential Revision: https://reviews.llvm.org/D31057

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298003 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-16 22:25:45 +00:00
Reid Kleckner
800f10438a [IR] Inline some Function accessors
I checked that all of these out-of-line methods previously compiled to
simple loads and bittests, so they are pretty good candidates for
inlining. In particular, arg_size() and arg_empty() are popular and are
just two loads, so they seem worth inlining.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297963 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-16 16:57:31 +00:00
Adrian Prantl
8c12617ac6 Revert "Debug Info: Add basic support for external types references."
This reverts commit r242302. External type refs of this form were
never used by any LLVM frontend so this is effectively dead code.
(They were introduced to support clang module debug info, but in the
end we came up with a better design that doesn't use this feature at
all.)

rdar://problem/25897929

Differential Revision: https://reviews.llvm.org/D30917

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297684 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-13 22:56:14 +00:00
Daniel Berlin
57bd1ea8eb Remove opt-bisect support for "cases" in favor of debug counters
Summary:
Ths "cases" support was not quite finished, is unused, and is really just debug counters.
(well, almost, debug counters are slightly more powerful, in that they can skip things at the start, too).
Note, opt-bisect itself could also be implemented as a wrapper around
debug counters, but not sure it's worth it ATM.

I'll shove it on a todo list if we think it is.

Reviewers: MatzeB, chandlerc

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D30856

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297542 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-11 01:41:03 +00:00
Yaron Keren
ea56368f3d Implement getPassName() for IR printing passes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297442 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-10 07:09:20 +00:00
Sanjay Patel
5cf1d925cc [ConstantFold] vector div/rem with any zero element in divisor is undef
Follow-up for:
https://reviews.llvm.org/D30665
https://reviews.llvm.org/rL297390


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297409 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-09 20:42:30 +00:00
Konstantin Zhuravlyov
2cee5cc825 [DebugInfo] Emit address space with DW_AT_address_class attribute for pointer and reference types
Differential Revision: https://reviews.llvm.org/D29670


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297320 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-08 23:55:44 +00:00
Javed Absar
9dd9f4f8b4 [ConstantFold] Fix defect in constant folding computation for GEP
When the array indexes are all determined by GVN to be constants,
a call is made to constant-folding to optimize/simplify the address
computation.

The constant-folding, however, makes a mistake in that it sometimes reads
back stale Idxs instead of NewIdxs, that it re-computed in previous iteration.
This leads to incorrect addresses coming out of constant-folding to GEP.
A test case is included. The error is only triggered when indexes have particular
patterns that the stale/new index updates interplay matters.

Reviewers: Daniel Berlin
Differential Revision: https://reviews.llvm.org/D30642



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297317 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-08 23:01:50 +00:00
Konstantin Zhuravlyov
df032da7f1 [DebugInfo] Make legal and emit DW_OP_swap and DW_OP_xderef
Differential Revision: https://reviews.llvm.org/D29672


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297247 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-08 00:28:57 +00:00
Adrian Prantl
e1768aea09 Rephrase condition for better readability. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297168 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-07 17:50:51 +00:00
Adrian Prantl
64945562e3 Relax the conflicting function arg verifier to allow for inlined debug
info in nodebug functions.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297161 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-07 17:28:54 +00:00
Adrian Prantl
80be6298d0 Verfier: Move the reset of DebugFnArgs closer to other similar operations.
NFC

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297160 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-07 17:28:49 +00:00
Adrian Prantl
441d8e70c1 Verifier: Change Assert to AssertDI.
This error can be recovered from by stripping debug info.
This is NFC for +asserts builds.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297072 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-06 21:05:14 +00:00
Daniel Berlin
ee517039d6 Keep attributes, calling convention, etc, when remangling intrinsic
Summary: Fix issue reported where intrinsic calling convention is dropped after r295253.

Reviewers: sanjoy

Subscribers: materi, llvm-commits

Differential Revision: https://reviews.llvm.org/D30422

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296563 91177308-0d34-0410-b5e6-96231b3b80d8
2017-03-01 01:49:13 +00:00
Adrian Prantl
56d0100cfa Teach the IR verifier to reject conflicting debug info for function arguments.
Conflicting debug info for function arguments causes hard-to-debug
assertions in the DWARF backend, so the Verifier should reject it.
For performance reasons this only checks function arguments from
non-inlined debug intrinsics for now.

rdar://problem/30520286

This reapplies r295749 after fixing PR32042.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296543 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-28 23:48:42 +00:00
Dehao Chen
e26c421c66 Add function importing info from samplepgo profile to the module summary.
Summary: For SamplePGO, the profile may contain cross-module inline stacks. As we need to make sure the profile annotation happens when all the hot inline stacks are expanded, we need to pass this info to the module importer so that it can import proper functions if necessary. This patch implemented this feature by emitting cross-module targets as part of function entry metadata. In the module-summary phase, the metadata is used to build call edges that points to functions need to be imported.

Reviewers: mehdi_amini, tejohnson

Reviewed By: tejohnson

Subscribers: davidxl, llvm-commits

Differential Revision: https://reviews.llvm.org/D30053

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296498 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-28 18:09:44 +00:00
David Bozier
3d50c64c92 [Stack Protection] Add diagnostic information for why stack protection was applied to a function
Stack Smash Protection is not completely free, so in hot code, the overhead it causes can cause performance issues. By adding diagnostic information for which functions have SSP and why, a user can quickly determine what they can do to stop SSP being applied to a specific hot function.

This change adds a remark that is reported by the stack protection code when an instruction or attribute is encountered that causes SSP to be applied.

Patch by: James Henderson

Differential Revision: https://reviews.llvm.org/D29023



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296483 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-28 16:02:37 +00:00
Matt Arsenault
f5567ad95f AMDGPU: Basic folds for fmed3 intrinsic
Constant fold, canonicalize constants to RHS,
reduce to minnum/maxnum when inputs are nan/undef.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296409 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-27 23:08:49 +00:00
Craig Topper
c908a7f8b4 [IR][X86] Fix llvm version number in comments in AutoUpgrade. Forgot the next release is 5.0 not 4.1
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296092 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-24 05:35:07 +00:00
Craig Topper
474a418aa7 [AVX-512] Remove lzcnt intrinsics and autoupgrade them to generic ctlz intrinsics with select.
Clang has been emitting cltz intrinsics for a while now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296091 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-24 05:35:04 +00:00
Adrian Prantl
d58d81ffa6 fix 80-column violation
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296045 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-23 23:54:29 +00:00
Sanjoy Das
9e36975287 [IR] Add a Instruction::dropPoisonGeneratingFlags helper
Summary:
The helper will be used in a later change.  This change itself is NFC
since the only user of this new function is its unit test.

Reviewers: majnemer, efriedma

Reviewed By: efriedma

Subscribers: efriedma, mcrosier, llvm-commits

Differential Revision: https://reviews.llvm.org/D30184

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296035 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-23 22:50:52 +00:00
Ahmed Bougacha
5487126153 [ORE] Use const CodeRegions in the remark diagnostics. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296008 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-23 19:17:34 +00:00
Adrian Prantl
84277628a6 Revert "Teach the IR verifier to reject conflicting debug info for function arguments."
This reverts commit r295749 while investigating PR32042.

It looks like this check uncovered a problem in the frontend that
needs to be fixed before the check can be enabled again.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@296005 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-23 19:13:48 +00:00
Craig Topper
59900325da [X86][IR] In AutoUpgrade, check explicitly for xop.vpcmov and xop.vpcmov.256 instead of anything starting with xop.vpcmov
There were some older intrinsics that only existed for less than a month in 2012 that still exist in some out of tree test files that start with this string, but aren't able to be handled by the current upgrade code and fire an assert. Now we'll go back to treating them as not intrinsics at all and just passing them through to output.

Fixes PR32041, sort of.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295930 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-23 03:22:14 +00:00
Justin Bogner
3d433ea2e3 OptDiag: Add const to some interfaces that don't modify anything. NFC
This needed a const_cast for the dominator tree recalculation in
OptimizationRemarkEmitter, but we do that all over the place already
and it's safe.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295812 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-22 07:38:17 +00:00
Sean Silva
0b39c0f14b Use const-ref in range-loop for to avoid copying pairs of std::string
No reason to create temporaries.

Differential Revision: https://reviews.llvm.org/D29871

Patch by sergio.martins!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295807 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-22 06:34:04 +00:00
Adrian Prantl
fb2cee97e4 Teach the IR verifier to reject conflicting debug info for function arguments.
Conflicting debug info for function arguments causes hard-to-debug
assertions in the DWARF backend, so the Verifier should reject it.
For performance reasons this only checks function arguments from
non-inlined debug intrinsics for now.

rdar://problem/30520286

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295749 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-21 19:03:15 +00:00
Davide Italiano
3abe103b2e [IR/Verifier] List the CU we weren't able to find in llvm.dbg.cu.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295678 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-20 22:51:42 +00:00
Craig Topper
58ee25f913 Recommit "[X86] Remove XOP VPCMOV intrinsics and autoupgrade them to native IR."
Clang has now been fixed to not use these intrinsics.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295571 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-18 21:50:58 +00:00
Craig Topper
b3d03a9308 Revert "[X86] Remove XOP VPCMOV intrinsics and autoupgrade them to native IR."
This reverts r295564. I missed that clang was still using the intrinsics despite our half implemented autoupgrade support.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295565 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-18 20:14:20 +00:00
Craig Topper
aa2f6f93a2 [X86] Remove XOP VPCMOV intrinsics and autoupgrade them to native IR.
It seems we were already upgrading 128-bit VPCMOV, but the intrinsic was still defined and being used in isel patterns. While I was here I also simplified the tablegen multiclasses.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295564 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-18 19:51:25 +00:00
Craig Topper
a6bf7e7433 [X86][IR] Simplify the XOP vpcmov autoupgrade code. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295563 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-18 19:51:19 +00:00
Craig Topper
fc7a041c9e [X86][IR] Merge together some very similar AutoUpgrade handling. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295562 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-18 19:51:14 +00:00
Craig Topper
47cf6aadec [AVX-512] Remove 128/256-bit masked fp max/min intrinsics. Upgrade them to legacy unmasked intrinsics and select instructions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295543 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-18 07:07:50 +00:00
Davide Italiano
8faf95ff17 [IR/Verifier] Don't visit DISubprograms more than needed.
Before this patch we happened to visit twice, one when scanning
MDNodes and the other one while visiting the function. Remove
the explicit call to visitDISubprogram there, so we don't emit
the same error twice in case the verifier fail and we save some
time when running it.
Thanks to Justin Bogner for the report and Adrian for the quick
review!

PR: 31995

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295537 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-18 03:02:44 +00:00
Justin Bogner
4be00b7013 OptDiag: Allow constructing DiagnosticLocation from DISubprograms
This avoids creating a DILocation just to represent a line number,
since creating Metadata is expensive. Creating a DiagnosticLocation
directly is much cheaper.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295531 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-18 02:00:27 +00:00
Justin Bogner
787e150ebe OptDiag: Decouple backend diagnostics from debug info metadata
This creates and uses a DiagnosticLocation type rather than using
DebugLoc for this purpose in the backend diagnostics. This is NFC for
now, but will allow us to create locations for diagnostics without
having to create new metadata nodes when we don't have a DILocation.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295519 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-18 00:42:23 +00:00
Justin Bogner
a39b1ce61f Verifier: Disallow a line number without a file in DISubprogram
A line number doesn't make much sense if you don't say where it's
from. Add a verifier check for this and update some tests that had
bogus debug info.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295516 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-17 23:57:42 +00:00
Justin Bogner
67d9e19554 OptDiag: Rename DiagnosticInfoWithDebugLoc to WithLocation. NFC
This generalizes the name in preparation for decoupling the concept
from DebugLoc.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295465 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-17 17:34:37 +00:00
Craig Topper
ff64e4651d [IR][X86] Simplify some AutoUpgrade code slightly. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295426 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-17 07:07:24 +00:00
Craig Topper
33dd89087d [IR][X86] Rename an AutoUpgrade helper function to more accurately match what intrinsics it handles. NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295425 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-17 07:07:21 +00:00
Craig Topper
aace5e8709 [IR][X86] Move X86 specific portions of UpgradeIntrinsicFunction1 to a couple helper functions. NFC
This enables some early outs to avoid repeatedly using IsX86 check to qualify. I hope to continue to improve this to shorten the lengths of some of the string comparisons.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295424 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-17 07:07:19 +00:00
Eugene Zelenko
b1df787d2c [IR] Fix some Clang-tidy modernize and Include What You Use warnings; other minor fixes (NFC).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295383 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-17 00:00:09 +00:00
Craig Topper
fdf5214704 [AVX-512] Remove masked packss/packus intrinsics and autoupgrade to unmasked intrinsics with select instructions. For 512-bit add new unmasked intrinsics.
The new 512-bit unmasked intrinsics will make it easy to handle these with the SSE/AVX intrinsics in InstCombine where we currently have a TODO.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295290 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-16 06:31:54 +00:00
Daniel Berlin
d17bca97a5 Implement intrinsic mangling for literal struct types.
Fixes PR 31921

Summary:
Predicateinfo requires an ugly workaround to try to avoid literal
struct types due to the intrinsic mangling not being implemented.
This workaround actually does not work in all cases (you can hit the
assert by bootstrapping with -print-predicateinfo), and can't be made
to work without DFS'ing the type (IE copying getMangledStr and using a
version that detects if it would crash).

Rather than do that, i just implemented the mangling.  It seems
simple, since they are unified structurally.

Looking at the overloaded-mangling testcase we have, it actually turns
out the gc intrinsics will *also* crash if you try to use a literal
struct.  Thus, the testcase added fails before this patch, and works
after, without needing to resort to predicateinfo.

Reviewers: chandlerc, davide

Subscribers: llvm-commits, sanjoy

Differential Revision: https://reviews.llvm.org/D29925

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295253 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-15 23:16:20 +00:00
Keno Fischer
b863b6b817 [GlobalObject] Fix setSection("")
Summary:
In rL291613, the section name was interned in LLVMContext. However,
this broke the ability to remove the section from a GlobalObject,
because it tried to intern empty strings, which is not allowed.
Fix that and add an appropriate regression test.

Reviewed By: rnk
Differential Revision: https://reviews.llvm.org/D29795

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295238 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-15 21:42:42 +00:00
Ahmed Bougacha
ffb0b39cd0 [OptDiag] Pass const Values/Types to Argument. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295228 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-15 20:38:28 +00:00
Sanjay Patel
dd591da2f0 fix documentation comments for Argument; NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295068 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-14 16:43:49 +00:00
Dehao Chen
d0b28d942d Encode duplication factor from loop vectorization and loop unrolling to discriminator.
Summary:
This patch starts the implementation as discuss in the following RFC: http://lists.llvm.org/pipermail/llvm-dev/2016-October/106532.html

When optimization duplicates code that will scale down the execution count of a basic block, we will record the duplication factor as part of discriminator so that the offline process tool can find the duplication factor and collect the accurate execution frequency of the corresponding source code. Two important optimization that fall into this category is loop vectorization and loop unroll. This patch records the duplication factor for these 2 optimizations.

The recording will be guarded by a flag encode-duplication-in-discriminators, which is off by default.

Reviewers: probinson, aprantl, davidxl, hfinkel, echristo

Reviewed By: hfinkel

Subscribers: mehdi_amini, anemet, mzolotukhin, llvm-commits

Differential Revision: https://reviews.llvm.org/D26420

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294782 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-10 21:09:07 +00:00
Peter Collingbourne
6db6348785 IR: Consider two DISubprograms to be odr-equal if they have the same template parameters.
In ValueMapper we create new operands for MDNodes and
rely on MDNode::replaceWithUniqued to create a new MDNode
with the specified operands. However this doesn't always
actually happen correctly for DISubprograms because when we
uniquify the new node, we only odr-compare it with existing nodes
(MDNodeSubsetEqualImpl<DISubprogram>::isDeclarationOfODRMember). Although
the TemplateParameters field can refer to a distinct DICompileUnit via
DITemplateTypeParameter::type -> DICompositeType::scope -> DISubprogram::unit,
it is not currently included in the odr comparison. As a result, we can end
up getting our original DISubprogram back, which means we will have a cloned
module referring to the DICompileUnit in the original module, which causes
a verification error.

The fix I implemented was to consider TemplateParameters to be one of the
odr-equal properties. But I'm a little uncomfortable with this. In general it
seems unsound to rely on distinct MDNodes never being reachable from nodes
which we only check odr-equality of. My only long term suggestion would be
to separate odr-uniquing from full uniquing.

Differential Revision: https://reviews.llvm.org/D29240

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@294240 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-06 21:23:03 +00:00
Adam Nemet
49e45b454f [LV] Also port failure remarks to new OptimizationRemarkEmitter API
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293866 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-02 05:41:51 +00:00
Dehao Chen
fe46230d58 Change debug-info-for-profiling from a TargetOption to a function attribute.
Summary: LTO requires the debug-info-for-profiling to be a function attribute.

Reviewers: echristo, mehdi_amini, dblaikie, probinson, aprantl

Reviewed By: mehdi_amini, dblaikie, aprantl

Subscribers: aprantl, probinson, ahatanak, llvm-commits, mehdi_amini

Differential Revision: https://reviews.llvm.org/D29203

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293833 91177308-0d34-0410-b5e6-96231b3b80d8
2017-02-01 22:45:09 +00:00
Sam McCall
ec19b49e1d Include LLVMDumpValue in release builds.
This part of the C API is still used in language bindings.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293460 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-30 05:40:52 +00:00
Matthias Braun
1a20e3f2d5 llvm-c: Keep LLVMDumpModule() even in release builds
While this probably should be considered a dump debugger utility, the C
API currently has no other ways to print a module to stderr for error
reporting purposes, so keep it even in release builds.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293436 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-29 17:52:03 +00:00
Daniel Sanders
0028bf5b31 stripDebugInfo() should remove DILocation's found in !llvm.loop metadata
Summary:
Patch by Michele Scandale
(with a small tweak to 'CHECK-NOT' the last DILocation in the test)

Subscribers: bogner, llvm-commits

Differential Revision: https://reviews.llvm.org/D27980

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293377 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-28 11:22:05 +00:00
Matthias Braun
88d207542b Cleanup dump() functions.
We had various variants of defining dump() functions in LLVM. Normalize
them (this should just consistently implement the things discussed in
http://lists.llvm.org/pipermail/cfe-dev/2014-January/034323.html

For reference:
- Public headers should just declare the dump() method but not use
  LLVM_DUMP_METHOD or #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- The definition of a dump method should look like this:
  #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
  LLVM_DUMP_METHOD void MyClass::dump() {
    // print stuff to dbgs()...
  }
  #endif

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293359 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-28 02:02:38 +00:00
Andrew Kaylor
e6f10d3481 Add intrinsics for constrained floating point operations
This commit introduces a set of experimental intrinsics intended to prevent
optimizations that make assumptions about the rounding mode and floating point
exception behavior.  These intrinsics will later be extended to specify
flush-to-zero behavior.  More work is also required to model instruction
dependencies in machine code and to generate these instructions from clang
(when required by pragmas and/or command line options that are not currently
supported).

Differential Revision: https://reviews.llvm.org/D27028



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293226 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-26 23:27:59 +00:00
Adam Nemet
19925fc03b New OptimizationRemarkEmitter pass for MIR
This allows MIR passes to emit optimization remarks with the same level
of functionality that is available to IR passes.

It also hooks up the greedy register allocator to report spills.  This
allows for interesting use cases like increasing interleaving on a loop
until spilling of registers is observed.

I still need to experiment whether reporting every spill scales but this
demonstrates for now that the functionality works from llc
using -pass-remarks*=<pass>.

Differential Revision: https://reviews.llvm.org/D29004

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293110 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-25 23:20:33 +00:00
Adam Nemet
2355a8bd5e [OptDiag] Split code region out of DiagnosticInfoOptimizationBase
Code region is the only part of this class that is IR-specific.  Code
region is moved down in the inheritance tree to a new derived class,
called DiagnosticInfoIROptimization.

All the existing remarks are derived from this new class now.

This allows the new MIR pass-remark classes to be derived from
DiagnosticInfoOptimizationBase.

Also because we keep the name DiagnosticInfoOptimizationBase, the clang
parts don't need any adjustment.

Differential Revision: https://reviews.llvm.org/D29003

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293109 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-25 23:20:25 +00:00
Chad Rosier
43cbae2946 Revert "Do not verify dominator tree if it has no roots"
This reverts commit r293033, per Danny's comment.  In short, we require
domtrees to have roots at all times.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293075 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-25 17:15:48 +00:00
Serge Pavlov
841259051a Do not verify dominator tree if it has no roots
If dominator tree has no roots, the pass that calculates it is
likely to be skipped. It occures, for instance, in the case of
entities with linkage available_externally. Do not run tree
verification in such case.

Differential Revision: https://reviews.llvm.org/D28767


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@293033 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-25 07:58:10 +00:00
Serge Pavlov
85a1ed1bce Make VerifyDomInfo and VerifyLoopInfo global variables
Verifications of dominator tree and loop info are expensive operations
so they are disabled by default. They can be enabled by command line
options -verify-dom-info and -verify-loop-info. These options however
enable checks only in files Dominators.cpp and LoopInfo.cpp. If some
transformation changes dominaror tree and/or loop info, it would be
convenient to place similar checks to the files implementing the
transformation.

This change makes corresponding flags global, so they can be used in
any file to optionally turn verification on.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292889 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-24 05:52:07 +00:00
Craig Topper
f931f143cb [IR] Use const_cast to reuse the const version of two BasicBlock methods that are duplicated for both const and non-const. NFC
Similar is already done for other methods in BasicBlock.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292753 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-22 06:53:04 +00:00
Justin Lebar
e5aefeb9b8 [NVPTX] Auto-upgrade some NVPTX intrinsics to LLVM target-generic code.
Summary:
Specifically, we upgrade llvm.nvvm.:

 * brev{32,64}
 * clz.{i,ll}
 * popc.{i,ll}
 * abs.{i,ll}
 * {min,max}.{i,ll,u,ull}
 * h2f

These either map directly to an existing LLVM target-generic
intrinsic or map to a simple LLVM target-generic idiom.

In all cases, we check that the code we generate is lowered to PTX as we
expect.

These builtins don't need to be backfilled in clang: They're not
accessible to user code from nvcc.

Reviewers: tra

Subscribers: majnemer, cfe-commits, llvm-commits, jholewinski

Differential Revision: https://reviews.llvm.org/D28793

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292694 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-21 01:00:32 +00:00
Serge Pavlov
69a1a20613 Reverted: Track validity of pass results
Commits r291882 and related r291887.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292062 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-15 10:23:18 +00:00
Chandler Carruth
10dd00ced5 [PM] Introduce an analysis set used to preserve all analyses over
a function's CFG when that CFG is unchanged.

This allows transformation passes to simply claim they preserve the CFG
and analysis passes to check for the CFG being preserved to remove the
fanout of all analyses being listed in all passes.

I've gone through and removed or cleaned up as many of the comments
reminding us to do this as I could.

Differential Revision: https://reviews.llvm.org/D28627

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@292054 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-15 06:32:49 +00:00
Craig Topper
6ffcfe02df [IR] Don't call assertModuleIsMaterialized in release builds
Summary:
To fix a release vs debug build linking error, r259695 made the body of assertModuleIsMaterialized empty if Value.cpp gets compiled in a release build. This way any code compiled as a debug build can still link against a release version of the function.

This patch takes this a step farther and removes all calls to it from Value.h in any code that includes it in a relase build.

This shrinks the opt binary on my macbook build by 17240 bytes.

Reviewers: rafael

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D28191

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@291883 91177308-0d34-0410-b5e6-96231b3b80d8
2017-01-13 06:26:18 +00:00