Commit Graph

275 Commits

Author SHA1 Message Date
Rafael Espindola
0549fc2448 Set comdats when lazily linking functions.
We were setting the comdat when functions were copied in the initial pass, but
not when they were linked only when we found out that they are needed.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215765 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-15 20:17:08 +00:00
Duncan P. N. Exon Smith
49135bb76c Don't upgrade global constructors when reading bitcode
An optional third field was added to `llvm.global_ctors` (and
`llvm.global_dtors`) in r209015.  Most of the code has been changed to
deal with both versions of the variables.  Users of the C API might
create either version, the helper functions in LLVM create the two-field
version, and clang now creates the three-field version.

However, the BitcodeReader was changed to always upgrade to the
three-field version.  This created an unnecessary inconsistency in the
IR before/after serializing to bitcode.

This commit resolves the inconsistency by making the third field truly
optional (and not upgrading in the bitcode reader).  Since `llvm-link`
was relying on this upgrade code, rather than deleting it I've moved it
into `ModuleLinker`, where it upgrades these arrays as necessary to
resolve inconsistencies between modules.

The ideal resolution would be to remove the 2-field version and make the
third field required.  I filed PR20506 to track that.

I changed `test/Bitcode/upgrade-global-ctors.ll` to a negative test and
duplicated the `llvm-link` check in `test/Linker/global_ctors.ll` to
check both upgrade directions.

Since I came across this as part of PR5680 (serializing use-list order),
I've also added the missing `verify-uselistorder` RUN line to
`test/Bitcode/metadata-2.ll`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215457 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-12 16:46:37 +00:00
Rafael Espindola
69ca26cc97 Fix use of uninitialized variable.
Fixes linking bitcode files that use the new style comdats for constructors
with ones that don't.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@215364 91177308-0d34-0410-b5e6-96231b3b80d8
2014-08-11 17:07:34 +00:00
Rafael Espindola
d57120551f Use "weak alias" instead of "alias weak"
Before this patch we had

@a = weak global ...
but
@b = alias weak ...

The patch changes aliases to look more like global variables.

Looking at some really old code suggests that the reason was that the old
bison based parser had a reduction for alias linkages and another one for
global variable linkages. Putting the alias first avoided the reduce/reduce
conflict.

The days of the old .ll parser are long gone. The new one parses just "linkage"
and a later check is responsible for deciding if a linkage is valid in a
given context.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214355 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-30 22:51:54 +00:00
Manman Ren
9cee201f6e Clean up testing cases.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214142 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-28 23:16:05 +00:00
Manman Ren
6514cc5cb5 Remove extra ; in testing case.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214137 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-28 22:46:46 +00:00
Manman Ren
807538b567 [Debug Info] add DISubroutineType and its creation takes DITypeArray.
DITypeArray is an array of DITypeRef, at its creation, we will create
DITypeRef (i.e use the identifier if the type node has an identifier).

This is the last patch to unique the type array of a subroutine type.

rdar://17628609


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@214132 91177308-0d34-0410-b5e6-96231b3b80d8
2014-07-28 22:24:06 +00:00
David Majnemer
c8a1169c93 IR: Add COMDATs to the IR
This new IR facility allows us to represent the object-file semantic of
a COMDAT group.

COMDATs allow us to tie together sections and make the inclusion of one
dependent on another. This is required to implement features like MS
ABI VFTables and optimizing away certain kinds of initialization in C++.

This functionality is only representable in COFF and ELF, Mach-O has no
similar mechanism.

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211920 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-27 18:19:56 +00:00
Rafael Espindola
6fd1b8ee48 Allow aliases to be unnamed_addr.
Alias with unnamed_addr were in a strange state. It is stored in GlobalValue,
the language reference talks about "unnamed_addr aliases" but the verifier
was rejecting them.

It seems natural to allow unnamed_addr in aliases:

* It is a property of how it is accessed, not of the data itself.
* It is perfectly possible to write code that depends on the address
of an alias.

This patch then makes unname_addr legal for aliases. One side effect is that
the syntax changes for a corner case: In globals, unnamed_addr is now printed
before the address space.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210302 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-06 01:20:28 +00:00
Rafael Espindola
2d21b25393 Allow alias to point to an arbitrary ConstantExpr.
This  patch changes GlobalAlias to point to an arbitrary ConstantExpr and it is
up to MC (or the system assembler) to decide if that expression is valid or not.

This reduces our ability to diagnose invalid uses and how early we can spot
them, but it also lets us do things like

@test5 = alias inttoptr(i32 sub (i32 ptrtoint (i32* @test2 to i32),
                                 i32 ptrtoint (i32* @bar to i32)) to i32*)

