Things that go in normally come out without requiring medical treatment, but this is not always the case.
There are tons of materials on people's experiences, and there are several images and articles online from ER personnel detailing their encounters with patients who arrived with a variety of objects lodged within their bodies as a result of such sex play.
The ER staff reports that they see this so frequently that no one should be ashamed, and it is critical that something is done immediately before the problem becomes more entrenched.
So, if your dildo gets stuck inside and does not come out after trying muscle contractions and moving about, then you should visit the emergency unit immediately. The ER staff often employ an instrument to enter and extract the object.