[LLVMbugs] [Bug 22285] New: comdats cause uncalled linkonce_odr functions to be retained at -O0/-O1
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Jan 21 11:27:03 PST 2015
http://llvm.org/bugs/show_bug.cgi?id=22285
Bug ID: 22285
Summary: comdats cause uncalled linkonce_odr functions to be
retained at -O0/-O1
Product: libraries
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: normal
Priority: P
Component: Interprocedural Optimizations
Assignee: david.majnemer at gmail.com
Reporter: dblaikie at gmail.com
CC: llvmbugs at cs.uiuc.edu, rafael.espindola at gmail.com
Classification: Unclassified
$ cat inl.ll
$f1 = comdat any
define void @f2() {
entry:
call void @f1()
ret void
}
define linkonce_odr void @f1() comdat {
entry:
ret void
}
$ opt -S -inline inl.ll -o - | grep define
define void @f2() {
define linkonce_odr void @f1() comdat {
$ cat inl2.ll
define void @f2() {
entry:
call void @f1()
ret void
}
define linkonce_odr void @f1() {
entry:
ret void
}
$ opt inl2.ll -S -inline -o - | grep define
define void @f2() {
$
The problem seems to be at lib/Transforms/IPO/Inliner.cpp:678:
// It is unsafe to drop a function with discardable linkage from a COMDAT
// without also dropping the other members of the COMDAT.
// The inliner doesn't visit non-function entities which are in COMDAT
// groups so it is unsafe to do so *unless* the linkage is local.
if (!F->hasLocalLinkage() && F->hasComdat())
continue;
Which is correct, but very conservative. At higher optimization levels some
other pass (I'll check which one in a moment) must kick in and still manage to
cleanup these dead comdats.
Since a comdat doesn't refer to its members, it's not trivial to just ask "is
this a comdat with only one element" and then drop the function (& comdat)
anyway. Maybe it needs a separate pass specifically looking for comdats whos
elements are all unused linkonce_odr elements?
--
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/20150121/4922cd97/attachment.html>
More information about the llvm-bugs
mailing list