llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.85k stars 11.91k forks source link

Missing optimization: linkonce_odr stuff only referenced by available externally globals is not discarded #20556

Open rnk opened 10 years ago

rnk commented 10 years ago
Bugzilla Link 20182
Version trunk
OS Windows NT
CC @d0k,@majnemer

Extended Description

consider:

@​x = available_externally constant void()* @​f

define linkonce_odr void @​f() { ret void }

define i32 @​main() { %f = load void()** @​x call void %f() ret i32 0 }

@​x references @​f. @​x will not be emitted, and @​f is discardable, so we should discard it if that's the only reference.

This is relevant for dllimported vftable thunks in the MS ABI, because they are not actually available externally. We emit them for devirtualization of thunks, but we cannot actually import them.

rnk commented 5 years ago

Still repros, still seems relevant for reducing object file size on Windows, where there are lots of available_externally vtables from dllimport stuff. I might re-look into this.

llvmbot commented 10 years ago

The fix was reverted.

d0k commented 10 years ago

r212337 should help.