aboutsummaryrefslogtreecommitdiffstats
path: root/test/Analysis
diff options
context:
space:
mode:
authorVictor Hernandez <vhernandez@apple.com>2009-11-05 00:03:03 +0000
committerVictor Hernandez <vhernandez@apple.com>2009-11-05 00:03:03 +0000
commit24f934d0551e33508c4ffd24318ea0e970db9810 (patch)
tree0d40c74486a929769f400842743d2e3c2d23100f /test/Analysis
parent61ecbd196c0128abb8c588aebc456ed96cdf1d63 (diff)
downloadexternal_llvm-24f934d0551e33508c4ffd24318ea0e970db9810.zip
external_llvm-24f934d0551e33508c4ffd24318ea0e970db9810.tar.gz
external_llvm-24f934d0551e33508c4ffd24318ea0e970db9810.tar.bz2
Update CreateMalloc so that its callers specify the size to allocate:
MallocInst-autoupgrade users use non-TargetData-computed allocation sizes. Optimization uses use TargetData to compute the allocation size. Now that malloc calls can have constant sizes, update isArrayMallocHelper() to use TargetData to determine the size of the malloced type and the size of malloced arrays. Extend getMallocType() to support malloc calls that have non-bitcast uses. Update OptimizeGlobalAddressOfMalloc() to optimize malloc calls that have non-bitcast uses. The bitcast use of a malloc call has to be treated specially here because the uses of the bitcast need to be replaced and the bitcast needs to be erased (just like the malloc call) for OptimizeGlobalAddressOfMalloc() to work correctly. Update PerformHeapAllocSRoA() to optimize malloc calls that have non-bitcast uses. The bitcast use of the malloc is not handled specially here because ReplaceUsesOfMallocWithGlobal replaces through the bitcast use. Update OptimizeOnceStoredGlobal() to not care about the malloc calls' bitcast use. Update all globalopt malloc tests to not rely on autoupgraded-MallocInsts, but instead use explicit malloc calls with correct allocation sizes. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@86077 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis')
-rw-r--r--test/Analysis/PointerTracking/sizes.ll18
1 files changed, 14 insertions, 4 deletions
diff --git a/test/Analysis/PointerTracking/sizes.ll b/test/Analysis/PointerTracking/sizes.ll
index c0b0606..267c3b8 100644
--- a/test/Analysis/PointerTracking/sizes.ll
+++ b/test/Analysis/PointerTracking/sizes.ll
@@ -31,6 +31,7 @@ entry:
}
declare i32 @bar(i8*)
+declare i32 @bar2(i64*)
define i32 @foo1(i32 %n) nounwind {
entry:
@@ -60,11 +61,16 @@ entry:
ret i32 %add16
}
-define i32 @foo2(i32 %n) nounwind {
+define i32 @foo2(i64 %n) nounwind {
entry:
- %call = malloc i8, i32 %n ; <i8*> [#uses=1]
+ %call = tail call i8* @malloc(i64 %n) ; <i8*> [#uses=1]
; CHECK: %call =
; CHECK: ==> %n elements, %n bytes allocated
+ %mallocsize = mul i64 %n, 8 ; <i64> [#uses=1]
+ %malloccall = tail call i8* @malloc(i64 %mallocsize) ; <i8*> [#uses=1]
+ %call3 = bitcast i8* %malloccall to i64* ; <i64*> [#uses=1]
+; CHECK: %malloccall =
+; CHECK: ==> (8 * %n) elements, (8 * %n) bytes allocated
%call2 = tail call i8* @calloc(i64 2, i64 4) nounwind ; <i8*> [#uses=1]
; CHECK: %call2 =
; CHECK: ==> 8 elements, 8 bytes allocated
@@ -72,13 +78,17 @@ entry:
; CHECK: %call4 =
; CHECK: ==> 16 elements, 16 bytes allocated
%call6 = tail call i32 @bar(i8* %call) nounwind ; <i32> [#uses=1]
+ %call7 = tail call i32 @bar2(i64* %call3) nounwind ; <i32> [#uses=1]
%call8 = tail call i32 @bar(i8* %call2) nounwind ; <i32> [#uses=1]
%call10 = tail call i32 @bar(i8* %call4) nounwind ; <i32> [#uses=1]
- %add = add i32 %call8, %call6 ; <i32> [#uses=1]
- %add11 = add i32 %add, %call10 ; <i32> [#uses=1]
+ %add = add i32 %call8, %call6 ; <i32> [#uses=1]
+ %add10 = add i32 %add, %call7 ; <i32> [#uses=1]
+ %add11 = add i32 %add10, %call10 ; <i32> [#uses=1]
ret i32 %add11
}
+declare noalias i8* @malloc(i64) nounwind
+
declare noalias i8* @calloc(i64, i64) nounwind
declare noalias i8* @realloc(i8* nocapture, i64) nounwind