Say you spent some time on a code answer to a SO question (example). Is it OK to forward the same code to Code Review or should any comments be left to happen in SO? If it's OK to ask for a review, should we have a protocol for linking the two questions?
Yes, such questions should get moved over here.
My ideas for a protocol
The code has to work. This site is not about fixing random bugs, it's about the design of the code and program. So he example linked in the OP should be migrated, since it's a design / scalability issue and not a plain bug. But it would be really bad if we move a question over here only to find that the code doesn't work and the question can't be answered because of random bugs popping up. So if there are obvious bugs in the implementation of an algorithm or the code fails with random segfaults, it should not get moved over here. Code should get fixed on SO and then be improved here on CR (as I said scalability is not considered a bug in this case).
The code should be refactorable. Don't move question from SO over here that basically consist of a ton of ugly, unindented code, that's filled with bad practices. While yes, one could answer this with a ginourmous post about what's all wrong with the code, this doesn't fit the sites purpose. We want to give clear answers, not links to refactoring books or listing posts. Also, such a question would have a high potential for ranting and it would be probably more work for us, then for the OP. So these kind of questions should stay on SO/Programmers and get answered / closed there.
The questioner should show (high?) interest in solving his problem. From my experience on SO, there's not much sense moving around questions where the questioner just posted his question and didn't respond to comments etc. Most of the time, such a question - if migrated - gets no attention at all. This is especially bad on this site, because we need the feedback from the author in order to write good answers and help him. This is not a rant against 1 rep users. I've seen people with 1 reputation writing excellent question and being very kind in regards of questions about their code. So we should look both at the account and the authors attitude. If he has low accept rate, that's a bad sign. If he writes no / hard to understand comments, that is another sign that we should probably leave the question on SO instead of moving it over here.
The question needs to be understandable, the code needs to have no bugs that would qualify it for SO and should be in a state where it can be actually refactored without doing a complete rewrite of a couple of thousand lines. Additionally, the questioner needs to be cooperative. He needs to show that he actually wants to work with us in order to clean up his code and we should be certain about him not desserting the question when it gets migrated to CR.
Popping the code over here for review helps the separation of concerns between the two sites, so yes I think it is OK.
I agree with @cbrulak's vote for a protocol - provided that protocol is clean and simple (maybe even just a comment to the effect of "go here for the original")