[PATCH] D145282: [LLParser] Error out if a name is too long and gets renamed
Arthur Eubanks via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 3 16:01:29 PST 2023
aeubanks created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D145282
Files:
llvm/lib/AsmParser/LLParser.cpp
llvm/test/Assembler/non-global-value-max-name-size.ll
Index: llvm/test/Assembler/non-global-value-max-name-size.ll
===================================================================
--- llvm/test/Assembler/non-global-value-max-name-size.ll
+++ llvm/test/Assembler/non-global-value-max-name-size.ll
@@ -1,10 +1,15 @@
-; 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
}
Index: llvm/lib/AsmParser/LLParser.cpp
===================================================================
--- llvm/lib/AsmParser/LLParser.cpp
+++ llvm/lib/AsmParser/LLParser.cpp
@@ -3330,6 +3330,12 @@
} 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;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145282.502295.patch
Type: text/x-patch
Size: 1242 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230304/d8b86393/attachment.bin>
More information about the llvm-commits
mailing list