An important implication of this patch is that the notion of aliased global
doesn't exist any more. The alias has to encode the information needed to
access it in its metadata (linkage, visibility, type, etc).

Another consequence to notice is that getSection has to return a "const char *".
It could return a NullTerminatedStringRef if there was such a thing, but when
that was proposed the decision was to just uses "const char*" for that.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@210062 91177308-0d34-0410-b5e6-96231b3b80d8
2014-06-03 02:41:57 +00:00
David Blaikie
254d093f99 DebugInfo: Lazily construct subprogram definition DIEs.
A further step to correctly emitting concrete out of line definitions
preceeding inlined instances of the same program.

To do this, emission of subprograms must be delayed until required since
we don't know which (abstract only (if there's no out of line
definition), concrete only (if there are no inlined instances), or both)
DIEs are required at the start of the module.

To reduce the test churn in the following commit that actually fixes the
bug, this commit introduces the lazy DIE construction and cleans up test
cases that are impacted by the changes in the resulting DIE ordering.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209675 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-27 18:37:48 +00:00
David Blaikie
1288a3b8e6 DebugInfo: Generalize some tests to handle variations in attribute ordering.
In an effort to fix inlined debug info in situations where the out of
line definition of a function preceeds any inlined usage, the order in
which some attributes are added to subprogram DIEs may change. (in
essence, definition-necessary attributes like DW_AT_low_pc/high_pc will
be added immediately, but the names, types, and other features will be
delayed to module end where they may either be added to the subprogram
DIE or instead reference an abstract definition for those values)

These tests can be generalized to be resilient to this change. 5 or so
tests actually have to be incompatibly changed to cope with this
reordering and will go along with the change that affects the order.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209554 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-23 21:11:46 +00:00
Adrian Prantl
30e5830301 LTO: Add a testcase for linking modules with incompatible Debug Info
Versions.
rdar://problem/16926122

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209183 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-19 23:41:25 +00:00
Reid Kleckner
1ce3088669 Add comdat key field to llvm.global_ctors and llvm.global_dtors
This allows us to put dynamic initializers for weak data into the same
comdat group as the data being initialized.  This is necessary for MSVC
ABI compatibility.  Once we have comdats for guard variables, we can use
the combination to help GlobalOpt fire more often for weak data with
guarded initialization on other platforms.

Reviewers: nlewycky

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209015 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-16 20:39:27 +00:00
Rafael Espindola
27c076ae40 Fix most of PR10367.
This patch changes the design of GlobalAlias so that it doesn't take a
ConstantExpr anymore. It now points directly to a GlobalObject, but its type is
independent of the aliasee type.

To avoid changing all alias related tests in this patches, I kept the common
syntax

@foo = alias i32* @bar

to mean the same as now. The cases that used to use cast now use the more
general syntax

@foo = alias i16, i32* @bar.

Note that GlobalAlias now behaves a bit more like GlobalVariable. We
know that its type is always a pointer, so we omit the '*'.

For the bitcode, a nice surprise is that we were writing both identical types
already, so the format change is minimal. Auto upgrade is handled by looking
through the casts and no new fields are needed for now. New bitcode will
simply have different types for Alias and Aliasee.

One last interesting point in the patch is that replaceAllUsesWith becomes
smart enough to avoid putting a ConstantExpr in the aliasee. This seems better
than checking and updating every caller.

A followup patch will delete getAliasedGlobal now that it is redundant. Another
patch will add support for an explicit offset.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209007 91177308-0d34-0410-b5e6-96231b3b80d8
2014-05-16 19:35:39 +00:00
Rafael Espindola
1021014c7b Fix DataLayout::operator==().
Patch by Maks Naumov!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@206911 91177308-0d34-0410-b5e6-96231b3b80d8
2014-04-22 17:47:03 +00:00
Adrian Prantl
5e8144df32 Switch the type field in DIVariable and DIGlobalVariable over to DITypeRefs.
This allows us to catch more opportunities for ODR-based type uniquing
during LTO.
Paired commit with CFE which updates some testcases to verify the new
DIBuilder behavior.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204106 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-18 02:34:58 +00:00
Adrian Prantl
1d8c02bef3 Debug info: Unique types before emitting them to DWARF, where applicable.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203983 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-14 23:08:29 +00:00
Adrian Prantl
7e1a3830ca Debug Info: Fix LTO type uniquing for C++ member declarations
based on the ODR.

This adds an OdrMemberMap to DwarfDebug which is used to unique C++
member function declarations based on the unique identifier of their
containing class and their mangled name.
We can't use the usual DIRef mechanism here because DIScopes are indexed
using their entire MDNode, including decl_file and decl_line, which need
not be unique (see testcase).

