[PATCH] D41296: Limit size of non-GlobalValue name
serge via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Dec 21 12:59:43 PST 2017
serge-sans-paille updated this revision to Diff 127929.
serge-sans-paille retitled this revision from "Limit size of SROA - generated register names" to "Limit size of non-GlobalValue name".
serge-sans-paille edited the summary of this revision.
Repository:
rL LLVM
https://reviews.llvm.org/D41296
Files:
lib/IR/Value.cpp
test/Transforms/SROA/register-name-too-long.ll
Index: lib/IR/Value.cpp
===================================================================
--- lib/IR/Value.cpp
+++ lib/IR/Value.cpp
@@ -39,6 +39,10 @@
using namespace llvm;
+static cl::opt<std::size_t> NonGlobalValueMaxNameSize(
+ "non-global-value-max-name-size", cl::Hidden, cl::init(64),
+ cl::desc("Maximum size for the name of non-global values."));
+
//===----------------------------------------------------------------------===//
// Value Class
//===----------------------------------------------------------------------===//
@@ -244,6 +248,10 @@
if (getName() == NameRef)
return;
+ // Cap the size of non-GlobalValue names.
+ if (NameRef.size() > NonGlobalValueMaxNameSize && !isa<GlobalValue>(this))
+ NameRef = NameRef.substr(0, NonGlobalValueMaxNameSize);
+
assert(!getType()->isVoidTy() && "Cannot assign a name to void values!");
// Get the symbol table to update for this object.
Index: test/Transforms/SROA/register-name-too-long.ll
===================================================================
--- test/Transforms/SROA/register-name-too-long.ll
+++ test/Transforms/SROA/register-name-too-long.ll
@@ -0,0 +1,55 @@
+; This test case used to swap because of too many intermediate steps resulting in utterly long names.
+; RUN: opt < %s -sroa -S
+
+source_filename = "bugpoint-output-1d9ce6e.bc"
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+%Array = type { [18812 x i8] }
+%CharArrayPair = type { i8, %Array }
+%Either = type { [18814 x i8] }
+
+; Function Attrs: noinline nounwind uwtable
+define void @foo() unnamed_addr #0 {
+start:
+ %_9 = alloca %Array, align 1
+ %_8 = alloca %Array, align 1
+ %array = alloca %Array, align 1
+ %_2 = alloca %CharArrayPair, align 1
+ %either = alloca %Either, align 1
+ %0 = bitcast %Either* %either to %CharArrayPair*
+ %1 = bitcast %CharArrayPair* %_2 to i8*
+ %2 = bitcast %CharArrayPair* %0 to i8*
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* %2, i8* %1, i64 18813, i32 1, i1 false)
+ %3 = bitcast %Either* %either to %CharArrayPair*
+ %4 = bitcast %CharArrayPair* %3 to i8*
+ %5 = load i8, i8* %4
+ br i1 undef, label %bb1, label %bb2
+
+bb1: ; preds = %start
+ %6 = bitcast %Either* %either to %CharArrayPair*
+ %7 = getelementptr inbounds %CharArrayPair, %CharArrayPair* %6, i32 0, i32 1
+ %8 = bitcast %Array* %7 to i8*
+ %9 = bitcast %Array* %_8 to i8*
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* %9, i8* %8, i64 18812, i32 1, i1 false)
+ %10 = bitcast %Array* %_8 to i8*
+ %11 = bitcast %Array* %array to i8*
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* %11, i8* %10, i64 18812, i32 1, i1 false)
+ ret void
+
+bb2: ; preds = %start
+ %12 = bitcast %Either* %either to %Array*
+ %13 = bitcast %Array* %12 to i8*
+ %14 = bitcast %Array* %_9 to i8*
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* %14, i8* %13, i64 18812, i32 1, i1 false)
+ %15 = bitcast %Array* %_9 to i8*
+ %16 = bitcast %Array* %array to i8*
+ call void @llvm.memcpy.p0i8.p0i8.i64(i8* %16, i8* %15, i64 18812, i32 1, i1 false)
+ unreachable
+}
+
+; Function Attrs: argmemonly nounwind
+declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture writeonly, i8* nocapture readonly, i64, i32, i1) #1
+
+attributes #0 = { noinline nounwind uwtable }
+attributes #1 = { argmemonly nounwind }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41296.127929.patch
Type: text/x-patch
Size: 3460 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171221/69556fbb/attachment.bin>
More information about the llvm-commits
mailing list