> On May 13, 2020, at 7:20 PM, Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote: > > On Wed, May 13, 2020 at 5:51 PM Nick Desaulniers > <ndesaulniers@xxxxxxxxxx> wrote: >> >> Are you sure LTO treats empty asm statements differently than full >> memory barriers in regards to preventing tail calls? > > It had better. > > At link-time, there is nothing left of an empty asm statement. So by > the time the linker runs, it only sees > > call xyz > ret > > in the object code. At that point, it's somewhat reasonable for any > link-time optimizer (or an optimizing assembler, for that matter) to > say "I'll just turn that sequence into a simple 'jmp xyz' instead". > What, what? LTO isn’t a linker taking regular .o files full of regular machine code and optimizing it. That’s nuts. LTO takes an intermediate representation and optimizes *that*. This will contain actual indications that something is inline asm. If LTO starts rewriting inline asm, then I bet all kinds of things will go wrong and this is the least of our worries. Also, trying to do the kinds of stuff LTO does by looking at just machine code isn't going to work. So the difference between: asm volatile ("nop"); and asm volatile (""); will be, literally, the absence of the nop. (And alignment changes, etc.)