Prior to this change multiple redundant member function declarations would
end up in the same uniqued DW_TAG_class_type.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203982 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-14 23:08:25 +00:00
Rafael Espindola
38048cdb1c Reject alias to undefined symbols in the verifier.
On ELF and COFF an alias is just another name for a position in the file.
There is no way to refer to a position in another file, so an alias to
undefined is meaningless.

MachO currently doesn't support aliases. The spec has a N_INDR, which when
implemented will have a different set of restrictions. Adding support for
it shouldn't be harder than any other IR extension.

For now, having the IR represent what is actually possible with current
tools makes it easier to fix the design of GlobalAlias.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203705 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-12 20:15:49 +00:00
Rafael Espindola
7e3e9aa8e1 Don't assume an empty stderr.
GuardMalloc can print info to stderr, causing these tests to fail.
Since FileCheck errors on empty inputs, just add a bit of dummy
data to make it happy.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203595 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-11 18:25:33 +00:00
JF Bastien
c869887dde Add test for LinkModules warning on triple, modified by r203009. Datalayout is already tested.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203468 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-10 15:54:49 +00:00
JF Bastien
51da5c7631 Fix datalayout test that I broke with my previous LinkModules warning improvement.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@203011 91177308-0d34-0410-b5e6-96231b3b80d8
2014-03-05 21:37:08 +00:00
Juergen Ributzka
4fb1463736 Revert "Use count 0."
This reverts commit r202283, because when we use GuardMalloc the test will fail
due to additional output to std err.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202341 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-27 03:10:10 +00:00
Rafael Espindola
a55b3dfdc6 Use count 0.
Thanks to Roman Divacky for the suggestion.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202283 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-26 17:57:35 +00:00
Rafael Espindola
c4bdb93d6a Compare DataLayout by Value, not by pointer.
This fixes spurious warnings in llvm-link about the datalayout not matching.

Thanks to Zalman Stern for reporting the bug!

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@202276 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-26 17:02:08 +00:00
Rafael Espindola
17c9169bbd Copy dll storage in copyAttributes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@201295 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-13 05:11:35 +00:00
David Blaikie
cec7ce78d7 DebugInfo: Remove some unneeded conditionals now that DIBuilder no longer emits zero-length arrays as {i32 0}
A bunch of test cases needed to be cleaned up for this, many my fault -
when implementid imported modules I updated test cases by simply
duplicating the prior metadata field - which wasn't always the empty
metadata entry.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200731 91177308-0d34-0410-b5e6-96231b3b80d8
2014-02-04 01:23:52 +00:00
Timur Iskhodzhanov
ab42578bdd Reland r200340 - 'Add line table debug info to COFF files when using a win32 triple'
This incorporates a couple of fixes reviewed at http://llvm-reviews.chandlerc.com/D2651

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200440 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-30 01:39:17 +00:00
Bill Wendling
d221469cc6 Verify that attributes are not lost during linking.
We don't want to lose attributes when a function decl without them is merged
with a function decl that has them.
PR2382

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200030 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-24 19:20:15 +00:00
Adrian Prantl
f9af5bdd63 Debug info (LTO): Move the creation of accessibility flags to
getOrCreateSubprogramDIE to avoid attributes being added twice when DIEs
are merged.

rdar://problem/15842330.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@199536 91177308-0d34-0410-b5e6-96231b3b80d8
2014-01-18 02:12:00 +00:00
Manman Ren
bec50063a5 Debug Info: update testing cases to specify the debug info version number.
We are going to drop debug info without a version number or with a different
version number, to make sure we don't crash when we see bitcode files with
different debug info metadata format.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195504 91177308-0d34-0410-b5e6-96231b3b80d8
2013-11-22 21:49:45 +00:00
Manman Ren
b8b70e10a2 Debug Info: remove duplication of DIEs when a DIE can be shared across CUs.
We add a map in DwarfDebug to map MDNodes that are shareable across CUs to the
corresponding DIEs: MDTypeNodeToDieMap. These DIEs can be shared across CUs,
that is why we keep the maps in DwarfDebug instead of CompileUnit.

We make the assumption that if a DIE is not added to an owner yet, we assume
it belongs to the current CU. Since DIEs for the type system are added to
their owners immediately after creation, and other DIEs belong to the current
CU, the assumption should be true.

A testing case is added to show that we only create a single DIE for a type
MDNode and we use ref_addr to refer to the type DIE.

We also add a testing case to show ref_addr relocations for non-darwin
platforms.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193779 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-31 17:54:35 +00:00
Manman Ren
c664d76716 Debug Info: In DIBuilder, the derived-from field of a DW_TAG_pointer_type
is updated to use DITypeRef.

