*Spoilers* The Butthole was not a Plothole
"David" remarked to Adam that he didn't have a, um, butthole and this made the ending look like a trainwreck of a plothole at first. Then I reviewed the dialogue. "David" didn't know he was an android and it seems the great question of ethics in this movie was how "David" was manipulated and abused by his creator.
This is why "Adam" retorted to "David" rather cryptically "I know about secrets".
If he had be referring to Joy and it had been a simple ruse of David and Adam pretending to be each other it would not have fit and we would expect "David" to have had a very different reaction. Similar if "David" had known the actual situation he would have told "Adam" that his acting sucked rather than discus emergent behavior with Joy over "Adam's" displays of emotion.
If "David" had known he was an android with metal bones, he definitely would not have been afraid of "Adam". If David had known he was hooked up to the house's wifi circuit and would "die" without it, he would never have followed Joy as they tried to leave the house nor looked so shocked when he heard 'the scratching' sound as his connection ended.
The real David was very broken; when he tried to enter the bathroom when Joy was in it, for example and the eye which let him watch her from the house, he had a high ick factor. Using David to impregnant Joy naturally follows and if you can build an artificial human, keeping semen viable doesn't seem like a stretch. It was one of those pseudo-rape moments unique to sci fi but in itself mirrors how "David" was also treated.