Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RemoveDIs] Enable conversion from dbg.declare to DPValue #74090

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

OCHyams
Copy link
Contributor

@OCHyams OCHyams commented Dec 1, 2023

The testing situation here is a little bit difficult. Most of the dbg.declare support patches depend on this patch to be able to test them. However, landing this patch first would result in ~10-15 test failures in tests that already --try-experimental-debuginfo-iterators that contain both dbg.values (already fully supported and being tested) and dbg.declares (support in flight: shouldn't really be tested yet - those updates would come as support is added to each pass etc, as we did with dbg.values, if that were possible).

Options:

  1. Land this patch first. Remove --try-experimental-debuginfo-iterators from those failing tests in this patch, re-add as those passes get dbg.declare support/fixes.
  2. Land this patch last. All the dbg.declare-support patches get test updates... but are rotten-green-tests until this patch lands (because the DPValue "declare" path isn't hit without this patch).
  3. Squash all the dbg.declare support patches together.

Any strong opinions on the options above? I have listed them in order of personal preference (1 being most preferred), but am happy to go with any as they all have pros & cons.

@llvmbot
Copy link
Collaborator

llvmbot commented Dec 1, 2023

@llvm/pr-subscribers-llvm-ir

Author: Orlando Cazalet-Hyams (OCHyams)

Changes

The testing situation here is a little bit difficult. Most of the dbg.declare support patches depend on this patch to be able to test them. However, landing this patch first would result in ~10-15 test failures in tests that already --try-experimental-debuginfo-iterators that contain both dbg.values (already fully supported and being tested) and dbg.declares (support in flight: shouldn't really be tested yet - those updates would come as support is added to each pass etc, as we did with dbg.values, if that were possible).

Options:

  1. Land this patch first. Remove --try-experimental-debuginfo-iterators from those failing tests in this patch, re-add as those passes get dbg.declare support/fixes.
  2. Land this patch last. All the dbg.declare-support patches get test updates... but are rotten-green-tests until this patch lands (because the DPValue "declare" path isn't hit without this patch).
  3. Squash all the dbg.declare support patches together.

Any strong opinions on the options above? I have listed them in order of personal preference (1 being most preferred), but am happy to go with any as they all have pros & cons.


Full diff: https://github.com/llvm/llvm-project/pull/74090.diff

1 Files Affected:

  • (modified) llvm/lib/IR/BasicBlock.cpp (+4-1)
diff --git a/llvm/lib/IR/BasicBlock.cpp b/llvm/lib/IR/BasicBlock.cpp
index 0a8fddbe102538d..eefa46a581f6185 100644
--- a/llvm/lib/IR/BasicBlock.cpp
+++ b/llvm/lib/IR/BasicBlock.cpp
@@ -73,7 +73,10 @@ void BasicBlock::convertToNewDbgValues() {
   SmallVector<DPValue *, 4> DPVals;
   for (Instruction &I : make_early_inc_range(InstList)) {
     assert(!I.DbgMarker && "DbgMarker already set on old-format instrs?");
-    if (DbgValueInst *DVI = dyn_cast<DbgValueInst>(&I)) {
+    if (DbgVariableIntrinsic *DVI = dyn_cast<DbgVariableIntrinsic>(&I)) {
+      if (isa<DbgAssignIntrinsic>(DVI))
+        continue;
+
       // Convert this dbg.value to a DPValue.
       DPValue *Value = new DPValue(DVI);
       DPVals.push_back(Value);

Copy link
Member

@jmorse jmorse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall idea LGTM. In terms of landing things, we've made a mess by having this partial overlapping coverage sadly, so there'll need to be some kind of gap for some period.

An additional constraint however is that there /might/ now be people testing this code, seeing how we've announced testing, and if we land the dbg-declare-conversion code up front, there might be some spurious differences / crashes / whatever in the meantime. I'd prefer option 2 to avoid punishing anyone who's kind enough to test for us.

(Or add another command line flag that lasts two days and turns on dbg-declare conversion? All bad options sorry).

OCHyams added a commit that referenced this pull request Dec 12, 2023
This is a boring mechanical update to support DPValues that look like
dbg.declares in SelectionDAG.

The tests will become "live" once #74090 lands (see for more info).
OCHyams added a commit that referenced this pull request Dec 12, 2023
The tests will become "live" once #74090 lands (see for more info).
OCHyams added a commit that referenced this pull request Dec 12, 2023
)

The intrinsic variants of these functions don't do anything to
dbg.declares so the non-instruction variants should ignore them too.

Tested in llvm/test/DebugInfo/duplicate_dbgvalue.ll, which has
`--try-experimental-debuginfo-iterators` added in #73504.

The tests will become "live" once #74090 lands (see for more info).
OCHyams added a commit that referenced this pull request Dec 12, 2023
That patch was missing a recent change to the non-DPValue StoreInst overload.
Add it to the DPValue version. This is tested by
`llvm/tests/Transforms/Mem2Reg/dbg_declare_to_value_conversions.ll`,
which already has `--try-experimental-debuginfo-iterators`. It doesn't
fail currently because until #74090 lands the declares are not converted
to DPValues.

The tests will become "live" once #74090 lands (see for more info).
OCHyams added a commit that referenced this pull request Dec 12, 2023
The tests will become "live" once #74090 lands (see for more info).
OCHyams added a commit that referenced this pull request Dec 12, 2023
Handle dbg.declares in SROA using DPValues.

In order to reduce duplication, the migrate-debug-info loop has been changed
to a generic lambda with some helper function overloads, which is called
for dbg.declares, dbg.assigns, and DPValues alike.

The tests will become "live" once #74090 lands (see for more info).
@OCHyams
Copy link
Contributor Author

OCHyams commented Dec 12, 2023

I've gone with option 2 as you've suggested. That makes it easy to temporarily disable this "capstone" patch as a fix-call too if problems are found.

@OCHyams OCHyams merged commit bdbc2db into llvm:main Dec 13, 2023
4 checks passed
OCHyams added a commit that referenced this pull request Dec 13, 2023
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.
Guzhu-AMD pushed a commit to GPUOpen-Drivers/llvm-project that referenced this pull request Dec 15, 2023
…gfx:ac9bf99e79f1

Local branch amd-gfx ac9bf99 Merged main:ef112833e11e94ea049f98bec4a29b4fe96a25dd into amd-gfx:d621799ca22b
Remote branch main bdbc2db [RemoveDIs] Enable conversion from dbg.declare to DPValue (llvm#74090)

Change-Id: Ic1c577a48c31052c9e44ce3733adc8b71a132127
@OCHyams OCHyams deleted the ddd/enable-declares branch January 5, 2024 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants