diff options
Diffstat (limited to 'test/Transforms/MergeFunc')
-rw-r--r-- | test/Transforms/MergeFunc/2011-02-08-RemoveEqual.ll | 8 | ||||
-rw-r--r-- | test/Transforms/MergeFunc/call-and-invoke-with-ranges.ll | 16 | ||||
-rw-r--r-- | test/Transforms/MergeFunc/fold-weak.ll | 48 |
3 files changed, 51 insertions, 21 deletions
diff --git a/test/Transforms/MergeFunc/2011-02-08-RemoveEqual.ll b/test/Transforms/MergeFunc/2011-02-08-RemoveEqual.ll index 4735ea5e61d28..97e8ed5a6edac 100644 --- a/test/Transforms/MergeFunc/2011-02-08-RemoveEqual.ll +++ b/test/Transforms/MergeFunc/2011-02-08-RemoveEqual.ll @@ -22,7 +22,7 @@ target triple = "i386-pc-linux-gnu" @.str = external constant [1 x i8], align 1 @_ZTVN2kc22impl_fileline_FileLineE = external constant [13 x i32 (...)*], align 32 -define void @_ZN2kc22impl_fileline_FileLineC2EPNS_20impl_casestring__StrEi(%"struct.kc::impl_fileline_FileLine"* %this, %"struct.kc::impl_casestring__Str"* %_file, i32 %_line) align 2 { +define void @_ZN2kc22impl_fileline_FileLineC2EPNS_20impl_casestring__StrEi(%"struct.kc::impl_fileline_FileLine"* %this, %"struct.kc::impl_casestring__Str"* %_file, i32 %_line) align 2 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { entry: %this_addr = alloca %"struct.kc::impl_fileline_FileLine"*, align 4 %_file_addr = alloca %"struct.kc::impl_casestring__Str"*, align 4 @@ -75,7 +75,7 @@ bb2: ; preds = %bb1, %invcont ret void lpad: ; preds = %bb - %eh_ptr = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + %eh_ptr = landingpad { i8*, i32 } cleanup %exn = extractvalue { i8*, i32 } %eh_ptr, 0 store i8* %exn, i8** %eh_exception @@ -148,7 +148,7 @@ return: ; preds = %bb1, %entry ret void } -define void @_ZN2kc22impl_fileline_FileLineC1EPNS_20impl_casestring__StrEi(%"struct.kc::impl_fileline_FileLine"* %this, %"struct.kc::impl_casestring__Str"* %_file, i32 %_line) align 2 { +define void @_ZN2kc22impl_fileline_FileLineC1EPNS_20impl_casestring__StrEi(%"struct.kc::impl_fileline_FileLine"* %this, %"struct.kc::impl_casestring__Str"* %_file, i32 %_line) align 2 personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) { entry: %this_addr = alloca %"struct.kc::impl_fileline_FileLine"*, align 4 %_file_addr = alloca %"struct.kc::impl_casestring__Str"*, align 4 @@ -201,7 +201,7 @@ bb2: ; preds = %bb1, %invcont ret void lpad: ; preds = %bb - %eh_ptr = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*) + %eh_ptr = landingpad { i8*, i32 } cleanup %exn = extractvalue { i8*, i32 } %eh_ptr, 0 store i8* %exn, i8** %eh_exception diff --git a/test/Transforms/MergeFunc/call-and-invoke-with-ranges.ll b/test/Transforms/MergeFunc/call-and-invoke-with-ranges.ll index 99eba5e280944..b955e3c9582e6 100644 --- a/test/Transforms/MergeFunc/call-and-invoke-with-ranges.ll +++ b/test/Transforms/MergeFunc/call-and-invoke-with-ranges.ll @@ -26,18 +26,18 @@ define i8 @call_different_range() { ret i8 %out } -define i8 @invoke_with_range() { +define i8 @invoke_with_range() personality i8* undef { %out = invoke i8 @dummy() to label %next unwind label %lpad, !range !0 next: ret i8 %out lpad: - %pad = landingpad { i8*, i32 } personality i8* undef cleanup + %pad = landingpad { i8*, i32 } cleanup resume { i8*, i32 } zeroinitializer } -define i8 @invoke_no_range() { +define i8 @invoke_no_range() personality i8* undef { ; CHECK-LABEL: @invoke_no_range() ; CHECK-NEXT: invoke i8 @dummy %out = invoke i8 @dummy() to label %next unwind label %lpad @@ -46,11 +46,11 @@ next: ret i8 %out lpad: - %pad = landingpad { i8*, i32 } personality i8* undef cleanup + %pad = landingpad { i8*, i32 } cleanup resume { i8*, i32 } zeroinitializer } -define i8 @invoke_different_range() { +define i8 @invoke_different_range() personality i8* undef { ; CHECK-LABEL: @invoke_different_range() ; CHECK-NEXT: invoke i8 @dummy %out = invoke i8 @dummy() to label %next unwind label %lpad, !range !1 @@ -59,7 +59,7 @@ next: ret i8 %out lpad: - %pad = landingpad { i8*, i32 } personality i8* undef cleanup + %pad = landingpad { i8*, i32 } cleanup resume { i8*, i32 } zeroinitializer } @@ -71,7 +71,7 @@ define i8 @call_with_same_range() { ret i8 %out } -define i8 @invoke_with_same_range() { +define i8 @invoke_with_same_range() personality i8* undef { ; CHECK-LABEL: @invoke_with_same_range() ; CHECK: tail call i8 @invoke_with_range() %out = invoke i8 @dummy() to label %next unwind label %lpad, !range !0 @@ -80,7 +80,7 @@ next: ret i8 %out lpad: - %pad = landingpad { i8*, i32 } personality i8* undef cleanup + %pad = landingpad { i8*, i32 } cleanup resume { i8*, i32 } zeroinitializer } diff --git a/test/Transforms/MergeFunc/fold-weak.ll b/test/Transforms/MergeFunc/fold-weak.ll index 4df6e39c12565..f8a1888789050 100644 --- a/test/Transforms/MergeFunc/fold-weak.ll +++ b/test/Transforms/MergeFunc/fold-weak.ll @@ -1,17 +1,47 @@ -; RUN: opt < %s -mergefunc -S > %t -; RUN: grep "define weak" %t | count 2 -; RUN: grep "call" %t | count 2 -; XFAIL: * - -; This test is off for a bit as we change this particular sort of folding to -; only apply on ELF systems and not Mach-O systems. +; RUN: opt -S -mergefunc < %s | FileCheck %s define weak i32 @sum(i32 %x, i32 %y) { %sum = add i32 %x, %y - ret i32 %sum + %sum2 = add i32 %sum, %y + %sum3 = add i32 %sum2, %y + ret i32 %sum3 } define weak i32 @add(i32 %x, i32 %y) { %sum = add i32 %x, %y - ret i32 %sum + %sum2 = add i32 %sum, %y + %sum3 = add i32 %sum2, %y + ret i32 %sum3 +} + +; Don't replace a weak function use by another equivalent function. We don't +; know whether the symbol that will ulitmately be linked is equivalent - we +; don't know that the weak definition is the definitive definition or whether it +; will be overriden by a stronger definition). + +; CHECK-LABEL: define private i32 @0 +; CHECK: add i32 +; CHECK: add i32 +; CHECK: add i32 +; CHECK: ret + +; CHECK-LABEL: define i32 @use_weak +; CHECK: call i32 @add +; CHECK: call i32 @sum +; CHECK: ret + +; CHECK-LABEL: define weak i32 @sum +; CHECK: tail call i32 @0 +; CHECK: ret + +; CHECK-LABEL: define weak i32 @add +; CHECK: tail call i32 @0 +; CHECK: ret + + +define i32 @use_weak(i32 %a, i32 %b) { + %res = call i32 @add(i32 %a, i32 %b) + %res2 = call i32 @sum(i32 %a, i32 %b) + %res3 = add i32 %res, %res2 + ret i32 %res3 } |