[llvm] [LLVM] Add HasFakeUses to MachineFunction (PR #110097)
Stephen Tozer via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 30 09:25:54 PDT 2024
================
@@ -525,6 +525,7 @@ MIRParserImpl::initializeMachineFunction(const yaml::MachineFunction &YamlMF,
MF.setHasEHCatchret(YamlMF.HasEHCatchret);
MF.setHasEHScopes(YamlMF.HasEHScopes);
MF.setHasEHFunclets(YamlMF.HasEHFunclets);
+ MF.setHasFakeUses(YamlMF.HasFakeUses);
----------------
SLTozer wrote:
The current approach for this has the property being set purely by ISel and not updated afterwards, such that we could have a function with "hasFakeUses" set which once contained FAKE_USE instructions, but where they have since been deleted by some form of DCE; that _shouldn't_ generally happen, since FAKE_USEs are meant to be preserved, but if there are cases where they exist in an unreachable block then it's possible. In those cases, under the current logic we would still assume fake uses exist and treat the function as such.
Changing this to have inference would require us to either have a circumstance where serializing and deserializing the MachineFunction changes the result (as we detect HasFakeUses=false), have serializing and deserializing result in an error due to inconsistency, or requiring every pass that could remove all FAKE_USE instructions to be aware of them and updating the flag if needed. I think of these options, it would probably be best to change the flag to "MayHaveFakeUses" or something along those lines and just keeping track of it from ISel onwards; there should be very few circumstances where FAKE_USEs are deleted post-ISel, and none at all where they're added. Does that sound reasonable?
https://github.com/llvm/llvm-project/pull/110097
More information about the llvm-commits
mailing list