[llvm-bugs] [Bug 27796] New: Calls to empty variadic functions in comdat no longer optimized out
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue May 17 15:33:20 PDT 2016
https://llvm.org/bugs/show_bug.cgi?id=27796
Bug ID: 27796
Summary: Calls to empty variadic functions in comdat no longer
optimized out
Product: libraries
Version: trunk
Hardware: PC
OS: Windows NT
Status: NEW
Severity: normal
Priority: P
Component: Interprocedural Optimizations
Assignee: unassignedbugs at nondot.org
Reporter: warren_ristow at playstation.sony.com
CC: llvm-bugs at lists.llvm.org
Classification: Unclassified
With LLVM 3.8, the following test-case (compiled at -O2) optimizes everything
away to simply 'main()' returning 0:
// ======== test.cpp ======== //
struct DebugMessage {
void PrintTraceMessage(const char *fmt, ...) {
#if defined(DEBUG_TRACE_ENABLED)
// some code here when debugging is enabled
#endif
}
void PrintTraceNote(const char *note) {
#if defined(DEBUG_TRACE_ENABLED)
// some code here when debugging is enabled
#endif
}
};
int main(int argc, char **argv)
{
DebugMessage dbg;
dbg.PrintTraceMessage("%s: Entered main() with argc = %d\n", argv[0],
argc);
dbg.PrintTraceNote("Done.\n");
return 0;
}
// ========================== //
But with a modern TOT compiler (e.g., r269832), the call from main() to the
empty method:
DebugMessage::PrintTraceMessage()
remains (and an empty body of DebugMessage::PrintTraceMessage() is emitted, of
course). On the other hand, the call to the other empty method:
DebugMessage:: PrintTraceNote()
is still inlined (and thus the body is not emitted). It's the variadic aspect
of 'DebugMessage::PrintTraceMessage()' that presumably is why it isn't inlined.
Tracking this down, prior to r265762, the variadic call was also inlined, and
so everything was optimized nicely, but with the change of r265762, the
variadic
routine is no longer inlined. (As an aside, r265762 also needs the change of
r265767 to be applied, to deal with an LLVM API change.)
r265762 is a change to address the issue of PR26774, which is that for
functions in comdat, some Inter Procedural Optimizations (IPO) cannot be done
safely, and so must be suppressed. Given the discussion in bug 26774, I'd
expect that this can be worked around by changing the test-case so
DebugMessage::PrintTraceMessage() isn't in comdat (e.g., by moving the
definition outside the class). I've verified that by doing that, main() is
again optimized to simply returning 0.
In this case, as far as I can see, the suppression of the optimization related
to PR26774 is unneeded.
--
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/20160517/42d2661c/attachment.html>
More information about the llvm-bugs
mailing list