1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 19:12:56 +02:00
Commit Graph

917 Commits

Author SHA1 Message Date
Duncan P. N. Exon Smith
efed7351e5 Verifier: Check accessors of MDLocation
Check accessors of `MDLocation`, and change them to `cast<>` down to the
right types.  Also add type-safe factory functions.

All the callers that handle broken code need to use the new versions of
the accessors (`getRawScope()` instead of `getScope()`) that still
return `Metadata*`.  This is also necessary for things like
`MDNodeKeyImpl<MDLocation>` (in LLVMContextImpl.h) that need to unique
the nodes when their operands might still be forward references of the
wrong type.

In the `Value` hierarchy, consumers that handle broken code use
`getOperand()` directly.  However, debug info nodes have a ton of
operands, and their order (even their existence) isn't stable yet.  It's
safer and more maintainable to add an explicit "raw" accessor on the
class itself.

llvm-svn: 233322
2015-03-26 22:05:04 +00:00
Benjamin Kramer
0d09df9f5d Internalize BitcodeReader. Not used outside of BitcodeReader.cpp.
NFC.

llvm-svn: 232542
2015-03-17 20:40:24 +00:00
Duncan P. N. Exon Smith
9e34c465ed AsmWriter: Assert on unresolved metadata nodes
Assert that `MDNode::isResolved()`.  While in theory the `Verifier`
should catch this, it doesn't descend into all debug info, and the
`DebugInfoVerifier` doesn't call into the `Verifier`.  Besides, this
helps to catch bugs when `-disable-verify=true`.

Note that I haven't come across a place where this fails with clang
today, so no testcase.

llvm-svn: 232442
2015-03-17 00:16:35 +00:00
David Blaikie
e59ac07033 Add testing for mismatched explicit type on a gep operator when loading from bitcode
llvm-svn: 232427
2015-03-16 22:03:50 +00:00
David Blaikie
921ef6c8fc Add testing for mismatched explicit type on a load instruction when loading from bitcode
llvm-svn: 232424
2015-03-16 21:48:46 +00:00
David Blaikie
4caaf07afa Test bitcode parsing error-handling for incorrect explicit type
(turns out I had regressed this when sinking handling of this type down
into GetElementPtrInst::Create - since that asserted before the error
handling was performed)

llvm-svn: 232420
2015-03-16 21:35:48 +00:00
David Blaikie
6b8c7476b9 [opaque pointer type] more gep API migration
llvm-svn: 232274
2015-03-14 19:53:33 +00:00
Rafael Espindola
20325e7adb Be lazy about loading metadata in IRObjectFile.
This speeds up llvm-ar building lib64/libclangSema.a with debug IR files
from 8.658015807 seconds to just 0.351036519 seconds :-)

llvm-svn: 232221
2015-03-13 21:54:20 +00:00
David Blaikie
3c00f3082e [opaque pointer type] Bitcode support for explicit type parameter on the gep operator
This happened to be fairly easy to support backwards compatibility based
on the number of operands (old format had an even number, new format has
one more operand so an odd number).

test/Bitcode/old-aliases.ll already appears to test old gep operators
(if I remove the backwards compatibility in the BitcodeReader, this and
another test fail) so I'm not adding extra test coverage here.

llvm-svn: 232216
2015-03-13 21:03:36 +00:00
David Blaikie
d92edb4bb2 Turn assertion into bitcode reading error
I don't think we test invalid bitcode records in any detail, so no test
here - just a change for consistency with existing error checks in
surrounding code.

llvm-svn: 232215
2015-03-13 21:03:34 +00:00
Manman Ren
3b5ee180c5 Add a parameter for getLazyBitcodeModule to lazily load Metadata.
We only defer loading metadata inside ParseModule when ShouldLazyLoadMetadata
is true and we have not loaded any Metadata block yet.

This commit implements all-or-nothing loading of Metadata. If there is a
request to load any metadata block, we will load all deferred metadata blocks.

We make sure the deferred metadata blocks are loaded before we materialize any
function or a module.

The default value of the added parameter ShouldLazyLoadMetadata for
getLazyBitcodeModule is false, so the default behavior stays the same.

We only set the parameter to true when creating LTOModule in local contexts.
These can only really be used for parsing symbols, so it's unnecessary to ever
load the metadata blocks.

If we are going to enable lazy-loading of Metadata for other usages of
getLazyBitcodeModule, where deferred metadata blocks need to be loaded, we can
expose BitcodeReader::materializeMetadata to Module, similar to
Module::materialize.

rdar://19804575

llvm-svn: 232198
2015-03-13 19:24:30 +00:00
David Blaikie
350b9cbf65 Simplify expressions involving boolean constants with clang-tidy
Patch by Richard (legalize at xmission dot com).

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

llvm-svn: 231617
2015-03-09 01:57:13 +00:00
Benjamin Kramer
ce7baceeed Add missing includes. make_unique proliferated everywhere.
llvm-svn: 230909
2015-03-01 21:28:53 +00:00
Yaron Keren
1d193961f0 Silence three more variable set but not used warnings, NFC.
llvm-svn: 230853
2015-02-28 15:29:17 +00:00
David Blaikie
cac63ea2c3 [opaque pointer type] Bitcode support for explicit type parameter on GEP.
Like r230414, add bitcode support including backwards compatibility, for
an explicit type parameter to GEP.

