This is an archive of the discontinued LLVM Phabricator instance.

In SPIR functions validate the llvm.dbg.declare intrinsics for locals and parameters refer to stack allocation in the alloca address space.
ClosedPublic

Authored by zahiraam on Nov 1 2021, 2:24 PM.

Details

Diff Detail

Event Timeline

zahiraam requested review of this revision.Nov 1 2021, 2:24 PM
zahiraam created this revision.
erichkeane added inline comments.
clang/lib/CodeGen/CGDecl.cpp
1617

I don't believe this is the correct answer here. I think we need to store the AllocaAddress out of the CreateTempAlloca call we do in the NRVO case above. In the other cases, the AllocaAddr and the DebugAddr should be the same, so there is no need to strip casts.

You probably want to do it more like how the below function is done, the AllocaAddr variable is already there, it just isn't set on every branch.

zahiraam updated this revision to Diff 384197.Nov 2 2021, 1:09 PM
zahiraam marked an inline comment as done.
zahiraam updated this revision to Diff 384201.Nov 2 2021, 1:12 PM
erichkeane added inline comments.Nov 2 2021, 1:19 PM
clang/lib/CodeGen/CGDecl.cpp
1617

I don't believe this is correct either, AllocaAddr is set in a couple of cases. There are two options I see here as potential:
1- make sure AllocaAddr is always updated to the correct thing in each of the above branches.
2- Only use DebugAddr when allocaAddr is not set.

But doing it off of the logic from above (in this case, the incorrect logic, but logic from above all the same) is too fragile.

zahiraam updated this revision to Diff 384212.Nov 2 2021, 1:44 PM
zahiraam marked an inline comment as done.
zahiraam added inline comments.
clang/lib/CodeGen/CGDecl.cpp
1617

I opted for option 2, mostly because I am not sure what should the value of AllocaAddr be in case NRVO is true. I see that AllocaAddr is calculated from the CreateTempAlloc function for the other case.

erichkeane added inline comments.Nov 2 2021, 1:51 PM
clang/lib/CodeGen/CGDecl.cpp
1508–1509

I suspect in the N RVO case we want the AllocAddr from the optional 5th parameter here.

zahiraam added inline comments.Nov 2 2021, 1:59 PM
clang/lib/CodeGen/CGDecl.cpp
1508–1509

Yes I saw that, but even that call is under a condition that in some OpenMP test case is not satisfied and I wind up with an AllocAddr invalid!

erichkeane added inline comments.Nov 2 2021, 2:03 PM
clang/lib/CodeGen/CGDecl.cpp
1436

I think there are a couple of places this needs to be set in order to be 'correct', I'll comment below:

1449–1450

Probably should be the same as address here.

1495–1496

For the 'else' cases to all the below 'ifs', it is the same as address here too.

1508–1509

Should be the last param here as said above.

1612

This is the last case, if it pops into this UsePointerValue, we should do the same as DebugAddr here.

zahiraam updated this revision to Diff 384234.Nov 2 2021, 2:30 PM
zahiraam marked 4 inline comments as done.
erichkeane added inline comments.Nov 3 2021, 6:14 AM
clang/lib/CodeGen/CGDecl.cpp
1517

This looks wrong, it looks like it overwrites the value put in on 1507, doesn't it? Should you put this on 1496 so that it gets overwritten by the CreateTempAlloc instead of the reverse?

1612

Missed this one, which might be why you were tempted to have the NRVO case wrong above.

zahiraam updated this revision to Diff 384437.Nov 3 2021, 7:52 AM
zahiraam marked 3 inline comments as done.
erichkeane accepted this revision.Nov 3 2021, 7:55 AM
erichkeane added a subscriber: bader.

I'm OK with this, but think that @rjmccall or @bader should have a chance to comment. So please don't commit for 48 hrs.

This revision is now accepted and ready to land.Nov 3 2021, 7:55 AM