I wonder in what version of llvm the noopt attribute appeared, that is inserted when O0 is specified? In some early versions I don’t get this behavior.

The ‘optnone’ attribute was added to LLVM IR some years ago, but originally Clang used it only for the “optimize off” pragma.

Adding it to all functions when compiling at –O0 was a relatively recent change, r304127 (end of May).