This is an archive of the discontinued LLVM Phabricator instance.

[DebugInfo] Ensure fallback artificial location is available for cleanups
ClosedPublic

Authored by aprantl on Dec 4 2019, 7:26 PM.

Details

Summary

While finishing a function without a valid end location, fall back to an
artificial debug location when generating IR for cleanups. This fixes a
verifier failure ("inlinable function call without debug info").

rdar://57630879

Diff Detail

Event Timeline

vsk created this revision.Dec 4 2019, 7:26 PM
vsk edited the summary of this revision. (Show Details)Dec 4 2019, 7:35 PM

This will definitely work; Once you got the testcase, it might be good to check whether there is a more targeted root cause that we could fix and assert on EndLoc here.

vsk updated this revision to Diff 232373.Dec 5 2019, 9:53 AM
vsk retitled this revision from WIP: [DebugInfo] Ensure fallback artificial location is available for cleanups to [DebugInfo] Ensure fallback artificial location is available for cleanups.
vsk edited the summary of this revision. (Show Details)

Added a test.

vsk added a comment.Dec 5 2019, 9:56 AM

This will definitely work; Once you got the testcase, it might be good to check whether there is a more targeted root cause that we could fix and assert on EndLoc here.

I believe the root cause is that GenerateObjCSetter does not pass a valid EndLoc, and does not have a 'simple' return statement. That seems reasonable to me, after all FinishFunction() defaults EndLoc to an invalid location, and there is no explicit return statement for an ObjC setter in source.

Do we know why EndLoc is invalid?

clang/test/CodeGenObjCXX/property-object-cleanup.mm
3 ↗(On Diff #232373)

Add a comment

// Test that call in the cleanup block have a valid debug location.

4 ↗(On Diff #232373)

FYI there is __attribute__((objc_root_class)) to silence the warning this causes.

Let me guess.. because setData: is synthesized?

aprantl commandeered this revision.Dec 5 2019, 10:17 AM
aprantl edited reviewers, added: vsk; removed: aprantl.

We looked at this together and it seems the forward declaration for the synthesized setter in the ObjCImplDecl doesn't have a valid source location. I'm going to investigate a more targeted fix.

Principled fix in D71084.

aprantl abandoned this revision.Dec 5 2019, 11:29 AM
aprantl updated this revision to Diff 232431.Dec 5 2019, 12:26 PM

Updated patch to assert a valid EndLoc and actually pass it in.

vsk accepted this revision.Dec 5 2019, 12:31 PM

Thanks, lgtm with a minor change.

clang/lib/CodeGen/CodeGenFunction.cpp
384

The braces around the else block are probably needed in the NDEBUG build.

This revision is now accepted and ready to land.Dec 5 2019, 12:31 PM
vsk added inline comments.Dec 5 2019, 12:32 PM
clang/test/CodeGenObjCXX/synthesized-property-cleanup.mm
17

Heads-up: this location should be different once https://reviews.llvm.org/D71084 lands, which I assume this depends on.

aprantl marked an inline comment as done.Dec 5 2019, 12:44 PM
aprantl added inline comments.
clang/lib/CodeGen/CodeGenFunction.cpp
384

No, this should be fine. The ; is not part of the macro.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptDec 5 2019, 12:47 PM
vsk added a comment.Dec 5 2019, 1:08 PM

This is causing a failure in debuginfo-tests:

http://lab.llvm.org:8080/green/view/LLDB/job/lldb-cmake/4450/testReport/junit/debuginfo-tests/llgdb-tests/block_var_m/

Assertion failed: (EndLoc.isValid() && "no location for inlineable cleanup calls")