aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/IR/BasicBlock.cpp
AgeCommit message (Collapse)AuthorFilesLines
2024-02-27Reapply "[RemoveDIs] Print non-intrinsic debug info in textual IR output ↵Stephen Tozer1-4/+0
(#79281)" This reapplication changes debug intrinsic declaration removal to only take place when printing final IR, so that the processing format of the Module does not affect the output. This reverts commit d128448efdd4e2bf3c9bc9a5b43ae642aa78026f.
2024-02-27Revert "Reapply "[RemoveDIs] Print non-intrinsic debug info in textual IR ↵Stephen Tozer1-0/+4
output (#79281)"" Reverted due to some test failures on some buildbots. https://lab.llvm.org/buildbot/#/builders/67/builds/14669 This reverts commit aa436493ab7ad4cf323b0189c15c59ac9dc293c7.
2024-02-27Reapply "[RemoveDIs] Print non-intrinsic debug info in textual IR output ↵Stephen Tozer1-4/+0
(#79281)" Fixes the prior issue in which the symbol for a cl-arg was unavailable to some binaries. This reverts commit dc06d75ab27b4dcae2940fc386fadd06f70faffe.
2024-02-26Revert "[RemoveDIs] Print non-intrinsic debug info in textual IR output ↵Stephen Tozer1-0/+4
(#79281)" Reverted due to failures on buildbots, where a new cl flag was placed in the wrong file, resulting in link errors. https://lab.llvm.org/buildbot/#/builders/198/builds/8548 This reverts commit 0b398256b3f72204ad1f7c625efe4990204e898a.
2024-02-26[RemoveDIs] Print non-intrinsic debug info in textual IR output (#79281)Stephen Tozer1-4/+0
This patch adds support for printing the proposed non-instruction debug info ("RemoveDIs") out to textual IR. This patch does not add any bitcode support, parsing support, or documentation. Printing of the new format is controlled by a flag added in this patch, `--write-experimental-debuginfo`, which defaults to false. The new format will be printed *iff* this flag is true, so whether we use the IR format is completely independent of whether we use non-instruction debug info during LLVM passes (which is controlled by the `--try-experimental-debuginfo-iterators` flag). Even with the flag disabled, some existing tests need to be updated, as this patch causes debug intrinsic declarations to be changed in a round trip, such that they always appear at the end of a module and have no attributes (this has no functional change on the module). The design of this new IR format was proposed previously on Discourse, and any further discussion about the design can still be contributed there: https://discourse.llvm.org/t/rfc-debuginfo-proposed-changes-to-the-textual-ir-representation-for-debug-values/73491
2024-02-26Reapply [RemoveDIs] Enable DPLabels conversion [3b/3] (#82639)Orlando Cazalet-Hyams1-8/+10
Enables conversion between llvm.dbg.label and DPLabel.
2024-02-23Revert "[RemoveDIs] Enable DPLabels conversion [3b/3] (#82639)"Jorge Gorbe Moya1-10/+8
This reverts commit 71d47a0b00e9f48dc740556d7f452ffadf308731 because it causes clang to crash in some cases. See repro posted at https://github.com/llvm/llvm-project/commit/71d47a0b00e9f48dc740556d7f452ffadf308731
2024-02-23[RemoveDIs] Enable DPLabels conversion [3b/3] (#82639)Orlando Cazalet-Hyams1-8/+10
Enables conversion between llvm.dbg.label and DPLabel.
2024-02-20[RemoveDIs][NFC] Introduce DbgRecord base class [1/3] (#78252)Orlando Cazalet-Hyams1-9/+13
Patch 1 of 3 to add llvm.dbg.label support to the RemoveDIs project. The patch stack adds a new base class -> 1. Add DbgRecord base class for DPValue and the not-yet-added DPLabel class. 2. Add the DPLabel class. 3. Enable dbg.label conversion and add support to passes. Patches 1 and 2 are NFC. In the near future we also will rename DPValue to DbgVariableRecord and DPLabel to DbgLabelRecord, at which point we'll overhaul the function names too. The name DPLabel keeps things consistent for now.
2024-02-14Reapply "[DebugInfo][RemoveDIs] Turn on non-instrinsic debug-info by default"Orlando Cazalet-Hyams1-1/+1
This reapplies commit bdde5f9 by undoing the revert fd3a0c185f17. The previous reapplication d759618df763 was reverted due to a crash (reproducer in comments for d759618df763) which was fixed in #81737. As noted in the original commit, this commit may break downstream tests. If this commit is breaking your downstream tests, please see comment 12 in [0], which documents the kind of variation in tests we'd expect to see from this change and what to do about it. [0] https://discourse.llvm.org/t/rfc-instruction-api-changes-needed-to-eliminate-debug-intrinsics-from-ir/68939
2024-02-13Revert "Reapply "[DebugInfo][RemoveDIs] Turn on non-instrinsic debug-info by ↵Arthur Eubanks1-1/+1
default"" This reverts commit d759618df76361a8e490eeae5c5399e0738cbfd0. Causes crashes, see comments in https://github.com/llvm/llvm-project/commit/d759618df76361a8e490eeae5c5399e0738cbfd0.
2024-02-13Reapply "[DebugInfo][RemoveDIs] Turn on non-instrinsic debug-info by default"OCHyams1-1/+1
This reapplies commit bdde5f9 by undoing the revert bc66e0c. The previous reapplication 5c9f768 was reverted due to a crash (reproducer in comments for 5c9f768) which was fixed in #81595. As noted in the original commit, this commit may break downstream tests. If this commit is breaking your downstream tests, please see comment 12 in [0], which documents the kind of variation in tests we'd expect to see from this change and what to do about it. [0] https://discourse.llvm.org/t/rfc-instruction-api-changes-needed-to-eliminate-debug-intrinsics-from-ir/68939
2024-02-13Revert "Reapply "[DebugInfo][RemoveDIs] Turn on non-instrinsic debug-info by ↵Arthur Eubanks1-1/+1
default"" This reverts commit 5c9f7682b090124d9a8b69f92d3f7c269dca25fc. Causes crashes, see comments on https://github.com/llvm/llvm-project/commit/5c9f7682b090124d9a8b69f92d3f7c269dca25fc.
2024-02-12Reapply "[DebugInfo][RemoveDIs] Turn on non-instrinsic debug-info by default"Stephen Tozer1-1/+1
This reapplies commit bdde5f9bea75e897bcc31a95b9c3376988c211cc. The above commit previously failed due to buildbot errors: https://lab.llvm.org/buildbot/#/builders/205/builds/25126 https://lab.llvm.org/buildbot/#/builders/184/builds/10242 These failures should have been respectively resolved by the commits: afa413a132c0959295df36c28814ee83948e4931 b5a273a1cfe6f509f8d2541e04d9186438f33348 As noted in the original commit, this commit may break downstream tests. If this commit is breaking your downstream tests, please see comment 12 in [0], which documents the kind of variation in tests we'd expect to see from this change and what to do about it. [0] https://discourse.llvm.org/t/rfc-instruction-api-changes-needed-to-eliminate-debug-intrinsics-from-ir/68939
2024-02-08Revert "[DebugInfo][RemoveDIs] Turn on non-instrinsic debug-info by default"Jeremy Morse1-1/+1
This reverts commit bdde5f9bea75e897bcc31a95b9c3376988c211cc. Two situations that are tripping a few buildbots: https://lab.llvm.org/buildbot/#/builders/205/builds/25126 Here, polly is currently presenting a DebugLoc attached to a debugging intrinsic as a "true" source location in a user report, something that's unreliable. https://lab.llvm.org/buildbot/#/builders/184/builds/10242 These HWAsan failures are probably (97% confidence) because in StackInfoBuilder::visit we're not observing DPValues attached to lifetime intrinsics because they're delt with higher up the function. But it's late-o'clock here, so revert for now.
2024-02-08[DebugInfo][RemoveDIs] Turn on non-instrinsic debug-info by defaultJeremy Morse1-1/+1
This patch causes all variable-location debug-info to be converted into non-intrinsic records as they passes through the optimisation / instrumentation passes. There's a brief introduction here [0] and a more detailed thread on what this means on discourse at [1]. If this commit is breaking your downstream tests, please see comment 12 in [1], which documents the kind of variation in tests we'd expect to see from this change and what to do about it. [0] https://llvm.org/docs/RemoveDIsDebugInfo.html [1] https://discourse.llvm.org/t/rfc-instruction-api-changes-needed-to-eliminate-debug-intrinsics-from-ir/68939
2024-02-08[DebugInfo][RemoveDIs] Erase ranges of instructions individually (#81007)Jeremy Morse1-1/+3
The BasicBlock::erase method simply removes a range of instructions from the instlist by unlinking them. However, now that we're attaching debug-info directly to instructions, some cleanup is required, so use eraseFromParent on each instruction instead. This is less efficient, but rare, and seemingly only WASM EH Prepare uses this method of BasicBlock. Detected via a memory leak check in asan. (asan is always the final boss for whatever I do).
2024-02-06[DebugInfo][RemoveDIs] Don't allocate one DPMarker per instruction (#79345)Jeremy Morse1-26/+32
This is an optimisation patch that shouldn't have any functional effect. There's no need for all instructions to have a DPMarker attached to them, because not all instructions have adjacent DPValues (aka dbg.values). This patch inserts the appropriate conditionals into functions like BasicBlock::spliceDebugInfo to ensure we don't step on a null pointer when there isn't a DPMarker allocated. Mostly, this is a case of calling createMarker occasionally, which will create a marker on an instruction if there isn't one there already. Also folded into this is the use of adoptDbgValues, which is a natural extension: if we have a sequence of instructions and debug records: %foo = add i32 %0,... # dbg_value { %foo, ... # dbg_value { %bar, ... %baz = add i32 %... %qux = add i32 %... and delete, for example, the %baz instruction, then the dbg_value records would naturally be transferred onto the %qux instruction (they "fall down" onto it). There's no point in creating and splicing DPMarkers in the case shown when %qux doesn't have a DPMarker already, we can instead just change the owner of %baz's DPMarker from %baz to %qux. This also avoids calling setParent on every DPValue. Update LoopRotationUtils: it was relying on each instruction having it's own distinct end(), so that we could express ranges and lack-of-ranges. That's no longer true though: so switch to storing the range of DPValues on the next instruction when we want to consider it's range next time around the loop (see the nearby comment).
2024-01-26Revert "[DebugInfo][RemoveDIs] Don't pointlessly scan funcs for debug-info ↵Jeremy Morse1-10/+2
(#79327)" This reverts commit c23608b8d58bdeb0134d99168e6d0335da2c8366. It looks like this depends on #79345, which isn't going to land today, so revert for now.
2024-01-26[DebugInfo][RemoveDIs] Don't pointlessly scan funcs for debug-info (#79327)Jeremy Morse1-2/+10
The utility functions this patch modifies are part of cleanly transitioning from a context where we use dbg.value intrinsics to one where we use DPValue objects to record debug-info, and back again. However, this is a waste of time in non-debug builds (i.e. no -g on the command line). We still have to call the function on all blocks though to set the IsNewDbgInfoFormat flag. To reduce the overhead of this, test whether there's any debug-info in the function by checking whether the function has a DISubprogram, and pass a flag down to the utility functions indicating whether they can skip the scan. It feels a bit dumb to me now that we're scanning and setting a flag in a load of blocks when we don't have to -- however it's been really valuable during development for working out where spurious dbg.value intrinsics leak into a RemoveDIs context. Happily we'll be able to just delete this flag entirely when RemoveDIs lands and sticks, and the conversion routines will eventually be pushed down into the debug-info autoupgrade path.
2024-01-23[DebugInfo][RemoveDIs] "Final" cleanup for non-instr debug-info (#79121)Jeremy Morse1-5/+11
Here's a raft of minor fixes for the RemoveDIs project that's replacing dbg.value intrinsics with DPValue objects, all IMO trivial: * When inserting functions or blocks and calling setIsNewDbgInfoFormat, do that after setting the Parent pointer, just in case conversion from (or to) dbg.value mode is triggered. * When transferring DPValues from an empty range in a splice call, don't transfer if there are no DPValues attached to the source block at all. * stripNonLineTableDebugInfo should drop DPValues. * In insertBefore, don't try to transfer DPValues if there aren't any.
2024-01-23[RemoveDIs][DebugInfo] Enable creation of DPVAssigns, update outstanding AT ↵Stephen Tozer1-3/+0
tests (#79148) This is the final patch for DPVAssign support, implementing the actual creation of DPVAssigns and allowing them to be converted along with dbg.values and dbg.declares. Numerous tests landed in previous patches will no longer be rotten after this patch lands (previously they would trivially pass due to DPVAssigns not actually being used), and a further batch of tests have been added here that require the changes in this patch before they pass.
2023-12-13[RemoveDIs] Update Coroutine passes to handle DPValues (#74480)Orlando Cazalet-Hyams1-0/+2
As part of the RemoveDIs project, transitioning to non-instruction debug info, all debug intrinsic handling code needs to be duplicated to handle DPValues. --try-experimental-debuginfo-iterators enables the new debug mode in tests if the CMake option has been enabled. `getInsertPtAfterFramePtr` now returns an iterator so we don't lose debug-info-communicating bits. --- Depends on #73500, #74090, #74091.
2023-12-13[RemoveDIs] Enable conversion from dbg.declare to DPValue (#74090)Orlando Cazalet-Hyams1-1/+4
Note that all the patches that implement support for declare-style DPValues have tests that are "rotten green" test without this patch (i.e., they pass at the moment without testing what we want them to test). See the Pull Request for more detail on this.
2023-12-05[DebugInfo] Follow up to 34cdc91321 to fix a crashJeremy Morse1-1/+1
We're removing trailing debug-records at the correct time, but from the wrong block. Broken the iterators buildbot: https://lab.llvm.org/buildbot/#/builders/275/builds/1889
2023-12-05[DebugInfo][RemoveDIs] Avoid leaking trailing DPMarkers (#74458)Jeremy Morse1-1/+9
In the debug-info-splice implementation, we need to be careful to delete trailing DPMarkers from blocks when we splice their contents out. This is equivalent to removing the terminator from a block, then splicing the rest of it's contents to another block: any DPValues trailing at the end of the block get moved and we need to clean up afterwards.
2023-12-01[DebugInfo][RemoveDIs] Handle a debug-info splicing corner case (#73810)Jeremy Morse1-0/+83
A large amount of complexity when it comes to shuffling DPValue objects around is pushed into BasicBlock::spliceDebugInfo, and it gets comprehensive testing there via the unit tests. It turns out that there's a corner case though: splicing instructions and debug-info to the end() iterator requires blocks of DPValues to be concatenated, but the DPValues don't behave normally as they're dangling at the end of a block. While this splicing-to-an-empty-block case is rare, and it's even rarer for it to contain debug-info, it does happen occasionally. Fix this by wrapping spliceDebugInfo with an outer layer that removes any dangling DPValues in the destination block -- that way the main splicing function (renamed to spliceDebugInfoImpl) doesn't need to worry about that scenario. See the diagram in the added function for more info.
2023-11-30[DebugInfo][RemoveDIs] Support maintaining DPValues in CodeGenPrepare (#73660)Jeremy Morse1-1/+1
CodeGenPrepare needs to support the maintenence of DPValues, the non-instruction replacement for dbg.value intrinsics. This means there are a few functions we need to duplicate or replicate the functionality of: * fixupDbgValue for setting users of sunk addr GEPs, * The remains of placeDbgValues needs a DPValue implementation for sinking * Rollback of RAUWs needs to update DPValues * Rollback of instruction removal needs supporting (see github #73350) * A few places where we have to use iterators rather than instructions. There are three places where we have to use the setHeadBit call on iterators to indicate which portion of debug-info records we're about to splice around. This is because CodeGenPrepare, unlike other optimisation passes, is very much concerned with which block an operation occurs in and where in the block instructions are because it's preparing things to be in a format that's good for SelectionDAG. There isn't a large amount of test coverage for debuginfo behaviours in this pass, hence I've added some more.
2023-11-30[DebugInfo][RemoveDIs] Emulate inserting insts in dbg.value sequences (#73350)Jeremy Morse1-0/+52
Here's a problem for the RemoveDIs project to make debug-info not be stored in instructions -- in the following sequence: dbg.value(foo %bar = add i32 ... dbg.value(baz It's possible for rare passes (only CodeGenPrepare) to remove the add instruction, and then re-insert it back in the same place. When debug-info is stored in instructions and there's a total order on "when" things happen this is easy, but by moving that information out of the instruction stream we start having to do manual maintenance. This patch adds some utilities for re-inserting an instruction into a sequence of DPValue objects. Someday we hope to design this away, but for now it's necessary to support all the things you can do with dbg.values. The two unit tests show how DPValues get shuffled around using the relevant function calls. A follow-up patch adds instrumentation to CodeGenPrepare.
2023-11-24[DebugInfo][RemoveDIs] Allow speculative-DPMarker creationJeremy Morse1-4/+4
There's good justification for having a function specifying "I need there to be a marker here, so return the marker there or create a new one". This was going to come later in the series, but it's starting to become necessary much eariler alas. Make use of it in spliceDebugInfo, where we can occasionally splice DPValues onto the end() iterator of a block while it's been edited.
2023-11-20[DebugInfo][RemoveDIs] Add local-utility plumbing for DPValues (#72276)Jeremy Morse1-2/+3
This patch re-implements a variety of debug-info maintenence functions to use DPValues instead of DbgValueInst's: supporting the "new" non-intrinsic representation of debug-info. As per [0], we need to have parallel implementations of various utilities for a time, and these are the most fundamental utilities used throughout the compiler. I've added --try-experimental-debuginfo-iterators to a variety of RUN lines: this is a flag that turns on "new debug-info" if it's built into LLVM, and not otherwise. This should ensure that we have the same behaviour for the same IR inputs, but using a different internal representation. For the most part these changes affect SROA/Mem2Reg promotion of dbg.declares into dbg.value intrinsics (now DPValues), we're leaving dbg.declares as instructions until later in the day. There's also some salvaging changes made. I believe the tests that I've added cover almost all the code being updated here. The only thing I'm not confident about is SimplifyCFG, which calls rewriteDebugUsers down a variety of code paths. Those changes can't immediately get full coverage as an additional patch is needed that updates handling of Unreachable instructions, will upload that shortly. [0] https://discourse.llvm.org/t/rfc-instruction-api-changes-needed-to-eliminate-debug-intrinsics-from-ir/68939/9
2023-11-09[DebugInfo][RemoveDIs] Add conversion utilities for new-debug-info formatJeremy Morse1-0/+12
This patch plumbs the command line --experimental-debuginfo-iterators flag in to the pass managers, so that modules can be converted to the new format, passes run, then converted back to the old format. That allows developers to test-out the new debuginfo representation across some part of LLVM with no further work, and from the command line. It also installs flag-catchers at the various points that bitcode and textual IR can egress from a process, and temporarily convert the module to dbg.value format when doing so. No tests alas as it's designed to be transparent. Differential Revision: https://reviews.llvm.org/D154372
2023-11-09[DebugInfo][RemoveDIs] Add new behind-the-scenes plumbing for debug-infoJeremy Morse1-12/+268
This is the "central" patch to the removing-debug-intrinsics project: it changes the instruction movement APIs (insert, move, splice) to interpret the "Head" bits we're attaching to BasicBlock::iterators, and updates debug-info records in the background to preserve the ordering of debug-info (which is in DPValue objects instead of dbg.values). The cost is the complexity of this patch, plus memory. The benefit is that LLVM developers can cease thinking about whether they're moving debug-info or not, because it'll happen behind the scenes. All that complexity appears in BasicBlock::spliceDebugInfo, see the diagram there for how we now manually shuffle debug-info around. Each potential splice configuration gets tested in the added unit tests. The rest of this patch applies the same reasoning in a variety of scenarios. When moveBefore (and it's siblings) are used to move instructions around, the caller has to indicate whether they intend for debug-info to move too (is it a "Preserving" call or not), and then the "Head" bits used to determine where debug-info moves to. Similar reasoning is needed for insertBefore. Differential Revision: https://reviews.llvm.org/D154353
2023-11-08Reapply 7d77bbef4ad92, adding new debug-info classesJeremy Morse1-1/+184
This reverts commit 957efa4ce4f0391147cec62746e997226ee2b836. Original commit message below -- in this follow up, I've shifted un-necessary inclusions of DebugProgramInstruction.h into being forward declarations (fixes clang-compile time I hope), and a memory leak in the DebugInfoTest.cpp IR unittests. I also tracked a compile-time regression in D154080, more explanation there, but the result of which is hiding some of the changes behind the EXPERIMENTAL_DEBUGINFO_ITERATORS compile-time flag. This is tested by the "new-debug-iterators" buildbot. [DebugInfo][RemoveDIs] Add prototype storage classes for "new" debug-info This patch adds a variety of classes needed to record variable location debug-info without using the existing intrinsic approach, see the rationale at [0]. The two added files and corresponding unit tests are the majority of the plumbing required for this, but at this point isn't accessible from the rest of LLVM as we need to stage it into the repo gently. An overview is that classes are added for recording variable information attached to Real (TM) instructions, in the form of DPValues and DPMarker objects. The metadata-uses of DPValues is plumbed into the metadata hierachy, and a field added to class Instruction, which are all stimulated in the unit tests. The next few patches in this series add utilities to convert to/from this new debug-info format and add instruction/block utilities to have debug-info automatically updated in the background when various operations occur. This patch was reviewed in Phab in D153990 and D154080, I've squashed them together into this commit as there are dependencies between the two patches, and there's little profit in landing them separately. [0] https://discourse.llvm.org/t/rfc-instruction-api-changes-needed-to-eliminate-debug-intrinsics-from-ir/68939
2023-11-02Revert "[DebugInfo][RemoveDIs] Add prototype storage classes for "new" ↵Jeremy Morse1-183/+1
debug-info" And some intervening fixups. There are two remaining problems: * A memory leak via https://lab.llvm.org/buildbot/#/builders/236/builds/7120/steps/10/logs/stdio * A performance slowdown with -g where I'm not completely sure what the cause it These might be fairly straightforwards to fix, but it's the end of the day hear, so I figure I'll clear the buildbots til tomorrow. This reverts commit 7d77bbef4ad9230f6f427649373fe46a668aa909. This reverts commit 9026f35afe6ffdc5e55b6615efcbd36f25b11558. This reverts commit d97b2b389a0e511c65af6845119eb08b8a2cb473.
2023-11-02[DebugInfo][RemoveDIs] Add prototype storage classes for "new" debug-infoJeremy Morse1-1/+183
This patch adds a variety of classes needed to record variable location debug-info without using the existing intrinsic approach, see the rationale at [0]. The two added files and corresponding unit tests are the majority of the plumbing required for this, but at this point isn't accessible from the rest of LLVM as we need to stage it into the repo gently. An overview is that classes are added for recording variable information attached to Real (TM) instructions, in the form of DPValues and DPMarker objects. The metadata-uses of DPValues is plumbed into the metadata hierachy, and a field added to class Instruction, which are all stimulated in the unit tests. The next few patches in this series add utilities to convert to/from this new debug-info format and add instruction/block utilities to have debug-info automatically updated in the background when various operations occur. This patch was reviewed in Phab in D153990 and D154080, I've squashed them together into this commit as there are dependencies between the two patches, and there's little profit in landing them separately. [0] https://discourse.llvm.org/t/rfc-instruction-api-changes-needed-to-eliminate-debug-intrinsics-from-ir/68939
2023-10-17[ADT][DebugInfo][RemoveDIs] Add extra bits to ilist_iterator for debug-infoJeremy Morse1-2/+13
...behind an experimental CMAKE option that's off by default. This patch adds a new ilist-iterator-like class that can carry two extra bits as well as the usual node pointer. This is part of the project to remove debug-intrinsics from LLVM: see the rationale here [0], they're needed to signal whether a "position" in a BasicBlock includes any debug-info before or after the iterator. This entirely duplicates ilist_iterator, attempting re-use showed it to be a false economy. It's enable-able through the existing ilist_node options interface, hence a few sites where the instruction-list type needs to be updated. The actual main feature, the extra bits in the class, aren't part of the class unless the cmake flag is given: this is because there's a compile-time cost associated with it, and I'd like to get everything in-tree but off-by-default so that we can do proper comparisons. Nothing actually makes use of this yet, but will do soon, see the Phab patch stack. [0] https://discourse.llvm.org/t/rfc-instruction-api-changes-needed-to-eliminate-debug-intrinsics-from-ir/68939 Differential Revision: https://reviews.llvm.org/D153777
2023-09-11[NFC][RemoveDIs] Prefer iterator-insertion over instructionsJeremy Morse1-0/+4
Continuing the patch series to get rid of debug intrinsics [0], instruction insertion needs to be done with iterators rather than instruction pointers, so that we can communicate information in the iterator class. This patch adds an iterator-taking insertBefore method and converts various call sites to take iterators. These are all sites where such debug-info needs to be preserved so that a stage2 clang can be built identically; it's likely that many more will need to be changed in the future. At this stage, this is just changing the spelling of a few operations, which will eventually become signifiant once the debug-info bearing iterator is used. [0] https://discourse.llvm.org/t/rfc-instruction-api-changes-needed-to-eliminate-debug-intrinsics-from-ir/68939 Differential Revision: https://reviews.llvm.org/D152537
2023-08-25[IR] Treat callbr as special terminator (PR64215)Nikita Popov1-2/+3
isLegalToHoistInto() currently return true for callbr instructions. That means that a callbr with one successor will be considered a proper loop preheader, which may result in instructions that use the callbr return value being hoisted past it. Fix this by adding callbr to isExceptionTerminator (with a rename to isSpecialTerminator), which also fixes similar assumptions in other places. Fixes https://github.com/llvm/llvm-project/issues/64215. Differential Revision: https://reviews.llvm.org/D158609
2023-06-16Revert "Revert "InstSimplify: Require instruction be parented""Arthur Eubanks1-3/+2
This reverts commit 0c03f48480f69b854f86d31235425b5cb71ac921. Going to fix forward size regression instead due to more dependent patches needing to be reverted otherwise.
2023-06-16Revert "InstSimplify: Require instruction be parented"Arthur Eubanks1-2/+3
This reverts commit 1536e299e63d7788f38117b0212ca50eb76d7a3b. Causes large binary size regressions, see comments on https://reviews.llvm.org/rG1536e299e63d7788f38117b0212ca50eb76d7a3b.
2023-06-16Revert "Revert "InstSimplify: Require instruction be parented""Alan Zhao1-3/+2
This reverts commit 00264eac4d0938ae8a0826da38e4777be269124c. Reason: caused a bunch of bots to break
2023-06-16Revert "InstSimplify: Require instruction be parented"Alan Zhao1-2/+3
This reverts commit 1536e299e63d7788f38117b0212ca50eb76d7a3b. Reason: causes a regression in the inliner (see https://crbug.com/1454531 and https://reviews.llvm.org/rG1536e299e63d7788f38117b0212ca50eb76d7a3b#1217141)
2023-06-02InstSimplify: Require instruction be parentedMatt Arsenault1-3/+2
Unlike every other analysis and transform, simplifyInstruction permitted operating on instructions which are not inserted into a function. This created an edge case no other code needs to really worry about, and limited transforms in cases that can make use of the context function. Only the inliner and a handful of other utilities were making use of this, so just fix up these edge cases. Results in some IR ordering differences since cloned blocks are inserted eagerly now. Plus some additional simplifications trigger (e.g. some add 0s now folded out that previously didn't).
2023-03-29Reland "[Windows SEH]: HARDWARE EXCEPTION HANDLING (MSVC -EHa) - Part 2"Phoebe Wang1-0/+9
This reverts commit db6a979ae82410e42430e47afa488936ba8e3025. Reland D102817 without any change. The previous revert was a mistake. Differential Revision: https://reviews.llvm.org/D102817
2022-12-15[NFC] Rename Function::insertBasicBlockAt() to Function::insert().Vasileios Porpodas1-2/+2
I think this is a better name because it is what STL uses. Differential Revision: https://reviews.llvm.org/D140068
2022-12-14[NFC] Cleanup: Replace Function::getBasicBlockList().splice() with ↵Vasileios Porpodas1-5/+4
Function::splice() This is part of a series of patches that aim at making Function::getBasicBlockList() private. Differential Revision: https://reviews.llvm.org/D139984
2022-12-14[NFC] Cleanup: BasicBlock::getInstList() and BasicBlock::getSublistAccess() ↵Vasileios Porpodas1-1/+1
are now private We now have an adequate set of API functions, including BasicBlock::splice(), BasicBlock::erase(), Instruction::insertAt() etc. that we shouldn't need access to the underlying instruction list. Differential Revision: https://reviews.llvm.org/D139905
2022-12-12[IR][NFC] Adds Function::insertBasicBlockAt() to replace things like ↵Vasileios Porpodas1-2/+2
F->getBasicBlockList().insert() This is part of a series of patches that aim at making Function::getBasicBlockList() private. Differential Revision: https://reviews.llvm.org/D139906
2022-12-05[IR] llvm::Optional => std::optionalFangrui Song1-2/+2
Many llvm/IR/* files have been migrated by other contributors. This migrates most remaining files.