PR19767: DebugInfo emission of pointer constants.

In refactoring DwarfUnit::isUnsignedDIType I restricted it to only work
on values with signedness (unsigned or signed), asserting on anything
else (which did uncover some bugs). But it turns out that we do need to
emit constants of signless data, such as pointer constants - only null
pointer constants are known to need this so far, but it's conceivable
that there might be non-null pointer constants at some point (hardcoded
address offsets for device drivers?).

This patch just uses 'unsigned' for signless data such as pointer
constants. Arguably we could use signless representations
(DW_FORM_dataN) instead, allowing a trinary result from isUnsignedDIType
(signed, unsigned, signless), but this seems reasonable for now.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209223 91177308-0d34-0410-b5e6-96231b3b80d8
Rewrite calculateDbgValueHistory to make it (hopefully) more transparent.

This change preserves the original algorithm of generating history
for user variables, but makes it more clear.

High-level description of algorithm:
Scan all the machine basic blocks and machine instructions in the order
they are emitted to the object file. Do the following:
1) If we see a DBG_VALUE instruction, add it to the history of the
corresponding user variable. Keep track of all user variables, whose
locations are described by a register.
2) If we see a regular instruction, look at all the registers it clobbers,
and terminate the location range for all variables described by these registers.
3) At the end of the basic block, terminate location ranges for all
user variables described by some register.

Although this change shouldn't be user-visible (the contents of .debug_loc section
should be the same), it changes some internal assumptions about the set
of instructions used to track the variable locations. Watching the bots.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209225 91177308-0d34-0410-b5e6-96231b3b80d8
Fix test breakage introduced in r209223.

Oops, broke the broken enum constants again.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209226 91177308-0d34-0410-b5e6-96231b3b80d8
GlobalValue: Automatically reset visibility when setting local linkage

r208264 started asserting in `setLinkage()` and `setVisibility()` that
visibility and linkage are compatible.  There are a few places in clang
where visibility is set first, and then linkage later, so the assert
fires.  In `setLinkage()`, it's clear what the visibility *should* be,
so rather than updating all the call sites just automatically fix the
visibility.

The testcase for this is for *clang*, so it'll follow separately in cfe.

PR19760

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209227 91177308-0d34-0410-b5e6-96231b3b80d8
[LSR] Canonicalize reg1 + ... + regN into reg1 + ... + 1*regN.

This commit introduces a canonical representation for the formulae.
Basically, as soon as a formula has more that one base register, the scaled
register field is used for one of them. The register put into the scaled
register is preferably a loop variant.
The commit refactors how the formulae are built in order to produce such
representation.
This yields a more accurate, but still perfectible, cost model.

<rdar://problem/16731508>


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209230 91177308-0d34-0410-b5e6-96231b3b80d8
Update MachOObjectFile::getSymbolAddress so it returns UnknownAddressOrSize
for undefined symbols.  Allowing llvm-nm to print spaces instead of 0’s for
the value of undefined symbols in Mach-O files.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209235 91177308-0d34-0410-b5e6-96231b3b80d8
Revert r209235 as it broke two tests:
Failing Tests (2):
	    LLVM :: ExecutionEngine/MCJIT/stubs-sm-pic.ll
	    LLVM :: ExecutionEngine/MCJIT/stubs.ll


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209236 91177308-0d34-0410-b5e6-96231b3b80d8
Move the function and data section flags into the options struct and
make the functions to set them non-static.
Move and rename the llvm specific backend options to avoid conflicting
with the clang option.

Paired with a backend commit to update.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209238 91177308-0d34-0410-b5e6-96231b3b80d8
Unbreak the sanitizer buildbots after r209226 due to SROA issue described in http://reviews.llvm.org/D3714

Undecided whether this should include a test case - SROA produces bad
dbg.value metadata describing a value for a reference that is actually
the value of the thing the reference refers to. For now, loosening the
assert lets this not assert, but it's still bogus/wrong output...

