CLANG/CLANG++ is both a native compiler and a cross compiler that supports multiple targets. On OS/X the targets by default are usually a variant of x86_64-apple-darwin for 64-bit code and i386-apple-darwin for 32-bit code. The code you are seeing that resembles this form:
push rbp mov rbp, rsp [snip] pop rbp ret
Is produced to introduce stack frames. By default CLANG++ implicitly enables stack frames for the Apple Darwin targets. This differs from the Linux targets like x86_64-linux-gnu and i386-linux-gnu. Stack frames can come in handy for some profiling and unwind libraries and can aid debugging on the OS/X platforms which is why I believe they opt to turn them on by default.
You can explicitly omit frame pointers with CLANG++ using the option -fomit-frame-pointer. If you use the build command
g++ -S -masm=intel -O3 -fno-exceptions -fno-asynchronous-unwind-tables \ -fomit-frame-pointer f.cpp
The output would be something similar to:
shl dword ptr [rdi] ret
A Look at Code with Different Targets
If you use different targets with CLANG++ you'd discover the behavior is different. This is an x86-64 Linux target where we don't explicitly omit the frame pointer:
clang++ -target x86_64-linux-gnu -S -masm=intel -O3 -fno-exceptions \ -fno-asynchronous-unwind-tables f.cpp
Which generates:
shl dword ptr [rdi] ret
This is your original x86-64 Apple Darwin target:
clang++ -target x86_64-apple-darwin -S -masm=intel -O3 -fno-exceptions \ -fno-asynchronous-unwind-tables f.cpp
Which generates:
push rbp mov rbp, rsp shl dword ptr [rdi] pop rbp ret
And then the x86-64 Apple target with frame pointers omitted:
clang++ -target x86_64-apple-darwin -S -masm=intel -O3 -fno-exceptions \ -fno-asynchronous-unwind-tables -fomit-frame-pointer f.cpp
Which generates:
shl dword ptr [rdi] ret
You can do a comparison of these targets on Godbolt. The first column of generated code is similar to the question - Apple target with implicit frame pointers. The second is Apple target without frame pointers and the third is an x86-64 Linux target.
-fomit-frame-pointerit should remove them when it can.-O3(or-O2) in Clang. I can't repro it here, either, even on an old version of Clang. Something is wrong with your configuration. Are you sure that that optimization flag is getting passed? Apple does that weirdg++== Clang redirection thing, maybe that's messing it up?