Preheat the oven to 425°F.
Toss the squash with olive oil, salt, and pepper in a shallow baking dish.
Spread the squash into a mostly single layer.
Roast for 25–35 minutes, stirring halfway through, until lightly golden and tender when pierced.
Meanwhile, cook the bacon in a skillet over medium heat until browned and just crisp.
Transfer the bacon to a paper-towel-lined plate to drain. Then chop it.
Reduce the oven temperature to 400°F.
Stir together the heavy cream, grated garlic, and minced rosemary in a small bowl.
Gently fold the cream mixture, half the Gruyere, and half the bacon into the roasted squash.
Sprinkle the remaining cheese over the top.
Bake for 10–15 minutes, adding the remaining bacon during the final 3 minutes, until the cheese is melted and the cream bubbles around the edges.
Rest for 5–10 minutes before serving.
