Compartmentalize your company. Make sure people from one compartment are unaware about things people from other compartments are doing. Don't transfer/hire across compartment boundaries.
I will grant you, the specific case of TSMC is definitely in the rarer case where there are true tech secrets.
If they compartmentalize their hardware and software departments, we might as well split them into a hardware and a software company.