If someone wants to tell me to add a test, I'm willing/able, just
undecided. Hopefully we'll get SROA fixed soon & we can tighten up this
assertion again.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209240 91177308-0d34-0410-b5e6-96231b3b80d8
[ARM64] PR19792: Fix cycle in DAG after performPostLD1Combine

Povray and dealII currently assert with "Overran sorted position" in
AssignTopologicalOrder.  The problem is that performPostLD1Combine can
introduce cycles.

Consider:

(insert_vector_elt (INSERT_SUBREG undef,
                                  (load (add %vreg0, Constant<8>), undef),  <= A
                                  TargetConstant<2>),
                   (load %vreg0, undef),                                    <= B
                   Constant<1>)

This is turned into a LD1LANEpost node.  However the address in A is not a
valid user of the post-incremented address of B in LD1LANEpost.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209242 91177308-0d34-0410-b5e6-96231b3b80d8
Revert "DebugInfo: Assume all subprogram DIEs have been created before any abstract subprograms are constructed."

This reverts commit r209178.

This seems to be asserting in an LTO build on some internal Apple
buildbots. No upstream reproduction (and I don't have an LLVM-aware gold
built right now to reproduce it personally) but it's a small patch & the
failure's semi-plausible so I'm going to revert first while I try to
reproduce this.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209251 91177308-0d34-0410-b5e6-96231b3b80d8
Fix test added in r209242: llc shouldn't create files in source tree

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209252 91177308-0d34-0410-b5e6-96231b3b80d8
Update MachOObjectFile::getSymbolAddress so it returns UnknownAddressOrSize
for undefined symbols, so it matches what COFFObjectFile::getSymbolAddress
does.  This allows llvm-nm to print spaces instead of 0’s for the value
of undefined symbols in Mach-O files.

To make this change other uses of MachOObjectFile::getSymbolAddress
are updated to handle when the Value is returned as UnknownAddressOrSize.
Which is needed to keep two of the ExecutionEngine tests working for example.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209253 91177308-0d34-0410-b5e6-96231b3b80d8
Move the verbose asm option to be part of the options struct and
set appropriately.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209258 91177308-0d34-0410-b5e6-96231b3b80d8
Move this test to the backend from the frontend.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209259 91177308-0d34-0410-b5e6-96231b3b80d8
Add a comment here.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209262 91177308-0d34-0410-b5e6-96231b3b80d8
This command line option is only used in one place. Move it there and
rename it to something more descriptive.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209263 91177308-0d34-0410-b5e6-96231b3b80d8
ARM: correct bundle generation for MOV32T relocations

Although the previous code would construct a bundle and add the correct elements
to it, it would not finalise the bundle.  This resulted in the InternalRead
markers not being added to the MachineOperands nor, more importantly, the
externally visible defs to the bundle itself.  So, although the bundle was not
exposing the def, the generated code would be correct because there was no
optimisations being performed.  When optimisations were enabled, the post
register allocator would kick in, and the hazard recognizer would reorder
operations around the load which would define the value being operated upon.

Rather than manually constructing the bundle, simply construct and finalise the
bundle via the finaliseBundle call after both MIs have been emitted.  This
improves the code generation with optimisations where IMAGE_REL_ARM_MOV32T
relocations are emitted.

The changes to the other tests are the result of the bundle generation
preventing the scheduler from hoisting the moves across the loads.  The net
effect of the generated code is equivalent, but, is much more identical to what
is actually being lowered.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209267 91177308-0d34-0410-b5e6-96231b3b80d8
[modules] Add module maps for LLVM. These are not quite ready for prime-time
yet, but only a few more Clang patches need to land. (I have 'ninja check'
passing locally.)


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209269 91177308-0d34-0410-b5e6-96231b3b80d8
MC: mark COFF .drectve section as REMOVE

The .drectve section should be marked as IMAGE_SCN_LNK_REMOVE.  This matches what
the MSVC toolchain does and accurately reflects that this section should not be
emitted into the final binary.  This section is merely information for the
linker, comprising of additional linker directives.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209273 91177308-0d34-0410-b5e6-96231b3b80d8