This reverts commit 17fdaccccfad9b143e4aadbcdda7f645de127153.
Unfortunately the commit (D123162) introduced a mis-compile (see
llvm/test/Transforms/PhaseOrdering/dse-ephemeral-value-captures.ll). The
issue is roughly:
- There's a call to a readonly function that takes a pointer argument and its result is only used by an assume, so the call is considered ephemeral and not capturing.
- Because the call doesn't capture the pointer, it's considered to not read the pointer, causing DSE to remove the store before the call.
- Now the called function gets inlined and there's now a load from the pointer, but the initializing store has been removed
- This leads to SROA replacing the load with undef, which will cause the function to get folded to unreachable by subsequent optimizations.
This is a mis-compile potentially impacting Clang builds with ThinLTO +
PGO.
I think as long as the call considered as ephemeral is not removed, we
need to be conservative. To address the correctness issue quickly, I
think we should revert the patch (as this patch does, it doens't revert
cleanly) and potentially consider what subset of ephemeral values we can
allow here or if we should clean up ephemeral calls sooner/avoid
inlining them.
remove comment