summaryrefslogtreecommitdiffstats
path: root/llvm/lib/AsmParser/LLParser.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Verifier: Check accessors of MDLocationDuncan P. N. Exon Smith2015-03-261-2/+2
| | | | | | | | | | | | | | | | | | | | 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
* AsmParser: Stop requiring 'name:' when it's not printedDuncan P. N. Exon Smith2015-03-161-3/+3
| | | | | | | | | r230877 optimized which fields are written out for `CHECK`-ability, but apparently missed changing some of them to optional in `LLParser`. Fixes PR22921. llvm-svn: 232400
* [opaque pointer type] more gep API migrations (AsmParser)David Blaikie2015-03-141-1/+1
| | | | llvm-svn: 232276
* [opaque pointer type] Add textual IR support for explicit type parameter to ↵David Blaikie2015-03-131-2/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | gep operator Similar to gep (r230786) and load (r230794) changes. Similar migration script can be used to update test cases, which successfully migrated all of LLVM and Polly, but about 4 test cases needed manually changes in Clang. (this script will read the contents of stdin and massage it into stdout - wrap it in the 'apply.sh' script shown in previous commits + xargs to apply it over a large set of test cases) import fileinput import sys import re rep = re.compile(r"(getelementptr(?:\s+inbounds)?\s*\()((<\d*\s+x\s+)?([^@]*?)(|\s*addrspace\(\d+\))\s*\*(?(3)>)\s*)(?=$|%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|zeroinitializer|<|\[\[[a-zA-Z]|\{\{)", re.MULTILINE | re.DOTALL) def conv(match): line = match.group(1) line += match.group(4) line += ", " line += match.group(2) return line line = sys.stdin.read() off = 0 for match in re.finditer(rep, line): sys.stdout.write(line[off:match.start()]) sys.stdout.write(conv(match)) off = match.end() sys.stdout.write(line[off:]) llvm-svn: 232184
* Fix a stack overflow in the assembler when checking that GEPs must be over ↵Owen Anderson2015-03-101-2/+6
| | | | | | | | | sized types. We failed to use a marking set to properly handle recursive types, which caused use to recurse infinitely and eventually overflow the stack. llvm-svn: 231760
* LLParser: gep: Simplify parsing error handlingDavid Blaikie2015-03-091-10/+4
| | | | llvm-svn: 231722
* Fix a bug in the LLParser where we failed to diagnose landingpads with ↵Owen Anderson2015-03-091-6/+7
| | | | | | | | | | non-constant clause operands. Fixing this also exposed a related issue where the landingpad under construction was not cleaned up when an error was raised, which would cause bad reference errors before the error could actually be printed. llvm-svn: 231634
* Revert "unique_ptrify ValID::ConstantStructElts"Reid Kleckner2015-03-041-8/+6
| | | | | | | | | | | | | | | | | | | | | This reverts r231200 and r231204. The second one added an explicit move ctor for MSVC. This change broke the clang-cl self-host due to weirdness in MSVC's implementation of std::map::insert. Somehow we lost our rvalue ref-ness when going through variadic placement new: template <class _Objty, class... _Types> void construct(_Objty *_Ptr, _Types &&... _Args) { // construct _Objty(_Types...) at _Ptr ::new ((void *)_Ptr) _Objty(_STD forward<_Types>(_Args)...); } For some reason, Clang decided to call the deleted std::pair copy constructor at this point. Needs further investigation, once I can build. llvm-svn: 231269
* unique_ptrify ValID::ConstantStructEltsDavid Blaikie2015-03-041-6/+8
| | | | llvm-svn: 231200
* LLParser: Avoid copying ValIDs, the copy ctor is deprecated in C++11 due to ↵David Blaikie2015-03-041-1/+6
| | | | | | the presence of a user-declared dtor llvm-svn: 231199
* Revert "Remove the explicit SDNodeIterator::operator= in favor of the ↵David Blaikie2015-03-031-12/+7
| | | | | | | | | | | implicit default" Accidentally committed a few more of these cleanup changes than intended. Still breaking these out & tidying them up. This reverts commit r231135. llvm-svn: 231136
* Remove the explicit SDNodeIterator::operator= in favor of the implicit defaultDavid Blaikie2015-03-031-7/+12
| | | | | | | | | | There doesn't seem to be any need to assert that iterator assignment is between iterators over the same node - if you want to reuse an iterator variable to iterate another node, that's perfectly acceptable. Just don't mix comparisons between iterators into disjoint sequences, as usual. llvm-svn: 231135
* Cleanup after r230934 per Dave's suggestions.Owen Anderson2015-03-031-3/+4
| | | | llvm-svn: 231056
* Teach the LLParser to fail gracefully when it encounters an invalid label name.Owen Anderson2015-03-021-5/+7
| | | | | | Previous it would either assert in +Asserts, or crash in -Asserts. Found by fuzzing LLParser. llvm-svn: 230935
* Fix a crash in the LL parser where it failed to validate that the pointer ↵Owen Anderson2015-03-021-0/+2
| | | | | | | | operand of a GEP was valid. This manifested as an assertion failure in +Asserts builds, and a hard crash in -Asserts builds. Found by fuzzing the LL parser. llvm-svn: 230934
* Optimize metadata node fields for CHECK-abilityDuncan P. N. Exon Smith2015-02-281-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While gaining practical experience hand-updating CHECK lines (for moving the new debug info hierarchy into place), I learnt a few things about CHECK-ability of the specialized node assembly output. - The first part of a `CHECK:` is to identify the "right" node (this is especially true if you intend to use the new `CHECK-SAME` feature, since the first CHECK needs to identify the node correctly before you can split the line). - If there's a `tag:`, it should go first. - If there's a `name:`, it should go next (followed by the `linkageName:`, if any). - If there's a `scope:`, it should follow after that. - When a node type supports multiple DW_TAGs, but one is implied by its name and is overwhelmingly more common, the `tag:` field is terribly uninteresting unless it's different. - `MDBasicType` is almost always `DW_TAG_base_type`. - `MDTemplateValueParameter` is almost always `DW_TAG_template_value_parameter`. - Printing `name: ""` doesn't improve CHECK-ability, and there are far more nodes than I realized that are commonly nameless. - There are a few other fields that similarly aren't very interesting when they're empty. This commit updates the `AsmWriter` as suggested above (and makes necessary changes in `LLParser` for round-tripping). llvm-svn: 230877
* [opaque pointer type] Add textual IR support for explicit type parameter to ↵David Blaikie2015-02-271-1/+9
| | | | | | | | | | | | | | | | | | | | | | | | load instruction Essentially the same as the GEP change in r230786. A similar migration script can be used to update test cases, though a few more test case improvements/changes were required this time around: (r229269-r229278) import fileinput import sys import re pat = re.compile(r"((?:=|:|^)\s*load (?:atomic )?(?:volatile )?(.*?))(| addrspace\(\d+\) *)\*($| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$)") for line in sys.stdin: sys.stdout.write(re.sub(pat, r"\1, \2\3*\4", line)) Reviewers: rafael, dexonsmith, grosser Differential Revision: http://reviews.llvm.org/D7649 llvm-svn: 230794
* [opaque pointer type] Add textual IR support for explicit type parameter to ↵David Blaikie2015-02-271-1/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | getelementptr instruction One of several parallel first steps to remove the target type of pointers, replacing them with a single opaque pointer type. This adds an explicit type parameter to the gep instruction so that when the first parameter becomes an opaque pointer type, the type to gep through is still available to the instructions. * This doesn't modify gep operators, only instructions (operators will be handled separately) * Textual IR changes only. Bitcode (including upgrade) and changing the in-memory representation will be in separate changes. * geps of vectors are transformed as: getelementptr <4 x float*> %x, ... ->getelementptr float, <4 x float*> %x, ... Then, once the opaque pointer type is introduced, this will ultimately look like: getelementptr float, <4 x ptr> %x with the unambiguous interpretation that it is a vector of pointers to float. * address spaces remain on the pointer, not the type: getelementptr float addrspace(1)* %x ->getelementptr float, float addrspace(1)* %x Then, eventually: getelementptr float, ptr addrspace(1) %x Importantly, the massive amount of test case churn has been automated by same crappy python code. I had to manually update a few test cases that wouldn't fit the script's model (r228970,r229196,r229197,r229198). The python script just massages stdin and writes the result to stdout, I then wrapped that in a shell script to handle replacing files, then using the usual find+xargs to migrate all the files. update.py: import fileinput import sys import re ibrep = re.compile(r"(^.*?[^%\w]getelementptr inbounds )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))") normrep = re.compile( r"(^.*?[^%\w]getelementptr )(((?:<\d* x )?)(.*?)(| addrspace\(\d\)) *\*(|>)(?:$| *(?:%|@|null|undef|blockaddress|getelementptr|addrspacecast|bitcast|inttoptr|\[\[[a-zA-Z]|\{\{).*$))") def conv(match, line): if not match: return line line = match.groups()[0] if len(match.groups()[5]) == 0: line += match.groups()[2] line += match.groups()[3] line += ", " line += match.groups()[1] line += "\n" return line for line in sys.stdin: if line.find("getelementptr ") == line.find("getelementptr inbounds"): if line.find("getelementptr inbounds") != line.find("getelementptr inbounds ("): line = conv(re.match(ibrep, line), line) elif line.find("getelementptr ") != line.find("getelementptr ("): line = conv(re.match(normrep, line), line) sys.stdout.write(line) apply.sh: for name in "$@" do python3 `dirname "$0"`/update.py < "$name" > "$name.tmp" && mv "$name.tmp" "$name" rm -f "$name.tmp" done The actual commands: From llvm/src: find test/ -name *.ll | xargs ./apply.sh From llvm/src/tools/clang: find test/ -name *.mm -o -name *.m -o -name *.cpp -o -name *.c | xargs -I '{}' ../../apply.sh "{}" From llvm/src/tools/polly: find test/ -name *.ll | xargs ./apply.sh After that, check-all (with llvm, clang, clang-tools-extra, lld, compiler-rt, and polly all checked out). The extra 'rm' in the apply.sh script is due to a few files in clang's test suite using interesting unicode stuff that my python script was throwing exceptions on. None of those files needed to be migrated, so it seemed sufficient to ignore those cases. Reviewers: rafael, dexonsmith, grosser Differential Revision: http://reviews.llvm.org/D7636 llvm-svn: 230786
* AsmParser: Check ConstantExpr insertvalue operands for type correctnessDavid Majnemer2015-02-231-1/+8
| | | | llvm-svn: 230206
* AsmParser: Call instructions can't have an alignmentDavid Majnemer2015-02-231-2/+10
| | | | llvm-svn: 230193
* AsmParser: Check ConstantExpr GEP operands for validityDavid Majnemer2015-02-221-2/+24
| | | | llvm-svn: 230188
* AsmParser/Writer: Handle symbolic constants in DI 'flags:'Duncan P. N. Exon Smith2015-02-211-5/+47
| | | | | | | | | | | | | | | | | | | | | | | | | | | Parse (and write) symbolic constants in debug info `flags:` fields. This prevents a readability (and CHECK-ability) regression with the new debug info hierarchy. Old (well, current) assembly, with pretty-printing: !{!"...\\0016387", ...} ; ... [public] [rvalue reference] Flags field without this change: !MDDerivedType(flags: 16387, ...) Flags field with this change: !MDDerivedType(flags: DIFlagPublic | DIFlagRValueReference, ...) As discussed in the review thread, this isn't a final state. Most of these flags correspond to `DW_AT_` symbolic constants, and we might eventually want to support arbitrary attributes in some form. However, as it stands now, some of the flags correspond to other concepts (like `FlagStaticMember`); until things are refactored this is the simplest way to move forward without regressing assembly. llvm-svn: 230111
* IR: Fix MDType fields from unsigned to uint64_tDuncan P. N. Exon Smith2015-02-191-8/+8
| | | | | | | | | When trying to match the current schema with the new debug info hierarchy, I downgraded `SizeInBits`, `AlignInBits` and `OffsetInBits` to 32-bits (oops!). Caught this while testing my upgrade script to move the hierarchy into place. Bump it back up to 64-bits and update tests. llvm-svn: 229933
* IR: Drop scope from MDTemplateParameterDuncan P. N. Exon Smith2015-02-191-10/+6
| | | | | | | | | | 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
* IR: Allow MDSubrange to have 'count: -1'Duncan P. N. Exon Smith2015-02-181-1/+1
| | | | | | | | | | | | | | It turns out that `count: -1` is a special value indicating an empty array, such as `Values` in: struct T { unsigned Count; int Values[]; }; Handle it. llvm-svn: 229769
* IR: Swap order of name and value in MDEnumDuncan P. N. Exon Smith2015-02-181-2/+2
| | | | | | | | | Put the name before the value in assembly for `MDEnum`. While working on the testcase upgrade script for the new hierarchy, I noticed that it "looks nicer" to have the name first, since it lines the names up in the (somewhat typical) case that they have a common prefix. llvm-svn: 229747
* AsmParser: extractvalue requires at least one index operandDavid Majnemer2015-02-161-0/+1
| | | | llvm-svn: 229365
* AsmParser: Make sure GlobalVariables have sane typesDavid Majnemer2015-02-161-1/+1
| | | | llvm-svn: 229364
* AsmParser: Reject alloca with function typeDavid Majnemer2015-02-161-4/+4
| | | | llvm-svn: 229363
* AsmWriter/Bitcode: MDImportedEntityDuncan P. N. Exon Smith2015-02-131-1/+16
| | | | llvm-svn: 229025
* AsmWriter/Bitcode: MDObjCPropertyDuncan P. N. Exon Smith2015-02-131-1/+19
| | | | llvm-svn: 229024
* AsmWriter/Bitcode: MDExpressionDuncan P. N. Exon Smith2015-02-131-1/+36
| | | | llvm-svn: 229023
* AsmWriter/Bitcode: MDLocalVariableDuncan P. N. Exon Smith2015-02-131-1/+22
| | | | llvm-svn: 229022
* AsmWriter/Bitcode: MDGlobalVariableDuncan P. N. Exon Smith2015-02-131-1/+25
| | | | llvm-svn: 229020
* AsmWriter/Bitcode: MDTemplate{Type,Value}ParameterDuncan P. N. Exon Smith2015-02-131-2/+31
| | | | llvm-svn: 229019
* AsmWriter/Bitcode: MDNamespaceDuncan P. N. Exon Smith2015-02-131-1/+14
| | | | llvm-svn: 229018
* AsmWriter/Bitcode: MDLexicalBlockFileDuncan P. N. Exon Smith2015-02-131-1/+13
| | | | llvm-svn: 229017
* AsmWriter/Bitcode: MDLexicalBlockDuncan P. N. Exon Smith2015-02-131-1/+14
| | | | llvm-svn: 229016
* AsmWriter: MDSubprogram: Recognize DW_VIRTUALITY in 'virtuality'Duncan P. N. Exon Smith2015-02-131-2/+25
| | | | llvm-svn: 229015
* AsmWriter/Bitcode: MDSubprogramDuncan P. N. Exon Smith2015-02-131-4/+60
| | | | llvm-svn: 229014
* AsmWriter/Bitcode: MDCompileUnitDuncan P. N. Exon Smith2015-02-131-1/+31
| | | | llvm-svn: 229013
* AsmWriter/Bitcode: MDSubroutineTypeDuncan P. N. Exon Smith2015-02-131-1/+8
| | | | llvm-svn: 229011
* AsmWriter: MDCompositeType: Recognize DW_LANG in 'runtimeLang'Duncan P. N. Exon Smith2015-02-131-1/+41
| | | | llvm-svn: 229010
* AsmWriter/Bitcode: MDDerivedType and MDCompositeTypeDuncan P. N. Exon Smith2015-02-131-2/+51
| | | | llvm-svn: 229009
* AsmWriter/Bitcode: MDFileDuncan P. N. Exon Smith2015-02-131-1/+12
| | | | llvm-svn: 229007
* AsmWriter: MDBasicType: Recognize DW_ATE in 'encoding'Duncan P. N. Exon Smith2015-02-131-1/+23
| | | | llvm-svn: 229006
* AsmWriter/Bitcode: MDBasicTypeDuncan P. N. Exon Smith2015-02-131-1/+15
| | | | llvm-svn: 229005
* AsmWriter/Bitcode: MDEnumeratorDuncan P. N. Exon Smith2015-02-131-1/+11
| | | | llvm-svn: 229004
* AsmWriter/Bitcode: MDSubrangeDuncan P. N. Exon Smith2015-02-131-1/+43
| | | | llvm-svn: 229003
* AsmParser: Validate alloca's typeDavid Majnemer2015-02-111-0/+3
| | | | | | An alloca's type should be weird things like metadata. llvm-svn: 228820
OpenPOWER on IntegriCloud