<html>
<head>
<base href="https://bugs.llvm.org/">
</head>
<body><table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Bug ID</th>
<td><a class="bz_bug_link
bz_status_NEW "
title="NEW - New Pass Manager unable to statically determine the return value of some functions"
href="https://bugs.llvm.org/show_bug.cgi?id=42333">42333</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>New Pass Manager unable to statically determine the return value of some functions
</td>
</tr>
<tr>
<th>Product</th>
<td>clang
</td>
</tr>
<tr>
<th>Version</th>
<td>trunk
</td>
</tr>
<tr>
<th>Hardware</th>
<td>PC
</td>
</tr>
<tr>
<th>OS</th>
<td>Linux
</td>
</tr>
<tr>
<th>Status</th>
<td>NEW
</td>
</tr>
<tr>
<th>Severity</th>
<td>normal
</td>
</tr>
<tr>
<th>Priority</th>
<td>P
</td>
</tr>
<tr>
<th>Component</th>
<td>LLVM Codegen
</td>
</tr>
<tr>
<th>Assignee</th>
<td>unassignedclangbugs@nondot.org
</td>
</tr>
<tr>
<th>Reporter</th>
<td>leonardchan@google.com
</td>
</tr>
<tr>
<th>CC</th>
<td>llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
</td>
</tr></table>
<p>
<div>
<pre>Found when enabling the new pass manager by default and running test:
`clang/test/CodeGenCXX/conditional-temporaries.cpp`
The test fails under the new PM because it is unable to optimize some return
values statically as the legacy PM does. For example:
```
static int ctorcalls;
static int dtorcalls;
struct A {
A() : i(0) { ctorcalls++; }
~A() { dtorcalls++; }
int i;
friend const A& operator<<(const A& a, int n) {
return a;
}
};
void g(int) { }
void g(const A&) { }
void f1(bool b) {
g(b ? A().i : 0);
g(b || A().i);
g(b && A().i);
g(b ? A() << 1 : A() << 2);
}
struct Checker {
Checker() {
f1(true);
f1(false);
}
};
Checker c;
}
// CHECK-OPT-LABEL: define i32 @_Z12getCtorCallsv()
int getCtorCalls() {
// CHECK-OPT: ret i32 5
return ctorcalls;
}
```
Invoking `%clang_cc1 -emit-llvm %s -o - -triple=x86_64-apple-darwin9 -O2` is
meant to optimize it as a return of 5, but the new PM instead generates:
```
[[RET:%.*]] = load i32, i32* addrspacecast (i32 addrspace(1)*
@_ZN12_GLOBAL__N_19ctorcallsE to i32*), align 4
ret i32 [[RET]]
```
We can see something similar in
`clang/test/CodeGenCXX/member-function-pointer-calls.cpp` where calls to member
functions are not optimized out under new PM.</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are on the CC list for the bug.</li>
</ul>
</body>
</html>