This is an archive of the discontinued LLVM Phabricator instance.

[LLParser] Error out if a name is too long and gets renamed
ClosedPublic

Authored by aeubanks on Mar 3 2023, 4:01 PM.

Details

Summary

Typically names longer than -non-global-value-max-name-size will just get renamed if there is a collision after truncating. This is fine since we typically don't reference Values by name.

However LLParser does reference Values by name, so report an error when that happens, otherwise weird issues can crop up if there are name collisions (e.g. verifier issues with the changed test case because we end up reusing the same block for testz and testa).

Diff Detail

Event Timeline

aeubanks created this revision.Mar 3 2023, 4:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2023, 4:01 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
aeubanks requested review of this revision.Mar 3 2023, 4:01 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 3 2023, 4:01 PM
aeubanks edited the summary of this revision. (Show Details)Mar 3 2023, 4:05 PM
aeubanks added reviewers: arsenm, nikic.
arsenm added a comment.Mar 3 2023, 4:32 PM

I’d expect the names to be truncated to the limit plus the conflict resolution number. Does the limit clamp the suffix?

I’d expect the names to be truncated to the limit plus the conflict resolution number. Does the limit clamp the suffix?

yes that is how it works, the limit doesn't clamp the suffix, but that's not the issue

the issue is that within LLParser, F.getValueSymbolTable()->lookup() truncates the name, resulting in both testa and testz getting mapped to the same BasicBlock in LLParser::PerFunctionState::getVal

the original issue was https://github.com/llvm/llvm-project/issues/45244, which https://reviews.llvm.org/D102707 sort of fixed. but the issue of collisions was never raised and I ran into it with very long basic block names. I think it's possible to fully fix this issue by keeping track of renaming but it's not trivial (e.g. have to handle the case where we see testz, truncate it to test internally, then see an actual test later on), and a solution wouldn't be free in terms of compile time

nikic accepted this revision.Mar 4 2023, 12:42 AM

LG, I think it's fine to just forbid this.

This revision is now accepted and ready to land.Mar 4 2023, 12:42 AM
This revision was landed with ongoing or failed builds.Mar 6 2023, 3:44 PM
This revision was automatically updated to reflect the committed changes.