At the suggestion of Duncan I tried coalescing the two older bitcodes into a
single new bitcode, though I did hit a wrinkle: I couldn't figure out how to
create an explicit abbreviation for a record with a variable number of
arguments (the indicies to the gep). This means the discriminator between
inbounds and non-inbounds gep is a full variable-length field I believe? Is my
understanding correct? Is there a way to create such an abbreviation? Should I
just use two bitcodes as before?

Reviewers: dexonsmith

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

llvm-svn: 230415
2015-02-25 01:08:52 +00:00
David Blaikie
9cc272162f [opaque pointer type] bitcode support for explicit type parameter to the load instruction
Summary:
I've taken my best guess at this, but I've cargo culted in places & so
explanations/corrections would be great.

This seems to pass all the tests (check-all, covering clang and llvm) so I
believe that pretty well exercises both the backwards compatibility and common
(same version) compatibility given the number of checked in bitcode files we
already have. Is that a reasonable approach to testing here? Would some more
explicit tests be desired?

1) is this the right way to do back-compat in this case (looking at the number
  of entries in the bitcode record to disambiguate between the old schema and
  the new?)

2) I don't quite understand the logarithm logic to choose the encoding type of
  the type parameter in the abbreviation description, but I found another
  instruction doing the same thing & it seems to work. Is that the right
  approach?

Reviewers: dexonsmith

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

llvm-svn: 230414
2015-02-25 01:07:20 +00:00
David Blaikie
84396f6ee6 BitcodeWriter: Refactor common computation of bits required for a type index.
Suggested by Duncan. Happy to bikeshed the name, cache the result, etc.

llvm-svn: 230410
2015-02-25 00:51:52 +00:00
JF Bastien
72a7d70886 Use common parse routine to read alignment values from bitcode
While fuzzing LLVM bitcode files, I discovered that (1) the bitcode reader doesn't check that alignments are no larger than 2**29; (2) downstream code doesn't check the range; and (3) for values out of range, corresponding large memory requests (based on alignment size) will fail. This code fixes the bitcode reader to check for valid alignments, fixing this problem.

This CL fixes alignment value on global variables, functions, and instructions: alloca, load, load atomic, store, store atomic.

Patch by Karl Schimpf (kschimpf@google.com).

llvm-svn: 230180
2015-02-22 19:32:03 +00:00
Duncan P. N. Exon Smith
650a4c9733 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.

llvm-svn: 229960
2015-02-20 03:17:58 +00:00
Duncan P. N. Exon Smith
9d3d24622e 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.)

llvm-svn: 229791
2015-02-19 00:37:21 +00:00
Benjamin Kramer
21bee91af5 Prefer SmallVector::append/insert over push_back loops.
Same functionality, but hoists the vector growth out of the loop.

llvm-svn: 229500
2015-02-17 15:29:18 +00:00
Duncan P. N. Exon Smith
29a6fcc535 Bitcode: Fix major regression: large files w/ debug info
The metadata/value split introduced a major regression reading large
bitcode files that contain debug info (or other cyclic (non-self
reference) metadata graphs).  For the first time in a while, I dropped
from libLTO.dylib down to `llvm-lto` with a non-trivial bitcode file
(~350MB), and I hit this when reading the result of ld64's `-save-temps`
in `llvm-lto`.

Here's pseudo-code for what was going on:

    read-main-metadata-block:
      for each md:
        if has-fwd-ref: // Only true for cyclic graphs.
          any-fwd-refs <- true
      if any-fwd-refs:
        foreach md:
          resolve-cycles(md) // Handle cycles.

    foreach function:
      read-function-metadata-block: // Such as !alias, !loop
        if any-fwd-refs:
          foreach md: // (all metadata, not just this block)
            resolve-cycles(md) // A no-op, but the loop is expensive!!

This commit resets the `AnyFwdRefs` flag to `false`.  This on its own
was enough to change my Release+Asserts `llvm-lto` time for reading this
bitcode from over 20 minutes (I gave up on it) to 20 seconds.  I've gone
further by tracking the min/max metadata forward-references in a
metadata block.  This protects against a schema that has lots of
functions that each reference their own metadata cycle.

Unfortunately, this regression is in the 3.6 branch as well.

llvm-svn: 229421
2015-02-16 19:18:01 +00:00
Filipe Cabecinhas
e4564d63bb [Bitcode reader] Fix a few assertions when reading invalid files
Summary:
When creating {insert,extract}value instructions from a BitcodeReader, we
weren't verifying the fields were valid.

Bugs found with afl-fuzz

Reviewers: rafael

Subscribers: llvm-commits

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

