Joint Optimization of Prompt Security and System Performance in Edge-Cloud LLM Systems