Why do we mangle names in llvm?

When we produce IL for

int f(void) {...}

it looks like

define i32 @f() {....

and llvm is then responsible for adding the '_' prefix:


Why do we have this division? Wouldn't it be better for the IL to have the '_':

define i32 @_f() {....

This causes problems with LTO because the symbols seem by the first pass are not the same as the ones seen once the final .o is produced. It can be fixed by having libLTO call void Mangler::getNameWithPrefix, but I was wondering if it wouldn't be better the avoid mangling in LLVM completely.