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`).
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D145282
} else {
FwdVal = new Argument(Ty, Name);
}
+ if (FwdVal->getName() != Name) {
+ P.error(Loc, "name is too long which can result in name collisions, "
+ "consider making the name shorter or "
+ "increasing -non-global-value-max-name-size");
+ return nullptr;
+ }
ForwardRefVals[Name] = std::make_pair(FwdVal, Loc);
return FwdVal;
-; RUN: opt < %s -S -non-global-value-max-name-size=4
-; Test that local value name lookup works if the name is capped
+; RUN: opt < %s -S -non-global-value-max-name-size=5
+; RUN: not opt < %s -S -non-global-value-max-name-size=4 2>&1 | FileCheck %s
+
+; CHECK: name is too long
define void @f() {
bb0:
br label %testz
testz:
+ br label %testa
+
+testa:
br label %testz
}