This depends on the government, the nature of the coup, and why the inmates were imprisoned. This is a popular type of question about Nazi Germany.
/u/commiespaceinvader has previously answered Did the Allies set free criminals when they liberated the concentration camps in WW2?
/u/IdenPoelchau has previously answered How much legal continuity exists between pre and post ww2 Germany?
Commiespaceinvader and /u/Kugelfang52 have previously answered How were homosexual concentration camp survivors treated by the Allied Powers?