Preheat the oven to 425°F with a rack in the center position.
Place the squash halves cut sides up on a rimmed sheet pan. Evenly spread the butter on the cut side of each squash.
In a small bowl, combine the sugar, salt, cinnamon, and cayenne (if using). Sprinkle the spice mixture evenly over the buttered squash.
Roast for 25 minutes. Remove from the oven, leaving the oven on. Carefully sprinkle the squash with pecans, then return to the oven until fork-tender and browned, 15 minutes more.
Transfer to a serving platter or divide among 8 plates. Sprinkle with salt and pepper before serving.