Move isUnsignedDIType and getOriginalTypeSize from DebugInfo.h to be static
helper functions in DwarfCompileUnit. We already have a static helper function
"isTypeSigned" in DwarfCompileUnit, and a pointer to DwarfDebug is added to
resolve the derived-from field. All three functions need to go across link
for derived-from fields, so we need to get hold of a type identifier map.

A pointer to DwarfDebug is also added to DbgVariable in order to resolve the
derived-from field.

Debug info verifier is updated to check a derived-from field is a TypeRef.
Verifier will not go across link for derived-from fields, in debug info finder,
we go across the link to add derived-from fields to types.

Function getDICompositeType is only used by dragonegg and since dragonegg does
not generate identifier for types, we use an empty map to resolve the
derived-from field.

When printing a derived-from field, we use DITypeRef::getName to either return
the type identifier or getName of the DIType.

A paired commit at clang is required due to changes to DIBuilder.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@192018 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-05 01:43:03 +00:00
Eric Christopher
3f045005bf Temporarily revert r191792 as it is causing some LTO debug failures
on platforms with relocations in debug info and also temporarily
revert r191800 due to conflicts with the revert of r191792.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191967 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-04 17:08:38 +00:00
Manman Ren
2b53089bd0 Debug Info: In DIBuilder, the derived-from field of a DW_TAG_pointer_type
is updated to use DITypeRef.

Move isUnsignedDIType and getOriginalTypeSize from DebugInfo.h to be static
helper functions in DwarfCompileUnit. We already have a static helper function
"isTypeSigned" in DwarfCompileUnit, and a pointer to DwarfDebug is added to
resolve the derived-from field. All three functions need to go across link
for derived-from fields, so we need to get hold of a type identifier map.

A pointer to DwarfDebug is also added to DbgVariable in order to resolve the
derived-from field.

Debug info verifier is updated to check a derived-from field is a TypeRef.
Verifier will not go across link for derived-from fields, in debug info finder,
we go across the link to add derived-from fields to types.

Function getDICompositeType is only used by dragonegg and since dragonegg does
not generate identifier for types, we use an empty map to resolve the
derived-from field.

When printing a derived-from field, we use DITypeRef::getName to either return
the type identifier or getName of the DIType.

A paired commit at clang is required due to changes to DIBuilder.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191800 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-01 23:45:54 +00:00
Manman Ren
9432820caf Remove triple from type unique testing cases.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191794 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-01 20:27:56 +00:00
Manman Ren
a8758a793f Try to fix native-arm bot
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191793 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-01 20:23:12 +00:00
Manman Ren
620f436b20 Debug Info: remove duplication of DIEs when a DIE is part of the type system
and it is shared across CUs.

We add a few maps in DwarfDebug to map MDNodes for the type system to the
corresponding DIEs: MDTypeNodeToDieMap, MDSPNodeToDieMap, and
MDStaticMemberNodeToDieMap. These DIEs can be shared across CUs, that is why we
keep the maps in DwarfDebug instead of CompileUnit.

Sometimes, when we try to add an attribute to a DIE, the DIE is not yet added
to its owner yet, so we don't know whether we should use ref_addr or ref4.
We create a worklist that will be processed during finalization to add
attributes with the correct form (ref_addr or ref4).

We add addDIEEntry to DwarfDebug to be a wrapper around DIE->addValue. It checks
whether we know the correct form, if not, we update the worklist
(DIEEntryWorklist).

A testing case is added to show that we only create a single DIE for a type
MDNode and we use ref_addr to refer to the type DIE.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191792 91177308-0d34-0410-b5e6-96231b3b80d8
2013-10-01 19:52:23 +00:00
Peter Collingbourne
1e3037f0be Implement function prefix data as an IR feature.
Previous discussion:
http://lists.cs.uiuc.edu/pipermail/llvmdev/2013-July/063909.html

Differential Revision: http://llvm-reviews.chandlerc.com/D1191

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190773 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-16 01:08:15 +00:00
Manman Ren
d4fc36f264 Debug Info: In DIBuilder, the context fields of a TAG_inheritance and a
TAG_friend are updated to use scope reference.

Added testing cases to verify that class with inheritance can be uniqued.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190364 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-09 23:07:58 +00:00
Manman Ren
0b9ba182a7 Debug Info Testing: remove a commented out line.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190351 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-09 20:45:34 +00:00
Manman Ren
2c9905a1f3 Debug Info: Use DIScopeRef for DIType::getContext.
In DIBuilder, the context field of a TAG_member is updated to use the
scope reference. Verifier is updated accordingly.
    
