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
Assertion `OpN.isUniqued() && "Only uniqued operands cannot be mapped immediately"' failed. #33277
Comments
assigned to @wolfy1961 |
Repros on 5.0 too. |
+Adrian: This seems like an area you are familiar with? |
Seems to only crash when the target platform is linux. |
I bisected this down to [FORWARD] [llvm] [mirror/master to master] Reapply "[Cloning] Take another pass at properly cloning debug info" This was rL304226, reverted in 304228 due to a clang assertion failure git-original-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@304488 |
r304228 is strict about not cloning temporary MD nodes. In the test case the code that creates the thunk for the varargs function does this by calling CloneFunction(), which also clones the metadata. Prior to this the vtable emission code created a temporary DI MD node to refer to the baseclass "Charlie" while it's completing all the classes. This is the one the cloning code trips over. Without varargs thunks this does not happen because there is no cloning. The temporary MD nodes are not replaced with uniqued or distinct ones until much later by DebugInfo::finalize(), so you basically can't clone metadata before this happens. Looks like not so much a direct issue with r304228 but a problem with sequencing between temporary MD node fixup and emission of deferred items, though the varargs thunks may be an anomaly because they are created by cloning the original function. A naive fix may be to just replace all the temporary MD nodes before we emit any deferred items. |
Thanks for the analysis! Sounds like whatever fix we implement will be in DIBuilder or CGDebugInfo then. If it is a safe thing to do then resolve all temporary nodes before cloning, seems reasonable to me. |
Is there any chance this can be fixed for 5.0.0? |
Wolfgang implemented a patch in CGDebugInfo for our release but he didn't |
Sounds like a good idea. Adrian, could you take a look at the patch if Paul posts it? |
Sorry, should have mentioned here that I posted it and Adrian had some |
Unblocking, since it seems this isn't getting fixed in time for 5.0.0. |
Depending on the circumstances, you might also see another assertion: Assertion `FirstN.isUniqued() && "Expected uniqued node"' failed. I had posted a patch by Wolfgang Pieb in https://reviews.llvm.org/D37038 |
*** Bug llvm/llvm-bugzilla-archive#34534 has been marked as a duplicate of this bug. *** |
After some futile attempts it seems that any attempt to resolve temporary It seems that cloning a function before all the metadata has been I think the cleanest solution would be to simply delay the generation |
Fixed with r317047 (cfe). Requires r317018 (llvm). See a detailed description in https://reviews.llvm.org/D39396. |
mentioned in issue #33840 |
mentioned in issue llvm/llvm-bugzilla-archive#34534 |
Extended Description
Crashes with trunk r308954. Okay with 4.0, haven't tried 5.0.
$ cat bz181281.cpp
struct Alpha {
virtual void bravo(...);
};
struct Charlie {
virtual ~Charlie() {}
};
struct CharlieImpl : Charlie, Alpha {
void bravo(...) {}
} delta;
$ clang -c -g bz181281.cpp
clang-5.0: /home/probinson/projects/llvm-org/trunk/llvm/lib/Transforms/Utils/ValueMapper.cpp:640: llvm::MDNode* {anonymous}::MDNodeMapper::visitOperands({anonymous}::MDNodeMapper::UniquedGraph&, const llvm::MDOperand*&, llvm::MDNode::op_iterator, bool&): Assertion `OpN.isUniqued() && "Only uniqued operands cannot be mapped immediately"' failed.
The text was updated successfully, but these errors were encountered: