1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2025-01-31 12:41:49 +01:00

HotColdSplitting: Do not outline within noreturn functions

A function marked `noreturn` may contain unreachable terminators: these
should not be considered cold, as the function may be a trampoline.

rdar://58068594
This commit is contained in:
Vedant Kumar 2019-12-19 14:03:22 -08:00
parent fe5f5af18a
commit 880c712961
2 changed files with 25 additions and 0 deletions

View File

@ -207,6 +207,11 @@ bool HotColdSplitting::shouldOutlineFrom(const Function &F) const {
if (F.hasFnAttribute(Attribute::NoInline))
return false;
// A function marked `noreturn` may contain unreachable terminators: these
// should not be considered cold, as the function may be a trampoline.
if (F.hasFnAttribute(Attribute::NoReturn))
return false;
if (F.hasFnAttribute(Attribute::SanitizeAddress) ||
F.hasFnAttribute(Attribute::SanitizeHWAddress) ||
F.hasFnAttribute(Attribute::SanitizeThread) ||

View File

@ -23,6 +23,24 @@ define void @foo(i32, %struct.__jmp_buf_tag*) {
ret void
}
; Don't outline within a noreturn function.
; CHECK: define {{.*}}@xpc_objc_main(i32 {{.*}}) [[XPC_OBJC_MAIN_ATTRS:#[0-9]+]]
; CHECK-NOT: xpc_objc_main.cold.1
define void @xpc_objc_main(i32) noreturn {
%2 = icmp eq i32 %0, 0
tail call void @_Z10sideeffectv()
br i1 %2, label %4, label %3
; <label>:3: ; preds = %2
call void @_Z10sideeffectv()
unreachable
; <label>:4: ; preds = %2
; Crash with an error message, "not supposed to return".
unreachable
}
; Do outline noreturn calls marked cold.
; CHECK-LABEL: define {{.*}}@bar(
@ -62,6 +80,8 @@ define void @baz(i32, %struct.__jmp_buf_tag*) {
; CHECK-LABEL: define {{.*}}@bar.cold.1(
; CHECK: call {{.*}}@llvm.trap(
; CHECK: attributes [[XPC_OBJC_MAIN_ATTRS]] = { noreturn }
declare void @sink() cold
declare void @llvm.trap() noreturn cold