DebugInfoFinder now needs to generate a type identifier map to have
access to the actual scope. Same applies for BreakpointPrinter.
    
processModule of DebugInfoFinder is called during initialization phase
of the verifier to make sure the type identifier map is constructed early
enough.
    
We are now able to unique a simple class as demonstrated by the added
testing case.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190334 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-09 19:47:11 +00:00
Manman Ren
1ed2e1fb92 Debug Info Testing: update context from empty string to null.
Context should be either null or MDNode.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190267 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-08 03:11:54 +00:00
Manman Ren
1307103dff Debug Info Testing: updated to use NULL instead of "i32 0" in a few fields.
Field 2 of DIType (Context), field 9 of DIDerivedType (TypeDerivedFrom),
field 12 of DICompositeType (ContainingType), fields 2, 7, 12 of DISubprogram
(Context, Type, ContainingType).


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@190205 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-06 21:03:58 +00:00
Rafael Espindola
9127334dad Error on linking appending globals with different unnamed_addr.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189950 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-04 15:33:34 +00:00
Rafael Espindola
6947f10ec4 Fix linking of unnamed_addr in functions.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189945 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-04 14:59:03 +00:00
Rafael Espindola
254f75095b Rename in preparation for adding tests for function linking.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189944 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-04 14:40:49 +00:00
Rafael Espindola
2396be0c6e Use CHECK-DAG instead of sort.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189942 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-04 14:35:48 +00:00
Rafael Espindola
3acfb58b17 Fix linking of unnamed_addr.
This was regression from r134829. When linking we have to be conservative. If
one of the symbols has a significant address, then the result should have it
too.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189935 91177308-0d34-0410-b5e6-96231b3b80d8
2013-09-04 14:05:09 +00:00
Daniel Dunbar
b1975a807d [tests] Use multiple statements instead of 'echo -e', which is not part of BSD echo.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189560 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-29 03:02:30 +00:00
Manman Ren
6e3cd0ebe2 Debug Info: add an identifier field to DICompositeType.
DICompositeType will have an identifier field at position 14. For now, the
field is set to null in DIBuilder.
For DICompositeTypes where the template argument field (the 13th field)
was optional, modify DIBuilder to make sure the template argument field is set.
Now DICompositeType has 15 fields.

Update DIBuilder to use NULL instead of "i32 0" for null value of a MDNode.
Update verifier to check that DICompositeType has 15 fields and the last
field is null or a MDString.

Update testing cases to include an extra field for DICompositeType.
The identifier field will be used by type uniquing so a front end can
genearte a DICompositeType with a unique identifer.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@189282 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-26 22:39:55 +00:00
Daniel Dunbar
24ec2e5a72 [tests] Cleanup initialization of test suffixes.
- Instead of setting the suffixes in a bunch of places, just set one master
   list in the top-level config. We now only modify the suffix list in a few
   suites that have one particular unique suffix (.ml, .mc, .yaml, .td, .py).

 - Aside from removing the need for a bunch of lit.local.cfg files, this enables
   4 tests that were inadvertently being skipped (one in
   Transforms/BranchFolding, a .s file each in DebugInfo/AArch64 and
   CodeGen/PowerPC, and one in CodeGen/SI which is now failing and has been
   XFAILED).

 - This commit also fixes a bunch of config files to use config.root instead of
   older copy-pasted code.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188513 91177308-0d34-0410-b5e6-96231b3b80d8
2013-08-16 00:37:11 +00:00
Manman Ren
ce0a12399c Debug Info Verifier: enable verification of DICompileUnit.
We used to call Verify before adding DICompileUnit to the list, and now we
remove the check and always add DICompileUnit to the list in DebugInfoFinder,
so we can verify them later on.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187237 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-26 20:04:30 +00:00
Manman Ren
cb420a4bc0 Debug Info: improve the verifier to check field types.
Make sure the context field of DIType is MDNode.
Fix testing cases to make them pass the verifier.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187150 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-25 19:33:30 +00:00
Manman Ren
a280a839f5 Update testing cases to pass debug info verifier.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187083 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-24 22:23:00 +00:00
Manman Ren
7894ffd006 Debug Info: improve the Finder.
Improve the Finder to handle context of a DIVariable.
If Scope is a DICompileUnit, add it to the list of CUs.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@187003 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-23 23:10:00 +00:00
Manman Ren
0e29eeec27 Debug Info Finder: use processDeclare and processValue to list debug info
MDNodes used by DbgDeclareInst and DbgValueInst.

