brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.7 KiB · abfe820 Raw
116 lines · plain
1; For instructions explicitly defined as mayThrow, make sure they prevent nounwind propagation2; RUN: split-file %s %t3; RUN: opt -thinlto-bc %t/main.ll -thin-link-bitcode-file=%t1.thinlink.bc -o %t1.bc4; RUN: opt -thinlto-bc %t/callees.ll -thin-link-bitcode-file=%t2.thinlink.bc -o %t2.bc5; RUN: llvm-lto2 run -disable-thinlto-funcattrs=0 %t1.bc %t2.bc -o %t.o -r %t1.bc,caller,px -r %t1.bc,caller1,px -r %t1.bc,caller2,px -r %t1.bc,caller_nounwind,px  \6; RUN:               -r %t1.bc,cleanupret,l -r %t1.bc,catchret,l -r %t1.bc,resume,l -r %t1.bc,cleanupret_nounwind,l \7; RUN:               -r %t2.bc,cleanupret,px -r %t2.bc,catchret,px -r %t2.bc,resume,px -r %t2.bc,cleanupret_nounwind,px -r %t2.bc,nonThrowing,px -r %t2.bc,__gxx_personality_v0,px -save-temps8; RUN: llvm-dis -o - %t2.bc | FileCheck %s --check-prefix=SUMMARY9; RUN: llvm-dis -o - %t.o.1.3.import.bc | FileCheck %s10 11;--- main.ll12target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"13target triple = "x86_64-unknown-linux-gnu"14 15declare void @cleanupret()16declare void @catchret()17declare void @resume()18 19; Functions can have mayThrow instructions but also be marked noUnwind20; if they have terminate semantics (e.g. noexcept). In such cases21; propagation trusts the original noUnwind value in the function summary22declare void @cleanupret_nounwind()23 24; CHECK: define void @caller() [[ATTR_MAYTHROW:#[0-9]+]]25define void @caller() {26  call void @cleanupret()27  ret void28}29 30; CHECK: define void @caller1() [[ATTR_MAYTHROW:#[0-9]+]]31define void @caller1() {32  call void @catchret()33  ret void34}35 36; CHECK: define void @caller2() [[ATTR_MAYTHROW:#[0-9]+]]37define void @caller2() {38  call void @resume()39  ret void40}41 42; CHECK: define void @caller_nounwind() [[ATTR_NOUNWIND:#[0-9]+]]43define void @caller_nounwind() {44    call void @cleanupret_nounwind()45    ret void46}47 48; CHECK-DAG: attributes [[ATTR_NOUNWIND]] = { norecurse nounwind }49; CHECK-DAG: attributes [[ATTR_MAYTHROW]] = { norecurse }50 51; SUMMARY-DAG: = gv: (name: "cleanupret", summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0, importType: definition), insts: 4, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 0, mayThrow: 1, hasUnknownCall: 0, mustBeUnreachable: 0), calls: ((callee: ^{{.*}})), refs: (^{{.*}}))))52; SUMMARY-DAG: = gv: (name: "resume", summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0, importType: definition), insts: 4, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 0, mayThrow: 1, hasUnknownCall: 0, mustBeUnreachable: 0), calls: ((callee: ^{{.*}})), refs: (^{{.*}}))))53; SUMMARY-DAG: = gv: (name: "catchret", summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 0, dsoLocal: 0, canAutoHide: 0, importType: definition), insts: 5, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 0, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 0, mayThrow: 1, hasUnknownCall: 0, mustBeUnreachable: 0), calls: ((callee: ^{{.*}})), refs: (^{{.*}}))))54 55;--- callees.ll56target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"57target triple = "x86_64-unknown-linux-gnu"58attributes #0 = { nounwind }59 60define void @nonThrowing() #0 {61    ret void62}63 64declare i32 @__gxx_personality_v0(...)65 66define void @cleanupret() personality ptr @__gxx_personality_v0 {67entry:68  invoke void @nonThrowing()69          to label %exit unwind label %pad70pad:71  %cp = cleanuppad within none [i7 4]72  cleanupret from %cp unwind to caller73exit:74  ret void75}76 77define void @catchret() personality ptr @__gxx_personality_v0 {78entry:79  invoke void @nonThrowing()80          to label %exit unwind label %pad81pad:82  %cs1 = catchswitch within none [label %catch] unwind to caller83catch:84  %cp = catchpad within %cs1 [i7 4]85  catchret from %cp to label %exit86exit:87  ret void88}89 90define void @resume() uwtable optsize ssp personality ptr @__gxx_personality_v0 {91entry:92  invoke void @nonThrowing()93          to label %try.cont unwind label %lpad94 95try.cont:                                         ; preds = %entry, %invoke.cont496  ret void97 98lpad:                                             ; preds = %entry99  %exn = landingpad {ptr, i32}100           cleanup101  resume { ptr, i32 } %exn102}103 104define void @cleanupret_nounwind() #0 personality ptr @__gxx_personality_v0 {105entry:106  invoke void @nonThrowing()107          to label %exit unwind label %pad108pad:109  %cp = cleanuppad within none [i7 4]110  cleanupret from %cp unwind to caller111exit:112  ret void113}114 115attributes #0 = { nounwind }116