- This should have been be a part of D148877. Before that patch, !prof is not added to known-id-set, and turns out unknown types of metadata are dropped in the implementation.
- This test is mainly added to make sure there won't be regressions for this kind of pattern. The pattern is observed it in application code; looks like the result of indirect call is used as function arguments initially; after the function is inlined load-after-store CSE opportunity is exposed.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Can you expand the summary to explain why it is being dropped, and conceptually what the fix is doing? I'm not familiar with DoesKMove and what the 2 cases are here.
llvm/test/Transforms/EarlyCSE/metadata.ll | ||
---|---|---|
2 | Add a comment at the top about what this test is testing. | |
22 | What was being CSE'd here that caused it to get dropped? |
looks like the wrong test case is uploaded? Should it be CSE of direct calls with "branch_weight" profile instead of indirect calls (indirect calls are unlikely to be CSEed without points to information).
Yes the code change is no longer needed. I initially thought K's metadata needs to be explicitly reset to be preserved in combineMetadata when KDominatesJ is false (or DoesKMove is false), but realized it shouldn't be the case, so reverted the code change (to explicitly reset metadata again)
Here the indirect call result CSE'ed a load-after-store instruction, rather than two indirect call instructions are CSE'ed to one
llvm/test/Transforms/EarlyCSE/metadata.ll | ||
---|---|---|
22 | Here the optimizer finds %foo should have the same value as %call1 so it CSE'ed the load operation, and combines metadata of %call1 = tail call i32 %0(ptr %call, i32 %a, i32 %b), !prof !0 and %foo = load i32, ptr %x, align 4. Before D148877, !prof is not added to known-id-set, and turns out unknown types of metadata are dropped in the implementation. This test is mainly added to make sure there won't be regressions for this kind of pattern. The pattern is observed it in application code; looks like the result of indirect call is used as function arguments initially; after the function is inlined load-after-store is exposed (I didn't try to get a c++ repro since the IR is a little complex) With 'opt -passes=early-cse -debug metadata.ll' debug log gives |
'llvm/lib/Transforms/Utils/Local.cpp' in https://reviews.llvm.org/D149387 is the original code change (that is not needed)
Add a comment at the top about what this test is testing.