top | item 19896385

(no title)

johannkokos | 6 years ago

> If we change foo2 to a declaration (such as would be the case if it was defined in an external translation unit, and its declaration included via header), then Clang can no longer observe whether foo2 definition differs or not from the declaration.

I tried enabling link time optimization on clang-8, it does see through and eliminate redundant xor instruction in foo2(). gcc fails to do that, however. I inspect the result by calling objdump on generated object code.

discuss

order

ndesaulniers|6 years ago

Great! Thanks for confirming; I suspected LTO would be able to do this optimization as well. I should add that to the post.