Another 16 testing cases failed and they are disabled with
-disable-debug-info-verifier.
A total of 34 cases are disabled with -disable-debug-info-verifier and will be
corrected.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@186902 91177308-0d34-0410-b5e6-96231b3b80d8
2013-07-23 00:22:51 +00:00
James Molloy
a84a83bbcd Extend RemapInstruction and friends to take an optional new parameter, a ValueMaterializer.
Extend LinkModules to pass a ValueMaterializer to RemapInstruction and friends to lazily create Functions for lazily linked globals. This is a big win when linking small modules with large (mostly unused) library modules.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@182776 91177308-0d34-0410-b5e6-96231b3b80d8
2013-05-28 15:17:05 +00:00
Eli Bendersky
d7170ea5a8 Rewrite test/Linker tests to use FileCheck instead of grep.
Some translations here are not 1x1 because there are grep|grep
chains that are non-trivial to implement in terms of FileCheck features. I
made an effort for the tests to remain as similar as possible; do let me know
if you notice anything fishy. The good news are that some buggy tests were
fixed (grep | not grep - a bug waiting to happen).



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179102 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-09 16:51:13 +00:00
Manman Ren
16d1a6bf08 Linker: correctly link in dbg.declare
This is a re-worked version of r174048.
Given source IR:
call void @llvm.dbg.declare(metadata !{i32* %argc.addr}, metadata !14), !dbg !15
we used to generate 
call void @llvm.dbg.declare(metadata !27, metadata !28), !dbg !29
!27 = metadata !{null}

With this patch, we will correctly generate
call void @llvm.dbg.declare(metadata !{i32* %argc.addr}, metadata !27), !dbg !28

Looking up %argc.addr in ValueMap will return null, since %argc.addr is already
correctly set up, we can use identity mapping.

rdar://problem/13089880


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174093 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-31 21:19:18 +00:00
Alexey Samsonov
e22df330a3 Revert r173946. This breaks compilation of googletest with Clang
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174048 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-31 08:02:11 +00:00
Manman Ren
1229c0cb10 Linker: correctly link in dbg.declare
Given source IR:
call void @llvm.dbg.declare(metadata !{i32* %argc.addr}, metadata !14), !dbg !15
we used to generate 
call void @llvm.dbg.declare(metadata !27, metadata !28), !dbg !29
!27 = metadata !{null}

With this patch, we will correctly generate
call void @llvm.dbg.declare(metadata !{i32* %argc.addr}, metadata !27), !dbg !28

Looking up %argc.addr in ValueMap will return null, since %argc.addr is already
correctly set up, we can use identity mapping.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@173946 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-30 17:42:15 +00:00
Daniel Dunbar
5db391c67d [IR] Add 'Append' and 'AppendUnique' module flag behaviors.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172659 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-16 21:38:56 +00:00
Daniel Dunbar
1e08165ae9 [Linker] Change module flag linking to be more extensible.
- Instead of computing a bunch of buckets of different flag types, just do an
   incremental link resolving conflicts as they arise.

 - This also has the advantage of making the link result deterministic and not
   dependent on map iteration order.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172634 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-16 18:39:23 +00:00
Joey Gouly
2b8f6ae6b7 Fix a copy/paste error in the IR Linker, casting an ArrayType instead of a VectorType.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@172054 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-10 10:49:36 +00:00
Bill Wendling
efd08d413c Remove the dependent libraries feature.
The dependent libraries feature was never used and has bit-rotted. Remove it.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@168694 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-27 09:55:56 +00:00
Chandler Carruth
49589f0d0e Convert the uses of '|&' to use '2>&1 |' instead, which works on old
versions of Bash. In addition, I can back out the change to the lit
built-in shell test runner to support this.

This should fix the majority of fallout on Darwin, but I suspect there
will be a few straggling issues.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159544 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-02 18:37:59 +00:00
Chandler Carruth
4177e6fff5 Convert all tests using TCL-style quoting to use shell-style quoting.
This was done through the aid of a terrible Perl creation. I will not
paste any of the horrors here. Suffice to say, it require multiple
staged rounds of replacements, state carried between, and a few
nested-construct-parsing hacks that I'm not proud of. It happens, by
luck, to be able to deal with all the TCL-quoting patterns in evidence
in the LLVM test suite.

If anyone is maintaining large out-of-tree test trees, feel free to poke
me and I'll send you the steps I used to convert things, as well as
answer any painful questions etc. IRC works best for this type of thing
I find.

Once converted, switch the LLVM lit config to use ShTests the same as
Clang. In addition to being able to delete large amounts of Python code
from 'lit', this will also simplify the entire test suite and some of
lit's architecture.

