Change how globalopt handles aliases in llvm.used

Rafael EspĂ­ndola rafael.espindola at gmail.com
Tue Jun 4 13:03:58 PDT 2013


ping.

On 27 May 2013 19:25, Rafael EspĂ­ndola <rafael.espindola at gmail.com> wrote:
> Now that the simple fix is safely in the 3.3 branch, I would like to
> revisit the more complete one.
>
> The first patch (verify.patch) just checks that every entry in
> llvm.used has a name. As far as I can tell this is a reasonable
> restriction since the language reference defines llvm.used in terms of
> an invisible reference.
>
> The second patch (global-opt.patch) is the actual change. Instead of a
> custom implementation of replaceAllUsesWith, we just call
> replaceAllUsesWith and recreate llvm.used and llvm.compiler-used.
>
> This change is particularity interesting because it makes llvm see
> through what clang is doing with static used functions in extern "C"
> contexts. With this change, running clang -O2 in
>
> extern "C" {
>   __attribute__((used)) static void foo() {}
> }
>
> produces
>
> @llvm.used = appending global [1 x i8*] [i8* bitcast (void ()* @foo to
> i8*)], section "llvm.metadata"
> define internal void @foo() #0 {
> entry:
>   ret void
> }
>
> Cheers,
> Rafael




More information about the llvm-commits mailing list