diff options
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Analysis/BasicAliasAnalysis.cpp | 113 | ||||
| -rw-r--r-- | llvm/test/Analysis/GlobalsModRef/chaining-analysis.ll | 24 | ||||
| -rw-r--r-- | llvm/test/Analysis/LoadVN/call_cse.ll | 19 | ||||
| -rw-r--r-- | llvm/test/Analysis/LoadVN/call_pure_function.ll | 21 | ||||
| -rw-r--r-- | llvm/test/Transforms/ADCE/dce_pure_call.ll | 9 | ||||
| -rw-r--r-- | llvm/test/Transforms/LICM/call_sink_const_function.ll | 21 | ||||
| -rw-r--r-- | llvm/test/Transforms/LICM/call_sink_pure_function.ll | 20 | ||||
| -rw-r--r-- | llvm/test/Transforms/LoopRotate/pr1154.ll | 49 | 
8 files changed, 83 insertions, 193 deletions
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp index c6e34da5ac3..2291852c869 100644 --- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp +++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp @@ -810,85 +810,9 @@ BasicAliasAnalysis::CheckGEPInstructions(    return MayAlias;  } -namespace { -  struct VISIBILITY_HIDDEN StringCompare { -    bool operator()(const char *LHS, const char *RHS) { -      return strcmp(LHS, RHS) < 0; -    } -  }; -} - -// Note that this list cannot contain libm functions (such as acos and sqrt) -// that set errno on a domain or other error. -static const char *DoesntAccessMemoryFns[] = { -  "abs", "labs", "llabs", "imaxabs", "fabs", "fabsf", "fabsl", -  "trunc", "truncf", "truncl", "ldexp", - -  "atan", "atanf", "atanl",   "atan2", "atan2f", "atan2l", -  "cbrt", -  "cos", "cosf", "cosl", -  "exp", "expf", "expl", -  "hypot", -  "sin", "sinf", "sinl", -  "tan", "tanf", "tanl",      "tanh", "tanhf", "tanhl", -   -  "floor", "floorf", "floorl", "ceil", "ceilf", "ceill", - -  // ctype.h -  "isalnum", "isalpha", "iscntrl", "isdigit", "isgraph", "islower", "isprint" -  "ispunct", "isspace", "isupper", "isxdigit", "tolower", "toupper", - -  // wctype.h" -  "iswalnum", "iswalpha", "iswcntrl", "iswdigit", "iswgraph", "iswlower", -  "iswprint", "iswpunct", "iswspace", "iswupper", "iswxdigit", - -  "iswctype", "towctrans", "towlower", "towupper", - -  "btowc", "wctob", - -  "isinf", "isnan", "finite", - -  // C99 math functions -  "copysign", "copysignf", "copysignd", -  "nexttoward", "nexttowardf", "nexttowardd", -  "nextafter", "nextafterf", "nextafterd", - -  // ISO C99: -  "__signbit", "__signbitf", "__signbitl", -}; - - -static const char *OnlyReadsMemoryFns[] = { -  "atoi", "atol", "atof", "atoll", "atoq", "a64l", -  "bcmp", "memcmp", "memchr", "memrchr", "wmemcmp", "wmemchr", - -  // Strings -  "strcmp", "strcasecmp", "strcoll", "strncmp", "strncasecmp", -  "strchr", "strcspn", "strlen", "strpbrk", "strrchr", "strspn", "strstr", -  "index", "rindex", - -  // Wide char strings -  "wcschr", "wcscmp", "wcscoll", "wcscspn", "wcslen", "wcsncmp", "wcspbrk", -  "wcsrchr", "wcsspn", "wcsstr", - -  // glibc -  "alphasort", "alphasort64", "versionsort", "versionsort64", - -  // C99 -  "nan", "nanf", "nand", - -  // File I/O -  "feof", "ferror", "fileno", -  "feof_unlocked", "ferror_unlocked", "fileno_unlocked" -}; - -static ManagedStatic<std::vector<const char*> > NoMemoryTable; -static ManagedStatic<std::vector<const char*> > OnlyReadsMemoryTable; -  static ManagedStatic<BitVector> NoMemoryIntrinsics;  static ManagedStatic<BitVector> OnlyReadsMemoryIntrinsics; -  AliasAnalysis::ModRefBehavior  BasicAliasAnalysis::getModRefBehavior(Function *F, CallSite CS,                                        std::vector<PointerAccessInfo> *Info) { @@ -896,19 +820,6 @@ BasicAliasAnalysis::getModRefBehavior(Function *F, CallSite CS,    static bool Initialized = false;    if (!Initialized) { -    NoMemoryTable->insert(NoMemoryTable->end(), -                          DoesntAccessMemoryFns,  -                          array_endof(DoesntAccessMemoryFns)); - -    OnlyReadsMemoryTable->insert(OnlyReadsMemoryTable->end(), -                                 OnlyReadsMemoryFns,  -                                 array_endof(OnlyReadsMemoryFns)); - -    // Sort the table the first time through. -    std::sort(NoMemoryTable->begin(), NoMemoryTable->end(), StringCompare()); -    std::sort(OnlyReadsMemoryTable->begin(), OnlyReadsMemoryTable->end(), -              StringCompare()); -          NoMemoryIntrinsics->resize(Intrinsic::num_intrinsics);      OnlyReadsMemoryIntrinsics->resize(Intrinsic::num_intrinsics);  #define GET_MODREF_BEHAVIOR @@ -927,30 +838,6 @@ BasicAliasAnalysis::getModRefBehavior(Function *F, CallSite CS,      return UnknownModRefBehavior;    } -   -  ValueName *Name = F->getValueName(); -  if (!Name) -    return UnknownModRefBehavior; -   -  unsigned NameLen = Name->getKeyLength(); -  const char *NamePtr = Name->getKeyData(); -   -  // If there is an embedded nul character in the function name, we can never -  // match it. -  if (strlen(NamePtr) != NameLen) -    return UnknownModRefBehavior; - -  std::vector<const char*>::iterator Ptr = -    std::lower_bound(NoMemoryTable->begin(), NoMemoryTable->end(), -                     NamePtr, StringCompare()); -  if (Ptr != NoMemoryTable->end() && strcmp(*Ptr, NamePtr) == 0) -    return DoesNotAccessMemory; - -  Ptr = std::lower_bound(OnlyReadsMemoryTable->begin(), -                         OnlyReadsMemoryTable->end(), -                         NamePtr, StringCompare()); -  if (Ptr != OnlyReadsMemoryTable->end() && strcmp(*Ptr, NamePtr) == 0) -    return OnlyReadsMemory;    const ParamAttrsList *Attrs = F->getFunctionType()->getParamAttrs();    if (Attrs && Attrs->paramHasAttr(0, ParamAttr::ReadNone)) diff --git a/llvm/test/Analysis/GlobalsModRef/chaining-analysis.ll b/llvm/test/Analysis/GlobalsModRef/chaining-analysis.ll index 49244563c0c..e521cc1350f 100644 --- a/llvm/test/Analysis/GlobalsModRef/chaining-analysis.ll +++ b/llvm/test/Analysis/GlobalsModRef/chaining-analysis.ll @@ -1,20 +1,20 @@ -; RUN: llvm-upgrade < %s | llvm-as | opt -globalsmodref-aa -load-vn -gcse | llvm-dis | not grep load +; RUN: llvm-as < %s | opt -globalsmodref-aa -load-vn -gcse | llvm-dis | not grep load -; This test requires the use of previous analyses to determine that  +; This test requires the use of previous analyses to determine that  ; doesnotmodX does not modify X (because 'sin' doesn't). -%X = internal global int 4 +@X = internal global i32 4		; <i32*> [#uses=2] -declare double %sin(double) +declare double @sin(double) readnone -int %test(int *%P) { -  store int 12,  int* %X -  call double %doesnotmodX(double 1.0) -  %V = load int* %X -  ret int %V +define i32 @test(i32* %P) { +	store i32 12, i32* @X +	call double @doesnotmodX( double 1.000000e+00 )		; <double>:1 [#uses=0] +	%V = load i32* @X		; <i32> [#uses=1] +	ret i32 %V  } -double %doesnotmodX(double %V) { -  %V2 = call double %sin(double %V) -  ret double %V2 +define double @doesnotmodX(double %V) { +	%V2 = call double @sin( double %V ) readnone		; <double> [#uses=1] +	ret double %V2  } diff --git a/llvm/test/Analysis/LoadVN/call_cse.ll b/llvm/test/Analysis/LoadVN/call_cse.ll index 78cdd43051f..b62300f5ab3 100644 --- a/llvm/test/Analysis/LoadVN/call_cse.ll +++ b/llvm/test/Analysis/LoadVN/call_cse.ll @@ -1,11 +1,12 @@ -; RUN: llvm-upgrade < %s | llvm-as | opt -basicaa -load-vn -gcse -instcombine | llvm-dis | not grep sub -declare int %strlen(sbyte*) +; RUN: llvm-as < %s | opt -basicaa -load-vn -gcse -instcombine | llvm-dis | not grep sub -int %test(sbyte* %P) { -	%X = call int %strlen(sbyte* %P) -	%A = add int %X, 14 -	%Y = call int %strlen(sbyte* %P) -	%Z = sub int %X, %Y -	%B = add int %A, %Z -	ret int %B +declare i32 @strlen(i8*) readonly + +define i32 @test(i8* %P) { +	%X = call i32 @strlen( i8* %P ) readonly		; <i32> [#uses=2] +	%A = add i32 %X, 14		; <i32> [#uses=1] +	%Y = call i32 @strlen( i8* %P ) readonly		; <i32> [#uses=1] +	%Z = sub i32 %X, %Y		; <i32> [#uses=1] +	%B = add i32 %A, %Z		; <i32> [#uses=1] +	ret i32 %B  } diff --git a/llvm/test/Analysis/LoadVN/call_pure_function.ll b/llvm/test/Analysis/LoadVN/call_pure_function.ll index 302ae604663..8055c5271f4 100644 --- a/llvm/test/Analysis/LoadVN/call_pure_function.ll +++ b/llvm/test/Analysis/LoadVN/call_pure_function.ll @@ -1,13 +1,14 @@ -; RUN: llvm-upgrade < %s | llvm-as | opt -basicaa -load-vn -gcse -instcombine | llvm-dis | not grep sub -declare int %strlen(sbyte*) -declare void %use(int %X) +; RUN: llvm-as < %s | opt -basicaa -load-vn -gcse -instcombine | llvm-dis | not grep sub -sbyte %test(sbyte* %P, sbyte* %Q) { -	%A = load sbyte* %Q -	%X = call int %strlen(sbyte* %P) -	%B = load sbyte* %Q                ;; CSE with A. -	call void %use(int %X)             ;; make strlen not dead +declare i32 @strlen(i8*) readonly -	%C = sub sbyte %A, %B -	ret sbyte %C +declare void @use(i32) + +define i8 @test(i8* %P, i8* %Q) { +	%A = load i8* %Q		; <i8> [#uses=1] +	%X = call i32 @strlen( i8* %P ) readonly		; <i32> [#uses=1] +	%B = load i8* %Q		; <i8> [#uses=1] +	call void @use( i32 %X ) +	%C = sub i8 %A, %B		; <i8> [#uses=1] +	ret i8 %C  } diff --git a/llvm/test/Transforms/ADCE/dce_pure_call.ll b/llvm/test/Transforms/ADCE/dce_pure_call.ll index 79a360c2680..a7414e027ea 100644 --- a/llvm/test/Transforms/ADCE/dce_pure_call.ll +++ b/llvm/test/Transforms/ADCE/dce_pure_call.ll @@ -1,9 +1,8 @@ -; RUN: llvm-upgrade < %s | llvm-as | opt -adce | llvm-dis | not grep call +; RUN: llvm-as < %s | opt -adce | llvm-dis | not grep call -declare int %strlen(sbyte*) +declare i32 @strlen(i8*) readonly -void %test() { -	;; Dead call should be deleted! -	call int %strlen(sbyte *null) +define void @test() { +	call i32 @strlen( i8* null ) readonly		; <i32>:1 [#uses=0]  	ret void  } diff --git a/llvm/test/Transforms/LICM/call_sink_const_function.ll b/llvm/test/Transforms/LICM/call_sink_const_function.ll index a8a4b72d6d6..f187e27335b 100644 --- a/llvm/test/Transforms/LICM/call_sink_const_function.ll +++ b/llvm/test/Transforms/LICM/call_sink_const_function.ll @@ -1,16 +1,17 @@ -; RUN: llvm-upgrade < %s | llvm-as | opt -basicaa -licm | llvm-dis | %prcontext sin 1 | grep Out:  -declare double %sin(double) -declare void %foo() +; RUN: llvm-as < %s | opt -basicaa -licm | llvm-dis | %prcontext sin 1 | grep Out: -double %test(double %X) { -	br label %Loop +declare double @sin(double) readnone + +declare void @foo() -Loop: -	call void %foo()    ;; Unknown effects! +define double @test(double %X) { +	br label %Loop -	%A = call double %sin(double %X)   ;; Can still hoist/sink call -	br bool true, label %Loop, label %Out +Loop:		; preds = %Loop, %0 +	call void @foo( ) +	%A = call double @sin( double %X ) readnone		; <double> [#uses=1] +	br i1 true, label %Loop, label %Out -Out: +Out:		; preds = %Loop  	ret double %A  } diff --git a/llvm/test/Transforms/LICM/call_sink_pure_function.ll b/llvm/test/Transforms/LICM/call_sink_pure_function.ll index e5857a62a6f..c0457a17fc4 100644 --- a/llvm/test/Transforms/LICM/call_sink_pure_function.ll +++ b/llvm/test/Transforms/LICM/call_sink_pure_function.ll @@ -1,14 +1,16 @@ -; RUN: llvm-upgrade < %s | llvm-as | opt -basicaa -licm | llvm-dis | %prcontext strlen 1 | grep Out:  -declare int %strlen(sbyte*) -declare void %foo() +; RUN: llvm-as < %s | opt -basicaa -licm | llvm-dis | %prcontext strlen 1 | grep Out: -int %test(sbyte* %P) { +declare i32 @strlen(i8*) readonly + +declare void @foo() + +define i32 @test(i8* %P) {  	br label %Loop -Loop: -	%A = call int %strlen(sbyte* %P)   ;; Can hoist/sink call -	br bool false, label %Loop, label %Out +Loop:		; preds = %Loop, %0 +	%A = call i32 @strlen( i8* %P ) readonly		; <i32> [#uses=1] +	br i1 false, label %Loop, label %Out -Out: -	ret int %A +Out:		; preds = %Loop +	ret i32 %A  } diff --git a/llvm/test/Transforms/LoopRotate/pr1154.ll b/llvm/test/Transforms/LoopRotate/pr1154.ll index 09c940548f8..025bc5694b6 100644 --- a/llvm/test/Transforms/LoopRotate/pr1154.ll +++ b/llvm/test/Transforms/LoopRotate/pr1154.ll @@ -1,13 +1,12 @@ -; RUN: llvm-upgrade < %s | llvm-as | opt -std-compile-opts | llvm-dis | \ +; RUN: llvm-as < %s | opt -std-compile-opts | llvm-dis | \  ; RUN:   %prcontext strstr 2 | grep -v declare | grep bb36.outer: -; END.  @str = internal constant [68 x i8] c"Dot. date. datum. 123. Some more doubtful demonstration dummy data.\00"		; <[68 x i8]*> [#uses=1]  @str1 = internal constant [5 x i8] c"ummy\00"		; <[5 x i8]*> [#uses=1]  @str2 = internal constant [6 x i8] c" data\00"		; <[6 x i8]*> [#uses=1]  @str3 = internal constant [3 x i8] c"by\00"		; <[3 x i8]*> [#uses=1] -i32 @stringSearch_Clib(i32 %count) { +define i32 @stringSearch_Clib(i32 %count) {  entry:  	%count_addr = alloca i32		; <i32*> [#uses=2]  	%retval = alloca i32, align 4		; <i32*> [#uses=2] @@ -17,11 +16,11 @@ entry:  	%j = alloca i32, align 4		; <i32*> [#uses=4]  	%p = alloca i8*, align 4		; <i8**> [#uses=6]  	%b = alloca [68 x i8], align 16		; <[68 x i8]*> [#uses=6] -	"alloca point" = bitcast i32 0 to i32		; <i32> [#uses=0] +	%"alloca point" = bitcast i32 0 to i32		; <i32> [#uses=0]  	store i32 %count, i32* %count_addr  	store i32 0, i32* %c  	%b1 = bitcast [68 x i8]* %b to i8*		; <i8*> [#uses=1] -	%tmp2 = getelementptr [68 x i8]* @str, i32 0, i32 0		; <i8*> [#uses=1] +	%tmp2 = getelementptr [68 x i8]* @str, i64 0, i64 0		; <i8*> [#uses=1]  	call void @llvm.memcpy.i32( i8* %b1, i8* %tmp2, i32 68, i32 1 )  	store i32 0, i32* %j  	br label %bb41 @@ -34,13 +33,13 @@ bb:		; preds = %bb41  bb4:		; preds = %bb36  	%b5 = bitcast [68 x i8]* %b to i8*		; <i8*> [#uses=1] -	%tmp6 = getelementptr [5 x i8]* @str1, i32 0, i32 0		; <i8*> [#uses=1] -	%tmp7 = call i8* @strstr( i8* %b5, i8* %tmp6 )		; <i8*> [#uses=1] +	%tmp6 = getelementptr [5 x i8]* @str1, i64 0, i64 0		; <i8*> [#uses=1] +	%tmp7 = call i8* @strstr( i8* %b5, i8* %tmp6 ) readonly		; <i8*> [#uses=1]  	store i8* %tmp7, i8** %p  	%tmp8 = load i8** %p		; <i8*> [#uses=1] -	%ttmp8 = icmp ne i8* %tmp8, null		; <i1>:0 [#uses=1] -	%ttmp10 = zext i1 %ttmp8 to i8		; <i8>:1 [#uses=1] -	%ttmp7 = icmp ne i8 %ttmp10, 0		; <i1>:2 [#uses=1] +	%ttmp8 = icmp ne i8* %tmp8, null		; <i1> [#uses=1] +	%ttmp10 = zext i1 %ttmp8 to i8		; <i8> [#uses=1] +	%ttmp7 = icmp ne i8 %ttmp10, 0		; <i1> [#uses=1]  	br i1 %ttmp7, label %cond_true, label %cond_next  cond_true:		; preds = %bb4 @@ -56,13 +55,13 @@ cond_true:		; preds = %bb4  cond_next:		; preds = %cond_true, %bb4  	%b16 = bitcast [68 x i8]* %b to i8*		; <i8*> [#uses=1] -	%tmp17 = getelementptr [6 x i8]* @str2, i32 0, i32 0		; <i8*> [#uses=1] -	%tmp18 = call i8* @strstr( i8* %b16, i8* %tmp17 )		; <i8*> [#uses=1] +	%tmp17 = getelementptr [6 x i8]* @str2, i64 0, i64 0		; <i8*> [#uses=1] +	%tmp18 = call i8* @strstr( i8* %b16, i8* %tmp17 ) readonly		; <i8*> [#uses=1]  	store i8* %tmp18, i8** %p  	%tmp19 = load i8** %p		; <i8*> [#uses=1] -	%ttmp6 = icmp ne i8* %tmp19, null		; <i1>:3 [#uses=1] -	%ttmp9 = zext i1 %ttmp6 to i8		; <i8>:4 [#uses=1] -	%ttmp4 = icmp ne i8 %ttmp9, 0		; <i1>:5 [#uses=1] +	%ttmp6 = icmp ne i8* %tmp19, null		; <i1> [#uses=1] +	%ttmp9 = zext i1 %ttmp6 to i8		; <i8> [#uses=1] +	%ttmp4 = icmp ne i8 %ttmp9, 0		; <i1> [#uses=1]  	br i1 %ttmp4, label %cond_true20, label %cond_next28  cond_true20:		; preds = %cond_next @@ -78,8 +77,8 @@ cond_true20:		; preds = %cond_next  cond_next28:		; preds = %cond_true20, %cond_next  	%b29 = bitcast [68 x i8]* %b to i8*		; <i8*> [#uses=1] -	%tmp30 = getelementptr [3 x i8]* @str3, i32 0, i32 0		; <i8*> [#uses=1] -	%tmp31 = call i32 @strcspn( i8* %b29, i8* %tmp30 )		; <i32> [#uses=1] +	%tmp30 = getelementptr [3 x i8]* @str3, i64 0, i64 0		; <i8*> [#uses=1] +	%tmp31 = call i32 @strcspn( i8* %b29, i8* %tmp30 ) readonly		; <i32> [#uses=1]  	%tmp32 = load i32* %c		; <i32> [#uses=1]  	%tmp33 = add i32 %tmp31, %tmp32		; <i32> [#uses=1]  	store i32 %tmp33, i32* %c @@ -90,9 +89,9 @@ cond_next28:		; preds = %cond_true20, %cond_next  bb36:		; preds = %cond_next28, %bb  	%tmp37 = load i32* %i		; <i32> [#uses=1] -	%ttmp3= icmp sle i32 %tmp37, 249		; <i1>:6 [#uses=1] -	%ttmp12 = zext i1 %ttmp3 to i8		; <i8>:7 [#uses=1] -	%ttmp1 = icmp ne i8 %ttmp12, 0		; <i1>:8 [#uses=1] +	%ttmp3 = icmp sle i32 %tmp37, 249		; <i1> [#uses=1] +	%ttmp12 = zext i1 %ttmp3 to i8		; <i8> [#uses=1] +	%ttmp1 = icmp ne i8 %ttmp12, 0		; <i1> [#uses=1]  	br i1 %ttmp1, label %bb4, label %bb38  bb38:		; preds = %bb36 @@ -104,9 +103,9 @@ bb38:		; preds = %bb36  bb41:		; preds = %bb38, %entry  	%tmp42 = load i32* %j		; <i32> [#uses=1]  	%tmp43 = load i32* %count_addr		; <i32> [#uses=1] -	%ttmp2 = icmp slt i32 %tmp42, %tmp43		; <i1>:9 [#uses=1] -	%ttmp11 = zext i1 %ttmp2 to i8		; <i8>:10 [#uses=1] -	%ttmp5 = icmp ne i8 %ttmp11, 0		; <i1>:11 [#uses=1] +	%ttmp2 = icmp slt i32 %tmp42, %tmp43		; <i1> [#uses=1] +	%ttmp11 = zext i1 %ttmp2 to i8		; <i8> [#uses=1] +	%ttmp5 = icmp ne i8 %ttmp11, 0		; <i1> [#uses=1]  	br i1 %ttmp5, label %bb, label %bb44  bb44:		; preds = %bb41 @@ -123,6 +122,6 @@ return:		; preds = %bb44  declare void @llvm.memcpy.i32(i8*, i8*, i32, i32) -declare i8* @strstr(i8*, i8*) +declare i8* @strstr(i8*, i8*) readonly -declare i32 @strcspn(i8*, i8*) +declare i32 @strcspn(i8*, i8*) readonly  | 

