diff --git a/llvm/test/Transforms/HotColdSplit/outline-unless-longjmp.ll b/llvm/test/Transforms/HotColdSplit/outline-unless-longjmp.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Transforms/HotColdSplit/outline-unless-longjmp.ll @@ -0,0 +1,66 @@ +; REQUIRES: asserts +; RUN: opt -S -hotcoldsplit -debug < %s 2>&1 | FileCheck %s +; RUN: opt -hotcoldsplit %s -o /dev/null + +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%"class.std::ios_base::Init" = type { i8 } +%struct.__jmp_buf_tag = type { [8 x i64], i32, %struct.__sigset_t } +%struct.__sigset_t = type { [16 x i64] } + +@jbuf = dso_local global [1 x %struct.__jmp_buf_tag] zeroinitializer, align 16 + +; CHECK: @f +; CHECK-NOT: {{.*}}@f.cold.1 + + +declare dso_local i32 @__cxa_atexit(void (i8*)*, i8*, i8*) #3 + +define dso_local void @_Z1ai(i32 %i) #4 { +entry: + %i.addr = alloca i32, align 4 + store i32 %i, i32* %i.addr, align 4 + %0 = load i32, i32* %i.addr, align 4 + %add = add nsw i32 %0, 1 + call void @longjmp(%struct.__jmp_buf_tag* getelementptr inbounds ([1 x %struct.__jmp_buf_tag], [1 x %struct.__jmp_buf_tag]* @jbuf, i64 0, i64 0), i32 %add) #8 + unreachable +} + +declare dso_local void @longjmp(%struct.__jmp_buf_tag*, i32) #5 + +define dso_local i32 @f() #6 { +entry: + %retval = alloca i32, align 4 + %i = alloca i32, align 4 + store i32 0, i32* %retval, align 4 + store volatile i32 0, i32* %i, align 4 + %call = call i32 @_setjmp(%struct.__jmp_buf_tag* getelementptr inbounds ([1 x %struct.__jmp_buf_tag], [1 x %struct.__jmp_buf_tag]* @jbuf, i64 0, i64 0)) #9 + %cmp = icmp ne i32 %call, 3 + br i1 %cmp, label %if.then, label %if.end + +if.then: ; preds = %entry + %0 = load volatile i32, i32* %i, align 4 + %inc = add nsw i32 %0, 1 + store volatile i32 %inc, i32* %i, align 4 + call void @_Z1ai(i32 %0) #10 + unreachable + +if.end: ; preds = %entry + ret i32 0 +} + +; Function Attrs: nounwind returns_twice +declare dso_local i32 @_setjmp(%struct.__jmp_buf_tag*) #7 + + +attributes #3 = { nounwind } +attributes #4 = { noinline noreturn nounwind uwtable } +attributes #5 = { noreturn nounwind } +attributes #6 = { noinline norecurse nounwind uwtable } +attributes #7 = { nounwind returns_twice } +attributes #8 = { noreturn nounwind } +attributes #9 = { nounwind returns_twice } +attributes #10 = { noreturn } + +