Finally, the test suite runs 33% faster on Linux now. ;]
For my 16-hardware-thread (2x 4-core xeon e5520): 36s -> 24s

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159525 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-02 12:47:22 +00:00
Chandler Carruth
7e621f3242 Switch a bunch of Linker tests from using elaborate echo productions to
just provide and reference separate input files from an Inputs
subdirectory. This pattern works very well in the Clang tree and is
easier to understand in my opinion. It also has fewer limitations and
will remove one particularly annoying use of TCL-style {} quoting from
the testsuite.

Also teach the LLVM lit configuration to avoid recursing into 'Inputs'
subdirectories. This wasn't required for the previous 'Inputs'
subdirectories used due to fortuitous suffix patterns.

This is the first step to completely removing support for TCL-style tests.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@159520 91177308-0d34-0410-b5e6-96231b3b80d8
2012-07-02 10:18:06 +00:00
Michael J. Spencer
75338097c7 Remove llvm-ld and llvm-stub (which is only used by llvm-ld).
llvm-ld is no longer useful and causes confusion and so it is being removed.

* Does not work very well on Windows because it must call a gcc like driver to
  assemble and link.
* Has lots of hard coded paths which are wrong on many systems.
* Does not understand most of ld's options.
* Can be partially replaced by llvm-link | opt | {llc | as, llc -filetype=obj} |
  ld, or fully replaced by Clang.

I know of no production use of llvm-ld, and hacking use should be
replaced by Clang's driver.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@155147 91177308-0d34-0410-b5e6-96231b3b80d8
2012-04-19 19:27:54 +00:00
Bill Wendling
348e5e763e Add back removed code. It still causes LLVM to miscompile. But not having it breaks other things.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151594 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-27 23:48:30 +00:00
Bill Wendling
fddefccf05 XFAIL test until <rdar://problem/10913281> is fixed.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@151578 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-27 22:53:42 +00:00
Eli Bendersky
0f0c411079 Replace all instances of dg.exp file with lit.local.cfg, since all tests are run with LIT now and now Dejagnu. dg.exp is no longer needed.
Patch reviewed by Daniel Dunbar. It will be followed by additional cleanup patches.




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150664 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-16 06:28:33 +00:00
Bill Wendling
46b8b27057 Remove extraneous tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150636 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-15 23:44:05 +00:00
Bill Wendling
39c4cd3180 Add a test for the Objective-C garbage collection metadata stuff.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150626 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-15 22:44:10 +00:00
Bill Wendling
c54066aed3 Change error tests to coincide with message changes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150467 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-14 09:29:21 +00:00
Bill Wendling
d34cb1e09f [WIP] Initial code for module flags.
Module flags are key-value pairs associated with the module. They include a
'behavior' value, indicating how module flags react when mergine two
files. Normally, it's just the union of the two module flags. But if two module
flags have the same key, then the resulting flags are dictated by the behaviors.

Allowable behaviors are:

     Error
       Emits an error if two values disagree.

     Warning
       Emits a warning if two values disagree.

     Require
       Emits an error when the specified value is not present
       or doesn't have the specified value. It is an error for
       two (or more) llvm.module.flags with the same ID to have
       the Require behavior but different values. There may be
       multiple Require flags per ID.

     Override
       Uses the specified value if the two values disagree. It
       is an error for two (or more) llvm.module.flags with the
       same ID to have the Override behavior but different
       values.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150300 91177308-0d34-0410-b5e6-96231b3b80d8
2012-02-11 11:38:06 +00:00
Rafael Espindola
3ed8815541 Link symbols with different visibilities according to the rules in the
System V Application Binary Interface. This lets us use
-fvisibility-inlines-hidden with LTO.
Fixes PR11697.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@147624 91177308-0d34-0410-b5e6-96231b3b80d8
2012-01-05 23:02:01 +00:00
Chris Lattner
ea93373a0a Now that PR11464 is fixed, reapply the patch to fix PR11464,
merging types by name when we can.  We still don't guarantee type name linkage
but we do it when obviously the right thing to do.  This makes LTO type names 
easier to read, for example.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146932 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-20 00:12:26 +00:00
Chris Lattner
68910509fd fix PR11464 by preventing the linker from mapping two different struct types from the source module onto the same opaque destination type. An opaque type can only be resolved to one thing or another after all.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146929 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-20 00:03:52 +00:00
Chad Rosier
2e6119429f Revert 146728 as it's causing failures on some of the external bots as well as
internal nightly testers.  Original commit message:

