[llvm-bugs] [Bug 39712] New: clang-cl generates more static initializers than VC++ does
via llvm-bugs
llvm-bugs at lists.llvm.org
Mon Nov 19 13:50:31 PST 2018
https://bugs.llvm.org/show_bug.cgi?id=39712
Bug ID: 39712
Summary: clang-cl generates more static initializers than VC++
does
Product: clang
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: enhancement
Priority: P
Component: C++
Assignee: unassignedclangbugs at nondot.org
Reporter: brucedawson at chromium.org
CC: blitzrakete at gmail.com, dgregor at apple.com,
erik.pilkington at gmail.com, llvm-bugs at lists.llvm.org,
richard-llvm at metafoo.co.uk
This is an example of code that VC++ optimizes better than clang-cl. With VC++
there is no static initializer whereas with clang there is:
struct my_id {
my_id() : v_(0) {}
int v_;
};
template <typename T> struct Foo {
static my_id id;
};
template <typename T> my_id Foo<T>::id;
int main() { Foo<char>::id.v_++; }
So, this is a missing optimization in LLVM. LLVM's globalopt pass is supposed
to handle this, but it gives up too easily. The COMDAT scheme that Microsoft
uses is clever and allows the compiler to optimize this to static
initialization without changing the ABI.
This was reported in crbug.com/782027 and it leads to eleven static
initializers in clang-cl builds of Chrome (chrome.exe, chrome.dll, and
chrome_child.dll) that are not present in VC++ builds, coming from the VC++ STL
header files.
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181119/0460497d/attachment-0001.html>
More information about the llvm-bugs
mailing list