The process of determining the worst-case execution time (WCET) is challenged in the presence of caches due to their unpredictable effect on the speed of memory references. In particular, when cache conflicts between program lines are common, thrashing occurs and this inadvertently increases the WCET, sometimes significantly so. One way to minimise the cache impact on the WCET, therefore, is to judiciously lay out code and data in memory to avoid cache conflicts. In this paper, we show how to formulate the WCET-aware code placement problem as a Constraint-Optimization Problem (COP), which can then be efficiently solved by off-the-shelf COP solvers. Experimental evaluation of our proposed analysis shows that the proposed analysis successfully identified code positioning that yields the minimum WCET for over half of the problems within manageable time.