By popular demand, link up types by name if they are isomorphic and one is an
autorenamed version of the other.   This makes the IR easier to read, because
we don't end up with random renamed versions of the types after LTO'ing a large
app.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146838 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-17 22:19:53 +00:00
Chris Lattner
9646acfccf By popular demand, link up types by name if they are isomorphic and one is an
autorenamed version of the other.   This makes the IR easier to read, because
we don't end up with random renamed versions of the types after LTO'ing a large app.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146728 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-16 08:36:07 +00:00
Chris Lattner
d2bf432b2b Upgrade syntax of tests using volatile instructions to use 'load volatile' instead of 'volatile load', which is archaic.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@145171 91177308-0d34-0410-b5e6-96231b3b80d8
2011-11-27 06:54:59 +00:00
Nico Weber
e688f8896b Let this test pass even if 'int' is somewhere in its directory path.
On my machine, grep matched:

  ; ModuleID = '/Volumes/MacintoshHD2/src/chrome-git/src/third_party/llvm/test/Linker/2011-08-18-unique-debug-type.ll'
  !9 = metadata !{i32 720932, null, metadata !"int", null, i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]

Explicitly filter out the ModuleID line.



git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@142077 91177308-0d34-0410-b5e6-96231b3b80d8
2011-10-15 18:07:16 +00:00
Andrew Trick
6ca06cd8a8 Use %% for literals in RUN lines.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138647 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-26 20:09:48 +00:00
Duncan Sands
3c0e5dc40f Testcase for PR10663.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@138231 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-22 10:32:09 +00:00
Devang Patel
727df2ca81 Add another test.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137969 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-18 18:50:25 +00:00
Devang Patel
3f52c51e00 Add test to check type uniquing.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@137968 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-18 18:40:49 +00:00
Devang Patel
1f35b17885 We need to map DebugLoc. It leads to Fuction * (through subprogram entry node) which should be appropriately mapped.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136910 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-04 20:02:18 +00:00
Devang Patel
211da8f7a9 Linke NamedMDNodes after linking global values as comment suggests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@136909 91177308-0d34-0410-b5e6-96231b3b80d8
2011-08-04 19:44:28 +00:00
Chris Lattner
7305c55a80 fix rdar://9776316 - type remapping needed for inline asm blobs,
fixing some objc llvm-test crashes with LTO.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135324 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-15 23:18:40 +00:00
Chris Lattner
1afcace3a3 Land the long talked about "type system rewrite" patch. This
patch brings numerous advantages to LLVM.  One way to look at it
is through diffstat:
 109 files changed, 3005 insertions(+), 5906 deletions(-)

Removing almost 3K lines of code is a good thing.  Other advantages
include:

1. Value::getType() is a simple load that can be CSE'd, not a mutating
   union-find operation.
2. Types a uniqued and never move once created, defining away PATypeHolder.
3. Structs can be "named" now, and their name is part of the identity that
   uniques them.  This means that the compiler doesn't merge them structurally
   which makes the IR much less confusing.
4. Now that there is no way to get a cycle in a type graph without a named
   struct type, "upreferences" go away.
5. Type refinement is completely gone, which should make LTO much MUCH faster
   in some common cases with C++ code.
6. Types are now generally immutable, so we can use "Type *" instead 
   "const Type *" everywhere.

Downsides of this patch are that it removes some functions from the C API,
so people using those will have to upgrade to (not yet added) new API.  
"LLVM 3.0" is the right time to do this.

There are still some cleanups pending after this, this patch is large enough
as-is.




git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134829 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-09 17:41:24 +00:00
Chris Lattner
5fe319b3bd remove a test that doesn't make sense in the new world.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134818 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-09 16:52:42 +00:00
Chandler Carruth
898402dba4 Quote two greps which contain parentheses.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@134353 91177308-0d34-0410-b5e6-96231b3b80d8
2011-07-02 20:43:13 +00:00
Rafael Espindola
4e93885bab Correctly merge available_externally and regular definitions when they have
different visibilities.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124650 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-01 05:33:52 +00:00
Chris Lattner
51e62f0f73 fix PR9015, a crash linking recursive metadata.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@124099 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-24 03:18:24 +00:00
Michael J. Spencer
ddbb3bcdd7 Make everyone happy this time.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123599 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-16 21:34:34 +00:00
Michael J. Spencer
6990433b56 Try and fix this test. For some reason llvm-ar thinks that the file exists when
it shouldn't, but I have no way to verify that it doesn't actually exist on the
buildbot.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123594 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-16 20:52:58 +00:00
Michael J. Spencer
c850965ec0 Revert "Archive: Replace all internal uses of PathV1 with PathV2. The external API still uses PathV1."
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123557 91177308-0d34-0410-b5e6-96231b3b80d8
2011-01-16 01:43:22 +00:00