Commit Graph

521 Commits

Author SHA1 Message Date
Duncan P. N. Exon Smith
ea8cbe9782 Bitcode: Stop assuming non-null fields
When writing the bitcode serialization for the new debug info hierarchy,
I assumed two fields would never be null.

Drop that assumption, since it's brittle (and crashes the
`BitcodeWriter` if wrong), and is a check better left for the verifier
anyway.  (No need for a bitcode upgrade here, since the new hierarchy is
still not in place.)

The fields in question are `MDCompileUnit::getFile()` and
`MDDerivedType::getBaseType()`, the latter of which isn't null in
test/Transforms/Mem2Reg/ConvertDebugInfo2.ll (see !14, a pointer to
nothing).  While the testcase might have bitrotted, there's no reason
for the bitcode format to rely on non-null for metadata operands.

This also fixes a bug in `AsmWriter` where if the `file:` is null it
isn't emitted (caught by the double-round trip in the testcase I'm
adding) -- this is a required field in `LLParser`.

I'll circle back to ConvertDebugInfo2.  Once the specialized nodes are
in place, I'll be trying to turn the debug info verifier back on by
default (in the newer module pass form committed r206300) and throwing
more logic in there.  If the testcase has bitrotted (as opposed to me
not understanding the schema correctly) I'll fix it then.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229960 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-20 03:17:58 +00:00
Duncan P. N. Exon Smith
eac950e408 IR: Drop scope from MDTemplateParameter
Follow-up to r229740, which removed `DITemplate*::getContext()` after my
upgrade script revealed that scopes are always `nullptr` for template
parameters.  This is the other shoe: drop `scope:` from
`MDTemplateParameter` and its two subclasses.  (Note: a bitcode upgrade
would be pointless, since the hierarchy hasn't been moved into place.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229791 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-19 00:37:21 +00:00
Benjamin Kramer
1a50a12b43 Prefer SmallVector::append/insert over push_back loops.
Same functionality, but hoists the vector growth out of the loop.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229500 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-17 15:29:18 +00:00
Aaron Ballman
66981fe208 Removing LLVM_DELETED_FUNCTION, as MSVC 2012 was the last reason for requiring the macro. NFC; LLVM edition.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229340 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-15 22:54:22 +00:00
Duncan P. N. Exon Smith
6a390dc584 AsmWriter/Bitcode: MDImportedEntity
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229025 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 01:46:02 +00:00
Duncan P. N. Exon Smith
3bfa8d00ae AsmWriter/Bitcode: MDObjCProperty
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229024 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 01:43:22 +00:00
Duncan P. N. Exon Smith
a034e076c2 AsmWriter/Bitcode: MDExpression
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229023 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 01:42:09 +00:00
Duncan P. N. Exon Smith
a342d827bd AsmWriter/Bitcode: MDLocalVariable
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229022 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 01:39:44 +00:00
Duncan P. N. Exon Smith
fbc547da81 AsmWriter/Bitcode: MDGlobalVariable
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229020 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 01:35:40 +00:00
Duncan P. N. Exon Smith
8921bbca59 AsmWriter/Bitcode: MDTemplate{Type,Value}Parameter
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229019 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 01:34:32 +00:00
Duncan P. N. Exon Smith
7bd3d1d3bd AsmWriter/Bitcode: MDNamespace
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229018 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 01:32:09 +00:00
Duncan P. N. Exon Smith
246f0931ff AsmWriter/Bitcode: MDLexicalBlockFile
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229017 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 01:30:42 +00:00
Duncan P. N. Exon Smith
c7be07e636 AsmWriter/Bitcode: MDLexicalBlock
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229016 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 01:29:28 +00:00
Duncan P. N. Exon Smith
ed356a925a AsmWriter/Bitcode: MDSubprogram
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229014 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 01:26:47 +00:00
Duncan P. N. Exon Smith
37742c3591 AsmWriter/Bitcode: MDCompileUnit
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229013 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 01:25:10 +00:00
Duncan P. N. Exon Smith
1c092c03ba AsmWriter/Bitcode: MDSubroutineType
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229011 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 01:22:59 +00:00
Duncan P. N. Exon Smith
dacf0004cb AsmWriter/Bitcode: MDDerivedType and MDCompositeType
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229009 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 01:20:38 +00:00
Duncan P. N. Exon Smith
192d9c3b6f AsmWriter/Bitcode: MDFile
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229007 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 01:19:14 +00:00
Duncan P. N. Exon Smith
57b4c150ca AsmWriter/Bitcode: MDBasicType
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229005 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 01:14:58 +00:00
Duncan P. N. Exon Smith
aa7c94359c AsmWriter/Bitcode: MDEnumerator
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229004 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 01:14:11 +00:00
Duncan P. N. Exon Smith
b984c49449 AsmWriter/Bitcode: MDSubrange
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229003 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-13 01:10:38 +00:00
Duncan P. N. Exon Smith
14fcfef23b IR: Add specialized debug info metadata nodes
Add specialized debug info metadata nodes that match the `DIDescriptor`
wrappers (used by `DIBuilder`) closely.  Assembly and bitcode support to
follow soon (it'll mostly just be obvious), but this sketches in today's
schema.  This is the first big commit (well, the only *big* one aside
from the testcase changes that'll come when I move this into place) for
PR22464.

I've marked a bunch of obvious changes as `TODO`s in the source; I plan
to make those changes promptly after this hierarchy is moved underneath
`DIDescriptor`, but for now I'm aiming mostly to match the status quo.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228640 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-10 00:52:32 +00:00
Duncan P. N. Exon Smith
ab47b42e26 IR: Initialize MDNode abbreviations en masse, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228203 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-04 21:54:12 +00:00
Peter Collingbourne
5e51ed875d Misc documentation/comment fixes.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228093 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-04 00:42:45 +00:00
Duncan P. N. Exon Smith
6adbfa3815 IR: Assembly and bitcode for GenericDebugNode
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@228041 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-03 21:54:14 +00:00
Duncan P. N. Exon Smith
ca8d3bf8af IR: Split out DebugInfoMetadata.h, NFC
Move debug-info-centred `Metadata` subclasses into their own
header/source file.  A couple of private template functions are needed
from both `Metadata.cpp` and `DebugInfoMetadata.cpp`, so I've moved them
to `lib/IR/MetadataImpl.h`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@227835 91177308-0d34-0410-b5e6-96231b3b80d8
2015-02-02 18:53:21 +00:00
Duncan P. N. Exon Smith
cee1699e9f IR: DwarfNode => DebugNode, NFC
These things are potentially used for non-DWARF data (see the discussion
in PR22235), so take the `Dwarf` out of the name.  Since the new name
gives fewer clues, update the doxygen to properly describe what they
are.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226874 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-22 22:47:44 +00:00
Duncan P. N. Exon Smith
022707e65a Bitcode: Simplify MDNode subclass dispatch, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226535 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20 01:03:09 +00:00
Duncan P. N. Exon Smith
f638e95852 Bitcode: WriteMDNode() => WriteMDTuple(), NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226534 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20 01:01:53 +00:00
Duncan P. N. Exon Smith
52f3603b17 Bitcode: Add ValueEnumerator::getMetadataOrNullID(), NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226533 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-20 01:00:23 +00:00
Rafael Espindola
4b678bff4e Bring r226038 back.
No change in this commit, but clang was changed to also produce trivial comdats when
needed.

Original message:

Don't create new comdats in CodeGen.

This patch stops the implicit creation of comdats during codegen.

Clang now sets the comdat explicitly when it is required. With this patch clang and gcc
now produce the same result in pr19848.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226467 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-19 15:16:06 +00:00
Timur Iskhodzhanov
6a7c74de33 Revert r226242 - Revert Revert Don't create new comdats in CodeGen
This breaks AddressSanitizer (ninja check-asan) on Windows

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226251 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-16 08:38:45 +00:00
Rafael Espindola
dfe88a08c7 Revert "Revert Don't create new comdats in CodeGen"
This reverts commit r226173, adding r226038 back.

No change in this commit, but clang was changed to also produce trivial comdats for
costructors, destructors and vtables when needed.

Original message:

Don't create new comdats in CodeGen.

This patch stops the implicit creation of comdats during codegen.

Clang now sets the comdat explicitly when it is required. With this patch clang and gcc
now produce the same result in pr19848.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226242 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-16 02:22:55 +00:00
Timur Iskhodzhanov
d048b3be70 Revert Don't create new comdats in CodeGen
It breaks AddressSanitizer on Windows.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226173 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-15 16:14:34 +00:00
Rafael Espindola
33f5127540 Don't create new comdats in CodeGen.
This patch stops the implicit creation of comdats during codegen.

Clang now sets the comdat explicitly when it is required. With this patch clang and gcc
now produce the same result in pr19848.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226038 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 20:55:48 +00:00
Rafael Espindola
ad946a868f Add support for comdats with names larger than 256 characters.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226012 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-14 18:25:45 +00:00
Duncan P. N. Exon Smith
3b0fe4ec0a AsmParser/Bitcode: Add support for MDLocation
This adds assembly and bitcode support for `MDLocation`.  The assembly
side is rather big, since this is the first `MDNode` subclass (that
isn't `MDTuple`).  Part of PR21433.

(If you're wondering where the mountains of testcase updates are, we
don't need them until I update `DILocation` and `DebugLoc` to actually
use this class.)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225830 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-13 21:10:44 +00:00
Duncan P. N. Exon Smith
e73fc94f02 Bitcode: Range-based for, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225716 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12 22:35:34 +00:00
Duncan P. N. Exon Smith
0c3289e0bb Bitcode: Add abbreviation for METADATA_NAME
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225715 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12 22:34:10 +00:00
Duncan P. N. Exon Smith
442539c468 Bitcode: Range-based for, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225714 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12 22:33:00 +00:00
Duncan P. N. Exon Smith
f3e42b3baf Bitcode: Range-based for, NFC
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225713 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12 22:31:35 +00:00
Duncan P. N. Exon Smith
8d86cef92f Bitcode: Simplify emission of METADATA_BLOCK
Refactor logic so that we know up-front whether to open a block and
whether we need an MDString abbreviation.

This is almost NFC, but will start emitting `MDString` abbreviations
when the first record is not an `MDString`.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225712 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-12 22:30:34 +00:00
Duncan P. N. Exon Smith
98e3b1abbf Revert "Bitcode: Move the DEBUG_LOC record to DEBUG_LOC_OLD"
This reverts commit r225498 (but leaves r225499, which was a worthy
cleanup).

My plan was to change `DEBUG_LOC` to store the `MDNode` directly rather
than its operands (patch was to go out this morning), but on reflection
it's not clear that it's strictly better.  (I had missed that the
current code is unlikely to emit the `MDNode` at all.)

Conflicts:
	lib/Bitcode/Reader/BitcodeReader.cpp (due to r225499)

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225531 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-09 17:53:27 +00:00
Duncan P. N. Exon Smith
97bbaa3227 Bitcode: Move the DEBUG_LOC record to DEBUG_LOC_OLD
Prepare to simplify the `DebugLoc` record.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225498 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-09 02:48:48 +00:00
Duncan P. N. Exon Smith
f416d72973 IR: Add 'distinct' MDNodes to bitcode and assembly
Propagate whether `MDNode`s are 'distinct' through the other types of IR
(assembly and bitcode).  This adds the `distinct` keyword to assembly.

Currently, no one actually calls `MDNode::getDistinct()`, so these nodes
only get created for:

  - self-references, which are never uniqued, and
  - nodes whose operands are replaced that hit a uniquing collision.

The concept of distinct nodes is still not quite first-class, since
distinct-ness doesn't yet survive across `MapMetadata()`.

Part of PR22111.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225474 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-08 22:38:29 +00:00
Rafael Espindola
e8d9f7b5d1 clang-format. NFC.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225454 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-08 16:25:01 +00:00
Chandler Carruth
b246acebf4 [PM] Switch the new pass manager to use a reference-based API for IR
units.

This was debated back and forth a bunch, but using references is now
clearly cleaner. Of all the code written using pointers thus far, in
only one place did it really make more sense to have a pointer. In most
cases, this just removes immediate dereferencing from the code. I think
it is much better to get errors on null IR units earlier, potentially
at compile time, than to delay it.

Most notably, the legacy pass manager uses references for its routines
and so as more and more code works with both, the use of pointers was
likely to become really annoying. I noticed this when I ported the
domtree analysis over and wrote the entire thing with references only to
have it fail to compile. =/ It seemed better to switch now than to
delay. We can, of course, revisit this is we learn that references are
really problematic in the API.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@225145 91177308-0d34-0410-b5e6-96231b3b80d8
2015-01-05 02:47:05 +00:00
Nick Lewycky
9451a382ed Make ValueEnumerator::print use OS for metadata too. Noticed by inspection.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224404 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-17 01:52:08 +00:00
Duncan P. N. Exon Smith
4bedb48751 Bitcode: Use unsigned char to record MDStrings
`MDString`s can have arbitrary characters in them.  Prevent an assertion
that fired in `BitcodeWriter` because of sign extension by copying the
characters into the record as `unsigned char`s.

Based on a patch by Keno Fischer; fixes PR21882.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224077 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-11 23:34:30 +00:00
Duncan P. N. Exon Smith
e39dba9f07 Bitcode: Add METADATA_NODE and METADATA_VALUE
This reflects the typelessness of `Metadata` in the bitcode format,
removing types from all metadata operands.

`METADATA_VALUE` represents a `ValueAsMetadata`, and always has two
fields: the type and the value.

`METADATA_NODE` represents an `MDNode`, and unlike `METADATA_OLD_NODE`,
doesn't store types.  It stores operands at their ID+1 so that `0` can
reference `nullptr` operands.

Part of PR21532.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224073 91177308-0d34-0410-b5e6-96231b3b80d8
2014-12-11 23:02:24 +00:00