mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
012a27a068
Summary: This was motivated by absence of PrunEH functionality in new PM. It was decided that a proper way to do PruneEH is to add NoUnwind inference into PostOrderFunctionAttrs and then perform normal SimplifyCFG on top. This change generalizes attribute handling implemented for (a removal of) Convergent attribute, by introducing a generic builder-like class AttributeInferer It registers all the attribute inference requests, storing per-attribute predicates into a vector, and then goes through an SCC Node, scanning all the instructions for not breaking attribute assumptions. The main idea is that as soon all the instructions from all the functions of SCC Node conform to attribute assumptions then we are free to infer the attribute as set for all the functions of SCC Node. It handles two distinct cases of attributes: - those that might break due to derefinement of the function code for these attributes we are allowed to apply inference only if all the functions are "exact definitions". Example - NoUnwind. - those that do not care about derefinement for these attributes we are allowed to apply inference as soon as we see any function definition. Example - removal of Convergent attribute. Also in this commit: * Converted all the FunctionAttrs tests to use FileCheck and added new-PM invocations to them * FunctionAttrs/convergent.ll test demonstrates a difference in behavior between new and old PM implementations. Marked with FIXME. * PruneEH tests were converted to new-PM as well, using function-attrs+simplify-cfg combo as intended * some of "other" tests were updated since function-attrs now infers 'nounwind' even for old PM pipeline * -disable-nounwind-inference hidden option added as a possible workaround for a supposedly rare case when nounwind being inferred by default presents a problem Reviewers: chandlerc, jlebar Reviewed By: jlebar Subscribers: eraman, llvm-commits Differential Revision: https://reviews.llvm.org/D44415 llvm-svn: 328377
71 lines
1.7 KiB
LLVM
71 lines
1.7 KiB
LLVM
; PruneEH is less powerful than simplify-cfg in terms of cfg simplification,
|
|
; so it leaves some of the unreachable stuff hanging around.
|
|
; Checking it with CHECK-OLD.
|
|
;
|
|
; RUN: opt -prune-eh -S < %s | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-OLD
|
|
; RUN: opt -passes='function-attrs,function(simplify-cfg)' -S < %s | FileCheck %s --check-prefix=CHECK --check-prefix=CHECK-NEW
|
|
|
|
target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
|
|
target triple = "i386-pc-windows-msvc"
|
|
|
|
declare void @neverthrows() nounwind
|
|
|
|
define void @test1() personality i32 (...)* @__CxxFrameHandler3 {
|
|
invoke void @neverthrows()
|
|
to label %try.cont unwind label %cleanuppad
|
|
|
|
try.cont:
|
|
ret void
|
|
|
|
cleanuppad:
|
|
%cp = cleanuppad within none []
|
|
br label %cleanupret
|
|
|
|
cleanupret:
|
|
cleanupret from %cp unwind to caller
|
|
}
|
|
|
|
; CHECK-LABEL: define void @test1(
|
|
; CHECK: call void @neverthrows()
|
|
; CHECK-NEW-NEXT: ret void
|
|
; CHECK-NEW-NEXT: }
|
|
; CHECK-OLD: ret void
|
|
|
|
; CHECK-OLD: %[[cp:.*]] = cleanuppad within none []
|
|
; CHECK-OLD-NEXT: unreachable
|
|
|
|
; CHECK-OLD: cleanupret from %[[cp]] unwind to caller
|
|
|
|
define void @test2() personality i32 (...)* @__CxxFrameHandler3 {
|
|
invoke void @neverthrows()
|
|
to label %try.cont unwind label %catchswitch
|
|
|
|
try.cont:
|
|
ret void
|
|
|
|
catchswitch:
|
|
%cs = catchswitch within none [label %catchpad] unwind to caller
|
|
|
|
catchpad:
|
|
%cp = catchpad within %cs []
|
|
unreachable
|
|
|
|
ret:
|
|
ret void
|
|
}
|
|
|
|
; CHECK-LABEL: define void @test2(
|
|
; CHECK: call void @neverthrows()
|
|
; CHECK-NEW-NEXT: ret void
|
|
; CHECK-NEW-NEXT: }
|
|
; CHECK-OLD: ret void
|
|
|
|
; CHECK-OLD: %[[cs:.*]] = catchswitch within none [label
|
|
|
|
; CHECK-OLD: catchpad within %[[cs]] []
|
|
; CHECK-OLD-NEXT: unreachable
|
|
|
|
; CHECK-OLD:ret void
|
|
|
|
declare i32 @__CxxFrameHandler3(...)
|