This is an archive of the discontinued LLVM Phabricator instance.

[CGVTables] Finalize SP before attempting to clone it
ClosedPublic

Authored by loladiro on May 30 2017, 5:30 PM.

Details

Summary

LLVM commit D33655 was reverted, because it exposed an assertion failure,
in GenerateVarArgsThunk. That function attempts to clone a function
before clang is entirely done generating the debug info for the current
compliation unit. That is not a valid use of the API, because it expects
that there are no temporary MD nodes in the nodes that it needs to clone.
However, until now, this did not cause any problems (though could have
caused assertions in the backend due to mismatched debug info metadata).

Attempt to rectify this by finalizing the SP before attempting to clone it.
The requisite LLVM API is being introduced in D33704.

Diff Detail

Repository
rL LLVM

Event Timeline

loladiro created this revision.May 30 2017, 5:30 PM
loladiro updated this revision to Diff 101092.Jun 1 2017, 1:07 PM

Finalize all subprograms when we're done emitting them.
The one we're interested in is a side effect, but doing
this uniformly might be cleaner and help avoid similar errors in the future.

@aprantl @dblaikie See if you like this better.

dblaikie accepted this revision.Jun 1 2017, 1:11 PM

I guess this would need a cross-project test case (ie: it'd have to run LLVM optimizations to fail/pass/demonstrate the fix). I think it'd be OK to add one if there's a neat/clean/obvious optimization that can be reliably triggered to do the cloning that would assert/crash - please add one if you think that's practical/reasonable.

This revision is now accepted and ready to land.Jun 1 2017, 1:11 PM

There's already such a test case, but the cloning currently doesn't assert properly (but it can generate incorrect code). D33655 fixes that up, so I think the testing is covered once that LLVM commit goes in. I'll hold off a little while to give @aprantl a chance to look at this as well, but I do want to get this in in short order, so I can recommit D33655.

aprantl edited edge metadata.Jun 1 2017, 1:28 PM

Looks good.. Are you also planning to change DIBuilder to not finalize subprograms automatically any more (and not insert them into AllSubprograms)? (That will be the more impactful change as it will force all non-clang frontends to make a similar change).

I don't think that change is entirely necessary. I don't have any strong objections to it, but I also don't see a good reason to require it. In any case, let me get this in to be able to re-land D33655 and we can revisit the more disruptive change later.

This revision was automatically updated to reflect the committed changes.