I have a pretty simple code like this:
#include <iostream>
#include <map>
int main() {
std::map<int, int> m{{1, 2}};
for (const auto&[a, b] : m) {
std::cout << a;
}
}
I compile it with flags -std=c++17 -Ofast and get an assembly with both clang-10 and gcc-9.3 (x86-64).
Then I add -flto flag to look how everything changes.
I expect to see some or no changes in the output.
But instead, I get something completely different on clang and <No assembly generated> on gcc.
https://gcc.godbolt.org/z/QgTAZ9
Clang output is in the attachment.

I'm not entirely sure why the Clang output is like this, but what you're seeing is the -S output, so assembly only. And for link-time-optimization you need a binary. So it's used with the 'Run the compiled output' by building the executable with -flto, but the assembly is still the -S output.
When you click the "Compile to binary", it will actually create the binary using -flto and dump the binary's assembly to CE.
So; Linking -> Compile to binary, otherwise it's just the assembly with 'some' flags taken into account, but not all.

@partouf thanks for the explanation
But is it possible to get a reasonable output without compiling to binary?
And, as you see, the output is not as pretty, as without -flto flag.
Without compiling to binary, definitely not. The compilers don't "really" build and link in the normal assembly view, just an approximation as to what it will send to the assembler.
If you want to see what the assembler + linker ended up doing, we need to build a binary.
If the question is; can we make the binary view better... maybe. But I don't see any way to improve the normal assembly view besides maybe warning the user. - But maybe @mattgodbolt has any other ideas
I'm afraid not: there's no way to get the kind of output that Compiler Explorer uses when doing LTO - we can but compile and fully link, and then disassemble the output. Warning the user is about all I could imagine we could do. Sorry!