From 008dc9e0a47d9ec70b0583b01bc71bd892f3de24 Mon Sep 17 00:00:00 2001
From: Stuart Archibald <redacted>
Date: Mon, 8 Apr 2019 16:30:24 +0100
Subject: [PATCH] Revert "Limit size of non-GlobalValue name"

https://reviews.llvm.org/D41296 introduced a limit on the length of a
non-GlobalValue name, this patch is a direct revert of that change (as code gen
can sometimes legitimately create very long names).

This reverts commit 4c23defc23d3ddb191762683b3bdb2399fe53a58.
---
 lib/IR/Value.cpp                     |  9 ---------
 test/Bitcode/value-with-long-name.ll | 18 ------------------
 2 files changed, 27 deletions(-)
 delete mode 100644 test/Bitcode/value-with-long-name.ll

diff --git a/lib/IR/Value.cpp b/lib/IR/Value.cpp
index cf32a66c901..99a4660a191 100644
--- a/lib/IR/Value.cpp
+++ b/lib/IR/Value.cpp
@@ -37,10 +37,6 @@
 
 using namespace llvm;
 
-static cl::opt<unsigned> NonGlobalValueMaxNameSize(
-    "non-global-value-max-name-size", cl::Hidden, cl::init(1024),
-    cl::desc("Maximum size for the name of non-global values."));
-
 //===----------------------------------------------------------------------===//
 //                                Value Class
 //===----------------------------------------------------------------------===//
@@ -238,11 +234,6 @@ void Value::setNameImpl(const Twine &NewName) {
   if (getName() == NameRef)
     return;
 
-  // Cap the size of non-GlobalValue names.
-  if (NameRef.size() > NonGlobalValueMaxNameSize && !isa<GlobalValue>(this))
-    NameRef =
-        NameRef.substr(0, std::max(1u, (unsigned)NonGlobalValueMaxNameSize));
-
   assert(!getType()->isVoidTy() && "Cannot assign a name to void values!");
 
   // Get the symbol table to update for this object.
diff --git a/test/Bitcode/value-with-long-name.ll b/test/Bitcode/value-with-long-name.ll
deleted file mode 100644
index 1ca5d133e09..00000000000
--- a/test/Bitcode/value-with-long-name.ll
+++ /dev/null
@@ -1,18 +0,0 @@
-; Check the size of generated variable when no option is set
-; RUN: opt -S %s -O2 -o - | FileCheck -check-prefix=CHECK-LONG %s
-; CHECK-LONG: %{{[a-z]{4}[a-z]+}}
-
-; Then check we correctly cap the size of newly generated non-global values name
-; Force the size to be small so that the check works on release and debug build
-; RUN: opt -S %s -O2 -o - -non-global-value-max-name-size=0 | FileCheck -check-prefix=CHECK-SHORT %s
-; RUN: opt -S %s -O2 -o - -non-global-value-max-name-size=1 | FileCheck -check-prefix=CHECK-SHORT %s
-; CHECK-SHORT-NOT: %{{[a-z][a-z]+}}
-
-define i32 @f(i32 %a, i32 %b) {
-  %c = add i32 %a, %b
-  %d = add i32 %c, %a
-  %e = add i32 %d, %b
-  ret i32 %e
-}
-
-
-- 
2.20.1