llvm-svn: 229345
2015-02-16 00:03:11 +00:00
Aaron Ballman
0b45511a2e Removing LLVM_DELETED_FUNCTION, as MSVC 2012 was the last reason for requiring the macro. NFC; LLVM edition.
llvm-svn: 229340
2015-02-15 22:54:22 +00:00
Richard Smith
1007da1563 Clean up some inappropriate choices of type in the bitcode reader. None of
these are expected to fix any 64->32 bit real truncation issues.

llvm-svn: 229153
2015-02-13 21:05:11 +00:00
Duncan P. N. Exon Smith
8dc64a4707 AsmWriter/Bitcode: MDImportedEntity
llvm-svn: 229025
2015-02-13 01:46:02 +00:00
Duncan P. N. Exon Smith
baf6eacc58 AsmWriter/Bitcode: MDObjCProperty
llvm-svn: 229024
2015-02-13 01:43:22 +00:00
Duncan P. N. Exon Smith
e023c0f5eb AsmWriter/Bitcode: MDExpression
llvm-svn: 229023
2015-02-13 01:42:09 +00:00
Duncan P. N. Exon Smith
c9450daed2 AsmWriter/Bitcode: MDLocalVariable
llvm-svn: 229022
2015-02-13 01:39:44 +00:00
Duncan P. N. Exon Smith
58b49ba795 AsmWriter/Bitcode: MDGlobalVariable
llvm-svn: 229020
2015-02-13 01:35:40 +00:00
Duncan P. N. Exon Smith
d136432599 AsmWriter/Bitcode: MDTemplate{Type,Value}Parameter
llvm-svn: 229019
2015-02-13 01:34:32 +00:00
Duncan P. N. Exon Smith
c96d92ad70 AsmWriter/Bitcode: MDNamespace
llvm-svn: 229018
2015-02-13 01:32:09 +00:00
Duncan P. N. Exon Smith
affacdfc5b AsmWriter/Bitcode: MDLexicalBlockFile
llvm-svn: 229017
2015-02-13 01:30:42 +00:00
Duncan P. N. Exon Smith
b3ef6197cf AsmWriter/Bitcode: MDLexicalBlock
llvm-svn: 229016
2015-02-13 01:29:28 +00:00
Duncan P. N. Exon Smith
52584d6996 AsmWriter/Bitcode: MDSubprogram
llvm-svn: 229014
2015-02-13 01:26:47 +00:00
Duncan P. N. Exon Smith
21bc2cacec AsmWriter/Bitcode: MDCompileUnit
llvm-svn: 229013
2015-02-13 01:25:10 +00:00
Duncan P. N. Exon Smith
51dcb8de94 AsmWriter/Bitcode: MDSubroutineType
llvm-svn: 229011
2015-02-13 01:22:59 +00:00
Duncan P. N. Exon Smith
c4bb6d7bbb AsmWriter/Bitcode: MDDerivedType and MDCompositeType
llvm-svn: 229009
2015-02-13 01:20:38 +00:00
Duncan P. N. Exon Smith
4428ff1087 AsmWriter/Bitcode: MDFile
llvm-svn: 229007
2015-02-13 01:19:14 +00:00
Duncan P. N. Exon Smith
38e2854cc3 AsmWriter/Bitcode: MDBasicType
llvm-svn: 229005
2015-02-13 01:14:58 +00:00
Duncan P. N. Exon Smith
8b689964a4 AsmWriter/Bitcode: MDEnumerator
llvm-svn: 229004
2015-02-13 01:14:11 +00:00
Duncan P. N. Exon Smith
9879c4ea87 AsmWriter/Bitcode: MDSubrange
llvm-svn: 229003
2015-02-13 01:10:38 +00:00
Zachary Turner
76143c865c Use ADDITIONAL_HEADER_DIRS in all LLVM CMake projects.
This allows IDEs to recognize the entire set of header files for
each of the core LLVM projects.

Differential Revision: http://reviews.llvm.org/D7526
Reviewed By: Chris Bieneman

llvm-svn: 228798
2015-02-11 03:28:02 +00:00
Duncan P. N. Exon Smith
1c43bf9cfb 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.

llvm-svn: 228640
2015-02-10 00:52:32 +00:00
Duncan P. N. Exon Smith
2b8de5594c IR: Initialize MDNode abbreviations en masse, NFC
llvm-svn: 228203
2015-02-04 21:54:12 +00:00
Peter Collingbourne
02d122cad4 Misc documentation/comment fixes.
llvm-svn: 228093
2015-02-04 00:42:45 +00:00
Duncan P. N. Exon Smith
55694c075d IR: Assembly and bitcode for GenericDebugNode
llvm-svn: 228041
2015-02-03 21:54:14 +00:00
Rafael Espindola
40410a9efa Propagate a better error message to the C api.
llvm-svn: 227934
2015-02-03 01:53:03 +00:00
Rafael Espindola
c8c6c9e6c7 Use a non-fatal diag handler in the C API. FIxes PR22368.
llvm-svn: 227903
2015-02-03 00:49:57 +00:00
Duncan P. N. Exon Smith
439bf9404e 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`.

llvm-svn: 227835
2015-02-02 18:53:21 +00:00