llvm / llvm-project

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

Possible bug: LTO, LLVM 5.0.0, mac OS: certain calls get shadowed by functions from system library given -flto flag provided and do not otherwise #33993

Open llvmbot opened 7 years ago

llvmbot commented 7 years ago
Bugzilla Link 34645
Version 5.0
OS MacOS X
Attachments Minimal reproducible example
Reporter LLVM Bugzilla Contributor
CC @AlexDenisov,@pcc

Extended Description

Please find the following minimal reproducible example in the attached:

This project is a very simplified setup extracted from openlibm library:

High quality system independent, portable, open source libm implementation http://www.openlibm.org

This repo has a function acos, certain calls to which seem to get shadowed by acos function from the standard library given the -flto flag is added. What is weird that there is no symmetry between compilation with and without -flto flag: only certain calls are shadowed while the rest still go through the custom acos function. For a contrast another function custom_acos is added - it is always called consistently with or without -flto flag (no shadowing occurs).

Important observation: valid inputs for acos function from the standard library are within range [-1, 1], for all other inputs it produces nan. In the logs for -flto below the calls of this function with invalid inputs like nan, -1.1, 1.1 do not get shadowed!

This issue is likely to affect all of the functions from openlibm library which interfere with the their corresponding functions from math.h.

The code is also pushed here: https://github.com/stanislaw/Examples/tree/20170916-llvm500-possible-lto-bug.

llvmbot commented 7 years ago

/cc /jfyi peter@pcc.me.uk

llvmbot commented 7 years ago

The following issue also exists on mac OS's system clang:

Apple LLVM version 8.1.0 (clang-802.0.42)

and manifests itself differently. In contrast to LLVM 5.0 example all the calls get shadowed given -flto flag is provided.