Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
How about test cases with PRE of calls? (on the other hand, I think those cases are non trivial to support ).
a = pure_call();
if (cond) {
b = pure_call(); ..
}
>
a = pure_call();
if (cond) {
b = a;
}
and
if (cond) {
b = pure_call();
}
a = pure_call();
>
if (cond) {
t = pure_call(); b = t;
} else {
t = pure_call();
}
a = t;
And LICM case:
for (...) {
sum += pure_call();
}
>
t = pure_call();
for (...) {
sum += t;
}
LICM may drop !prof for a similar reason that !prof is not a known metadata that doesn't have UB side effects (https://github.com/llvm/llvm-project/blob/2dc97921afba741586887037763784fc9b19c304/llvm/lib/Transforms/Scalar/LICM.cpp#L1744) -> so looks like another case to fix.
- test case https://gcc.godbolt.org/z/47Mj9vn9n
For one PRE case, both GVN and EarlyCSE could merge call instructions and preserve !prof (https://gcc.godbolt.org/z/3fzP3x6eG and https://gcc.godbolt.org/z/aT8W4crzv)
ack. existing test cases doesn't fail by adding !prof to non undefined-behavior list. I think it could show up in real code (not only artificial test case).