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.
I tried to reproduce it by running clang with "-fexperimental-new-pass-manager -O2", and it does produce the desired result.
Am I doing something wrong?
Extended Description
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:
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: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.