summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/AsmWriter.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Internalize llvm::AssemblyWriter. It's not used outside of AsmWriter.cpp.Benjamin Kramer2015-03-171-7/+86
| | | | | | | This is an artifact of an implementation detail of DebugIR that has been long refactored away. NFC. llvm-svn: 232532
* AsmWriter: Handle broken metadata nodesDuncan P. N. Exon Smith2015-03-161-2/+2
| | | | | | | Print out temporary `MDNode`s so we don't crash in the verifier (or during `dump()` output). llvm-svn: 232417
* IR: Default the Metadata::dump() argument "harder" after r232275Duncan P. N. Exon Smith2015-03-151-0/+3
| | | | | | | | | | Use an overload instead of a default argument for `Metadata::dump()`. The latter seems to require calling `dump(nullptr)` explicitly when using a debugger, where as the former doesn't. Other than utility for debugging, there's NFC here. llvm-svn: 232315
* IR: Make Metadata::print() reliable and usefulDuncan P. N. Exon Smith2015-03-141-33/+85
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Replumb the `AsmWriter` so that `Metadata::print()` is generally useful. (Similarly change `Metadata::printAsOperand()`.) - `SlotTracker` now has a mode where all metadata will be correctly numbered when initializing a `Module`. Normally, `Metadata` only referenced from within `Function`s gets numbered when the `Function` is incorporated. - `Metadata::print()` and `Metadata::printAsOperand()` (and `Metadata::dump()`) now take an optional `Module` argument. When provided, `SlotTracker` is initialized with the new mode, and the numbering will be complete and consistent for all calls to `print()`. - `Value::print()` uses the new `SlotTracker` mode when printing intrinsics with `MDNode` operands, `MetadataAsValue` operands, or the bodies of functions. Thus, metadata numbering will be consistent between calls to `Metadata::print()` and `Value::print()`. - `Metadata::print()` (and `Metadata::dump()`) now print the full definition of `MDNode`s: !5 = !{!6, !"abc", !7} This matches behaviour for `Value::print()`, which includes the name of instructions. - Updated call sites in `Verifier` to call `print()` instead of `printAsOperand()`. All this, so that `Verifier` can print out useful failure messages that involve `Metadata` for PR22777. Note that `Metadata::printAsOperand()` previously took an optional `bool` and `Module` operand. The former was cargo-culted from `Value::printAsOperand()` and wasn't doing anything useful. The latter didn't give consistent results (without the new `SlotTracker` mode). llvm-svn: 232275
* AsmWriter: Split out SlotTracker::processInstructionMetadata(), NFCDuncan P. N. Exon Smith2015-03-141-18/+24
| | | | llvm-svn: 232273
* AsmWriter: Use range-based for, NFCDuncan P. N. Exon Smith2015-03-141-15/+13
| | | | llvm-svn: 232272
* AsmWriter: Write alloca array size explicitly (and -instcombine fixup)Duncan P. N. Exon Smith2015-03-131-1/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Write the `alloca` array size explicitly when it's non-canonical. Previously, if the array size was `iX 1` (where X is not 32), the type would mutate to `i32` when round-tripping through assembly. The testcase I added fails in `verify-uselistorder` (as well as `FileCheck`), since the use-lists for `i32 1` and `i64 1` change. (Manman Ren came across this when running `verify-uselistorder` on some non-trivial, optimized code as part of PR5680.) The type mutation started with r104911, which allowed array sizes to be something other than an `i32`. Starting with r204945, we "canonicalized" to `i64` on 64-bit platforms -- and then on every round-trip through assembly, mutated back to `i32`. I bundled a fixup for `-instcombine` to avoid r204945 on scalar allocations. (There wasn't a clean way to sequence this into two commits, since the assembly change on its own caused testcase churn, and the `-instcombine` change can't be tested without the assembly changes.) An obvious alternative fix -- change `AllocaInst::AllocaInst()`, `AsmWriter` and `LLParser` to treat `intptr_t` as the canonical type for scalar allocations -- was rejected out of hand, since this required teaching them each about the data layout. A follow-up commit will add an `-instcombine` to canonicalize the scalar allocation array size to `i32 1` rather than leaving `iX 1` alone. rdar://problem/20075773 llvm-svn: 232200
* [opaque pointer type] Add textual IR support for explicit type parameter to ↵David Blaikie2015-03-131-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Teach raw_ostream to accept SmallString.Yaron Keren2015-03-101-1/+1
| | | | | | | | | | | | | | Saves adding .str() call to any raw_ostream << SmallString usage and a small step towards making .str() consistent in the ADTs by removing one of the SmallString::str() use cases, discussion at http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20141013/240026.html I'll update the Phabricator patch http://reviews.llvm.org/D6372 for review of the Twine SmallString support, it's more complex than this one. llvm-svn: 231763
* DebugInfo: Move new hierarchy into placeDuncan P. N. Exon Smith2015-03-031-24/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Move the specialized metadata nodes for the new debug info hierarchy into place, finishing off PR22464. I've done bootstraps (and all that) and I'm confident this commit is NFC as far as DWARF output is concerned. Let me know if I'm wrong :). The code changes are fairly mechanical: - Bumped the "Debug Info Version". - `DIBuilder` now creates the appropriate subclass of `MDNode`. - Subclasses of DIDescriptor now expect to hold their "MD" counterparts (e.g., `DIBasicType` expects `MDBasicType`). - Deleted a ton of dead code in `AsmWriter.cpp` and `DebugInfo.cpp` for printing comments. - Big update to LangRef to describe the nodes in the new hierarchy. Feel free to make it better. Testcase changes are enormous. There's an accompanying clang commit on its way. If you have out-of-tree debug info testcases, I just broke your build. - `upgrade-specialized-nodes.sh` is attached to PR22564. I used it to update all the IR testcases. - Unfortunately I failed to find way to script the updates to CHECK lines, so I updated all of these by hand. This was fairly painful, since the old CHECKs are difficult to reason about. That's one of the benefits of the new hierarchy. This work isn't quite finished, BTW. The `DIDescriptor` subclasses are almost empty wrappers, but not quite: they still have loose casting checks (see the `RETURN_FROM_RAW()` macro). Once they're completely gutted, I'll rename the "MD" classes to "DI" and kill the wrappers. I also expect to make a few schema changes now that it's easier to reason about everything. llvm-svn: 231082
* AsmWriter: Only print one space after the load typeBenjamin Kramer2015-03-021-1/+1
| | | | | | | | | Before: %x = load i32, i32* %i After: %x = load i32, i32* %i Purely cosmetic, so no new test case. llvm-svn: 230966
* Optimize metadata node fields for CHECK-abilityDuncan P. N. Exon Smith2015-02-281-24/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* AsmWriter: Escape string fields in metadataDuncan P. N. Exon Smith2015-02-281-34/+24
| | | | | | | | | | | | | Properly escape string fields in metadata. I've added a spot-check with direct coverage for `MDFile::getFilename()`, but we'll get more coverage once the hierarchy is moved into place (since this comes up in various checked-in testcases). I've replicated the `if` logic using the `ShouldSkipEmpty` flag (although a follow-up commit is going to change how often this flag is specified); no NFCI other than escaping the string fields. llvm-svn: 230875
* AsmWriter: Extract writeStringField(), NFCIDuncan P. N. Exon Smith2015-02-281-5/+12
| | | | | | | | Extract logic for escaping a string field in the new debug info hierarchy from `GenericDebugNode`. A follow-up commit will use it far more widely (hence the dead code for `ShouldSkipEmpty`). llvm-svn: 230873
* [opaque pointer type] Add textual IR support for explicit type parameter to ↵David Blaikie2015-02-271-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | 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-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* IR: Drop newline from AssemblyWriter::printMDNodeBody()Duncan P. N. Exon Smith2015-02-251-1/+1
| | | | | | | | | | | Remove a newline from `AssemblyWriter::printMDNodeBody()`, and add one to `AssemblyWriter::writeMDNode()`. NFCI for assembly output. However, this drops an inconsistent newline from `Metadata::print()` when `this` is an `MDNode`. Now the newline added by `Metadata::dump()` won't look so verbose. llvm-svn: 230565
* IR: Annotate dump methods with LLVM_DUMP_METHODDuncan P. N. Exon Smith2015-02-251-0/+6
| | | | | | | | | It turns out we have a macro to ensure that debuggers can access `dump()` methods. Use it. Hopefully this will prevent me (and others) from committing crimes like in r223802 (search for /10000/, or just see the fix in r224407). llvm-svn: 230555
* AsmParser/Writer: Handle symbolic constants in DI 'flags:'Duncan P. N. Exon Smith2015-02-211-12/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Bitcode: Stop assuming non-null fieldsDuncan P. N. Exon Smith2015-02-201-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* IR: Drop scope from MDTemplateParameterDuncan P. N. Exon Smith2015-02-191-4/+0
| | | | | | | | | | 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: Swap order of name and value in MDEnumDuncan P. N. Exon Smith2015-02-181-1/+1
| | | | | | | | | 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
* Removing LLVM_DELETED_FUNCTION, as MSVC 2012 was the last reason for ↵Aaron Ballman2015-02-151-2/+2
| | | | | | requiring the macro. NFC; LLVM edition. llvm-svn: 229340
* AsmWriter/Bitcode: MDImportedEntityDuncan P. N. Exon Smith2015-02-131-4/+17
| | | | llvm-svn: 229025
* AsmWriter/Bitcode: MDObjCPropertyDuncan P. N. Exon Smith2015-02-131-3/+24
| | | | llvm-svn: 229024
* AsmWriter/Bitcode: MDExpressionDuncan P. N. Exon Smith2015-02-131-3/+20
| | | | llvm-svn: 229023
* AsmWriter/Bitcode: MDLocalVariableDuncan P. N. Exon Smith2015-02-131-4/+32
| | | | llvm-svn: 229022
* AsmWriter/Bitcode: MDGlobalVariableDuncan P. N. Exon Smith2015-02-131-4/+36
| | | | llvm-svn: 229020
* AsmWriter/Bitcode: MDTemplate{Type,Value}ParameterDuncan P. N. Exon Smith2015-02-131-10/+31
| | | | llvm-svn: 229019
* AsmWriter/Bitcode: MDNamespaceDuncan P. N. Exon Smith2015-02-131-3/+17
| | | | llvm-svn: 229018
* AsmWriter/Bitcode: MDLexicalBlockFileDuncan P. N. Exon Smith2015-02-131-4/+17
| | | | llvm-svn: 229017
* AsmWriter/Bitcode: MDLexicalBlockDuncan P. N. Exon Smith2015-02-131-3/+18
| | | | llvm-svn: 229016
* AsmWriter: MDSubprogram: Recognize DW_VIRTUALITY in 'virtuality'Duncan P. N. Exon Smith2015-02-131-2/+7
| | | | llvm-svn: 229015
* AsmWriter/Bitcode: MDSubprogramDuncan P. N. Exon Smith2015-02-131-3/+60
| | | | llvm-svn: 229014
* AsmWriter/Bitcode: MDCompileUnitDuncan P. N. Exon Smith2015-02-131-3/+51
| | | | llvm-svn: 229013
* AsmWriter/Bitcode: MDSubroutineTypeDuncan P. N. Exon Smith2015-02-131-4/+10
| | | | llvm-svn: 229011
* AsmWriter: MDCompositeType: Recognize DW_LANG in 'runtimeLang'Duncan P. N. Exon Smith2015-02-131-2/+8
| | | | llvm-svn: 229010
* AsmWriter/Bitcode: MDDerivedType and MDCompositeTypeDuncan P. N. Exon Smith2015-02-131-7/+89
| | | | llvm-svn: 229009
* AsmWriter/Bitcode: MDFileDuncan P. N. Exon Smith2015-02-131-2/+8
| | | | llvm-svn: 229007
* AsmWriter: MDBasicType: Recognize DW_ATE in 'encoding'Duncan P. N. Exon Smith2015-02-131-2/+7
| | | | llvm-svn: 229006
* AsmWriter/Bitcode: MDBasicTypeDuncan P. N. Exon Smith2015-02-131-3/+15
| | | | llvm-svn: 229005
* AsmWriter/Bitcode: MDEnumeratorDuncan P. N. Exon Smith2015-02-131-2/+7
| | | | llvm-svn: 229004
* AsmWriter/Bitcode: MDSubrangeDuncan P. N. Exon Smith2015-02-131-3/+9
| | | | llvm-svn: 229003
* IR: Add specialized debug info metadata nodesDuncan P. N. Exon Smith2015-02-101-0/+87
| | | | | | | | | | | | | | | 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
* AsmWriter: Extract writeTag(), NFCDuncan P. N. Exon Smith2015-02-061-5/+9
| | | | llvm-svn: 228447
* AsmWriter: Extract writeMetadataAsOperand(), NFCDuncan P. N. Exon Smith2015-02-061-5/+12
| | | | llvm-svn: 228446
* AsmParser: Recognize DW_TAG_* constantsDuncan P. N. Exon Smith2015-02-031-2/+5
| | | | | | | Recognize `DW_TAG_` constants in assembly, and output it by default for `GenericDebugNode`. llvm-svn: 228042
* IR: Assembly and bitcode for GenericDebugNodeDuncan P. N. Exon Smith2015-02-031-4/+26
| | | | llvm-svn: 228041
* IR: DwarfNode => DebugNode, NFCDuncan P. N. Exon Smith2015-01-221-1/+1
| | | | | | | | | 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. llvm-svn: 226874
* IR: Introduce GenericDwarfNodeDuncan P. N. Exon Smith2015-01-201-0/+6
| | | | | | | | | | | | As part of PR22235, introduce `DwarfNode` and `GenericDwarfNode`. The former is a metadata node with a DWARF tag. The latter matches our current (generic) schema of a header with string (and stringified integer) data and an arbitrary number of operands. This doesn't move it into place yet; that change will require a large number of testcase updates. llvm-svn: 226529
OpenPOWER on IntegriCloud