On some ports it is extremely important, essential even, that the yielding is done as the last thing. On the Cortex-M however, it is not important, and either of your code snippets are fine, provided your doStuff() function is only called from an interrupt. If it is not called from an interrupt then it will still be ok provided the function that calls it takes care of the yielding if one is required.
Every port is different. Some require direct manipulation of the ISR exit code, in which case the yield must be at the end, or use function calls, which again means it has to be at the end, but the Cortex-M just pends the PendSV interrupt, and that can be done at any time because the interrupt won’t execute until the original ISR exits (because the PendSV is the lowest priority).