As someone with a similar history of violent coughing, I would strongly recommend that you see an allergist and be evaluated for both allergies and
asthma. Also, the old saying, "If it hurts, stop it" should be followed. Don't force the phlegm up to the point that you see the blood, but if you have to cough hard and it comes up that is another story. You have to get the gunk up some how.
Also, my GP automatically puts me on antibiotic when I am coughing up blood.