forked from OSchip/llvm-project
Revert new files from new pass manager coro-split/coro-elide
This reverts
https://reviews.llvm.org/rG7125d66f9969605d886b5286780101a45b5bed67 and
https://reviews.llvm.org/rG00fec8004aca6588d8d695a2c3827c3754c380a0 due
to buildbot failures:
http://lab.llvm.org:8011/builders/clang-cmake-x86_64-sde-avx512-linux/builds/34004
Previous revert 11053a1cc6
missed newly
added files, this commit removes those as well.
This commit is contained in:
parent
aa2ae6af81
commit
e999aa38d1
|
@ -1,30 +0,0 @@
|
|||
//===---- CoroElide.h - Coroutine frame allocation elision ------*- C++ -*-===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// \file
|
||||
// This file declares a pass that replaces dynamic allocation of coroutine
|
||||
// frames with alloca and replaces calls to llvm.coro.resume and
|
||||
// llvm.coro.destroy with direct calls to coroutine sub-functions.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_TRANSFORMS_COROUTINES_COROELIDE_H
|
||||
#define LLVM_TRANSFORMS_COROUTINES_COROELIDE_H
|
||||
|
||||
#include "llvm/IR/PassManager.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
class Function;
|
||||
|
||||
struct CoroElidePass : PassInfoMixin<CoroElidePass> {
|
||||
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
|
||||
};
|
||||
} // end namespace llvm
|
||||
|
||||
#endif // LLVM_TRANSFORMS_COROUTINES_COROELIDE_H
|
|
@ -1,30 +0,0 @@
|
|||
//===- CoroSplit.h - Converts a coroutine into a state machine -*- C++ -*--===//
|
||||
//
|
||||
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||
// See https://llvm.org/LICENSE.txt for license information.
|
||||
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
//
|
||||
// \file
|
||||
// This file declares the pass that builds the coroutine frame and outlines
|
||||
// the resume and destroy parts of the coroutine into separate functions.
|
||||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
#ifndef LLVM_TRANSFORMS_COROUTINES_COROSPLIT_H
|
||||
#define LLVM_TRANSFORMS_COROUTINES_COROSPLIT_H
|
||||
|
||||
#include "llvm/Analysis/CGSCCPassManager.h"
|
||||
#include "llvm/Analysis/LazyCallGraph.h"
|
||||
#include "llvm/IR/PassManager.h"
|
||||
|
||||
namespace llvm {
|
||||
|
||||
struct CoroSplitPass : PassInfoMixin<CoroSplitPass> {
|
||||
PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
|
||||
LazyCallGraph &CG, CGSCCUpdateResult &UR);
|
||||
};
|
||||
} // end namespace llvm
|
||||
|
||||
#endif // LLVM_TRANSFORMS_COROUTINES_COROSPLIT_H
|
|
@ -1,61 +0,0 @@
|
|||
; Check that we can handle the case when both alloc function and
|
||||
; the user body consume the same argument.
|
||||
; RUN: opt < %s -coro-split -S | FileCheck %s
|
||||
; RUN: opt < %s -passes=coro-split -S | FileCheck %s
|
||||
|
||||
; using copy of this (as it would happen under -O0)
|
||||
define i8* @f_copy(i64 %this_arg) "coroutine.presplit"="1" {
|
||||
entry:
|
||||
%this.addr = alloca i64
|
||||
store i64 %this_arg, i64* %this.addr
|
||||
%this = load i64, i64* %this.addr
|
||||
%id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
|
||||
%size = call i32 @llvm.coro.size.i32()
|
||||
%alloc = call i8* @myAlloc(i64 %this, i32 %size)
|
||||
%hdl = call i8* @llvm.coro.begin(token %id, i8* %alloc)
|
||||
%0 = call i8 @llvm.coro.suspend(token none, i1 false)
|
||||
switch i8 %0, label %suspend [i8 0, label %resume
|
||||
i8 1, label %cleanup]
|
||||
resume:
|
||||
call void @print2(i64 %this)
|
||||
br label %cleanup
|
||||
|
||||
cleanup:
|
||||
%mem = call i8* @llvm.coro.free(token %id, i8* %hdl)
|
||||
call void @free(i8* %mem)
|
||||
br label %suspend
|
||||
suspend:
|
||||
call i1 @llvm.coro.end(i8* %hdl, i1 0)
|
||||
ret i8* %hdl
|
||||
}
|
||||
|
||||
; See if %this was added to the frame
|
||||
; CHECK: %f_copy.Frame = type { void (%f_copy.Frame*)*, void (%f_copy.Frame*)*, i1, i1, i64 }
|
||||
|
||||
; See that %this is spilled into the frame
|
||||
; CHECK-LABEL: define i8* @f_copy(i64 %this_arg)
|
||||
; CHECK: %this.spill.addr = getelementptr inbounds %f_copy.Frame, %f_copy.Frame* %FramePtr, i32 0, i32 4
|
||||
; CHECK: store i64 %this_arg, i64* %this.spill.addr
|
||||
; CHECK: ret i8* %hdl
|
||||
|
||||
; See that %this was loaded from the frame
|
||||
; CHECK-LABEL: @f_copy.resume(
|
||||
; CHECK: %this.reload = load i64, i64* %this.reload.addr
|
||||
; CHECK: call void @print2(i64 %this.reload)
|
||||
; CHECK: ret void
|
||||
|
||||
declare i8* @llvm.coro.free(token, i8*)
|
||||
declare i32 @llvm.coro.size.i32()
|
||||
declare i8 @llvm.coro.suspend(token, i1)
|
||||
declare void @llvm.coro.resume(i8*)
|
||||
declare void @llvm.coro.destroy(i8*)
|
||||
|
||||
declare token @llvm.coro.id(i32, i8*, i8*, i8*)
|
||||
declare i1 @llvm.coro.alloc(token)
|
||||
declare i8* @llvm.coro.begin(token, i8*)
|
||||
declare i1 @llvm.coro.end(i8*, i1)
|
||||
|
||||
declare noalias i8* @myAlloc(i64, i32)
|
||||
declare double @print(double)
|
||||
declare void @print2(i64)
|
||||
declare void @free(i8*)
|
|
@ -1,58 +0,0 @@
|
|||
; Check that we can handle the case when both alloc function and
|
||||
; the user body consume the same argument.
|
||||
; RUN: opt < %s -coro-split -S | FileCheck %s
|
||||
; RUN: opt < %s -passes=coro-split -S | FileCheck %s
|
||||
|
||||
; using this directly (as it would happen under -O2)
|
||||
define i8* @f_direct(i64 %this) "coroutine.presplit"="1" {
|
||||
entry:
|
||||
%id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
|
||||
%size = call i32 @llvm.coro.size.i32()
|
||||
%alloc = call i8* @myAlloc(i64 %this, i32 %size)
|
||||
%hdl = call i8* @llvm.coro.begin(token %id, i8* %alloc)
|
||||
%0 = call i8 @llvm.coro.suspend(token none, i1 false)
|
||||
switch i8 %0, label %suspend [i8 0, label %resume
|
||||
i8 1, label %cleanup]
|
||||
resume:
|
||||
call void @print2(i64 %this)
|
||||
br label %cleanup
|
||||
|
||||
cleanup:
|
||||
%mem = call i8* @llvm.coro.free(token %id, i8* %hdl)
|
||||
call void @free(i8* %mem)
|
||||
br label %suspend
|
||||
suspend:
|
||||
call i1 @llvm.coro.end(i8* %hdl, i1 0)
|
||||
ret i8* %hdl
|
||||
}
|
||||
|
||||
; See if %this was added to the frame
|
||||
; CHECK: %f_direct.Frame = type { void (%f_direct.Frame*)*, void (%f_direct.Frame*)*, i1, i1, i64 }
|
||||
|
||||
; See that %this is spilled into the frame
|
||||
; CHECK-LABEL: define i8* @f_direct(i64 %this)
|
||||
; CHECK: %this.spill.addr = getelementptr inbounds %f_direct.Frame, %f_direct.Frame* %FramePtr, i32 0, i32 4
|
||||
; CHECK: store i64 %this, i64* %this.spill.addr
|
||||
; CHECK: ret i8* %hdl
|
||||
|
||||
; See that %this was loaded from the frame
|
||||
; CHECK-LABEL: @f_direct.resume(
|
||||
; CHECK: %this.reload = load i64, i64* %this.reload.addr
|
||||
; CHECK: call void @print2(i64 %this.reload)
|
||||
; CHECK: ret void
|
||||
|
||||
declare i8* @llvm.coro.free(token, i8*)
|
||||
declare i32 @llvm.coro.size.i32()
|
||||
declare i8 @llvm.coro.suspend(token, i1)
|
||||
declare void @llvm.coro.resume(i8*)
|
||||
declare void @llvm.coro.destroy(i8*)
|
||||
|
||||
declare token @llvm.coro.id(i32, i8*, i8*, i8*)
|
||||
declare i1 @llvm.coro.alloc(token)
|
||||
declare i8* @llvm.coro.begin(token, i8*)
|
||||
declare i1 @llvm.coro.end(i8*, i1)
|
||||
|
||||
declare noalias i8* @myAlloc(i64, i32)
|
||||
declare double @print(double)
|
||||
declare void @print2(i64)
|
||||
declare void @free(i8*)
|
|
@ -1,98 +0,0 @@
|
|||
; Check that we can handle edge splits leading into a landingpad
|
||||
; RUN: opt < %s -coro-split -S | FileCheck %s
|
||||
; RUN: opt < %s -passes=coro-split -S | FileCheck %s
|
||||
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
; CHECK-LABEL: define internal fastcc void @f.resume(
|
||||
define void @f(i1 %cond) "coroutine.presplit"="1" personality i32 0 {
|
||||
entry:
|
||||
%id = call token @llvm.coro.id(i32 16, i8* null, i8* null, i8* null)
|
||||
%size = tail call i64 @llvm.coro.size.i64()
|
||||
%alloc = call i8* @malloc(i64 %size)
|
||||
%hdl = call i8* @llvm.coro.begin(token %id, i8* %alloc)
|
||||
%sp = call i8 @llvm.coro.suspend(token none, i1 false)
|
||||
switch i8 %sp, label %coro.ret [
|
||||
i8 0, label %resume
|
||||
i8 1, label %cleanup
|
||||
]
|
||||
|
||||
resume:
|
||||
br i1 %cond, label %invoke1, label %invoke2
|
||||
|
||||
invoke1:
|
||||
invoke void @may_throw1()
|
||||
to label %unreach unwind label %pad.with.phi
|
||||
invoke2:
|
||||
invoke void @may_throw2()
|
||||
to label %unreach unwind label %pad.with.phi
|
||||
|
||||
; Verify that we cloned landing pad on every edge and inserted a reload of the spilled value
|
||||
|
||||
; CHECK: pad.with.phi.from.invoke2:
|
||||
; CHECK: %0 = landingpad { i8*, i32 }
|
||||
; CHECK: catch i8* null
|
||||
; CHECK: br label %pad.with.phi
|
||||
|
||||
; CHECK: pad.with.phi.from.invoke1:
|
||||
; CHECK: %1 = landingpad { i8*, i32 }
|
||||
; CHECK: catch i8* null
|
||||
; CHECK: br label %pad.with.phi
|
||||
|
||||
; CHECK: pad.with.phi:
|
||||
; CHECK: %val = phi i32 [ 0, %pad.with.phi.from.invoke1 ], [ 1, %pad.with.phi.from.invoke2 ]
|
||||
; CHECK: %lp = phi { i8*, i32 } [ %0, %pad.with.phi.from.invoke2 ], [ %1, %pad.with.phi.from.invoke1 ]
|
||||
; CHECK: %exn = extractvalue { i8*, i32 } %lp, 0
|
||||
; CHECK: call i8* @__cxa_begin_catch(i8* %exn)
|
||||
; CHECK: call void @use_val(i32 %val)
|
||||
; CHECK: call void @__cxa_end_catch()
|
||||
; CHECK: call void @free(i8* %vFrame)
|
||||
; CHECK: ret void
|
||||
|
||||
pad.with.phi:
|
||||
%val = phi i32 [ 0, %invoke1 ], [ 1, %invoke2 ]
|
||||
%lp = landingpad { i8*, i32 }
|
||||
catch i8* null
|
||||
%exn = extractvalue { i8*, i32 } %lp, 0
|
||||
call i8* @__cxa_begin_catch(i8* %exn)
|
||||
call void @use_val(i32 %val)
|
||||
call void @__cxa_end_catch()
|
||||
br label %cleanup
|
||||
|
||||
cleanup: ; preds = %invoke.cont15, %if.else, %if.then, %ehcleanup21, %init.suspend
|
||||
%mem = call i8* @llvm.coro.free(token %id, i8* %hdl)
|
||||
call void @free(i8* %mem)
|
||||
br label %coro.ret
|
||||
|
||||
coro.ret:
|
||||
call i1 @llvm.coro.end(i8* null, i1 false)
|
||||
ret void
|
||||
|
||||
unreach:
|
||||
unreachable
|
||||
}
|
||||
|
||||
; Function Attrs: argmemonly nounwind readonly
|
||||
declare token @llvm.coro.id(i32, i8* readnone, i8* nocapture readonly, i8*)
|
||||
declare noalias i8* @malloc(i64)
|
||||
declare i64 @llvm.coro.size.i64()
|
||||
declare i8* @llvm.coro.begin(token, i8* writeonly)
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare token @llvm.coro.save(i8*)
|
||||
declare i8 @llvm.coro.suspend(token, i1)
|
||||
|
||||
; Function Attrs: argmemonly nounwind
|
||||
declare void @may_throw1()
|
||||
declare void @may_throw2()
|
||||
|
||||
declare i8* @__cxa_begin_catch(i8*)
|
||||
|
||||
declare void @use_val(i32)
|
||||
declare void @__cxa_end_catch()
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare i1 @llvm.coro.end(i8*, i1)
|
||||
declare void @free(i8*)
|
||||
declare i8* @llvm.coro.free(token, i8* nocapture readonly)
|
|
@ -1,92 +0,0 @@
|
|||
; Check that we can handle edge splits leading into a landingpad
|
||||
; RUN: opt < %s -coro-split -S | FileCheck %s
|
||||
; RUN: opt < %s -passes=coro-split -S | FileCheck %s
|
||||
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
; CHECK-LABEL: define internal fastcc void @g.resume(
|
||||
define void @g(i1 %cond, i32 %x, i32 %y) "coroutine.presplit"="1" personality i32 0 {
|
||||
entry:
|
||||
%id = call token @llvm.coro.id(i32 16, i8* null, i8* null, i8* null)
|
||||
%size = tail call i64 @llvm.coro.size.i64()
|
||||
%alloc = call i8* @malloc(i64 %size)
|
||||
%hdl = call i8* @llvm.coro.begin(token %id, i8* %alloc)
|
||||
%sp = call i8 @llvm.coro.suspend(token none, i1 false)
|
||||
switch i8 %sp, label %coro.ret [
|
||||
i8 0, label %resume
|
||||
i8 1, label %cleanup
|
||||
]
|
||||
|
||||
resume:
|
||||
br i1 %cond, label %invoke1, label %invoke2
|
||||
|
||||
invoke1:
|
||||
invoke void @may_throw1()
|
||||
to label %unreach unwind label %pad.with.phi
|
||||
invoke2:
|
||||
invoke void @may_throw2()
|
||||
to label %unreach unwind label %pad.with.phi
|
||||
|
||||
; Verify that we created cleanuppads on every edge and inserted a reload of the spilled value
|
||||
|
||||
; CHECK: pad.with.phi.from.invoke2:
|
||||
; CHECK: %0 = cleanuppad within none []
|
||||
; CHECK: %y.reload.addr = getelementptr inbounds %g.Frame, %g.Frame* %FramePtr, i32 0, i32 6
|
||||
; CHECK: %y.reload = load i32, i32* %y.reload.addr
|
||||
; CHECK: cleanupret from %0 unwind label %pad.with.phi
|
||||
|
||||
; CHECK: pad.with.phi.from.invoke1:
|
||||
; CHECK: %1 = cleanuppad within none []
|
||||
; CHECK: %x.reload.addr = getelementptr inbounds %g.Frame, %g.Frame* %FramePtr, i32 0, i32 5
|
||||
; CHECK: %x.reload = load i32, i32* %x.reload.addr
|
||||
; CHECK: cleanupret from %1 unwind label %pad.with.phi
|
||||
|
||||
; CHECK: pad.with.phi:
|
||||
; CHECK: %val = phi i32 [ %x.reload, %pad.with.phi.from.invoke1 ], [ %y.reload, %pad.with.phi.from.invoke2 ]
|
||||
; CHECK: %tok = cleanuppad within none []
|
||||
; CHECK: call void @use_val(i32 %val)
|
||||
; CHECK: cleanupret from %tok unwind to caller
|
||||
|
||||
pad.with.phi:
|
||||
%val = phi i32 [ %x, %invoke1 ], [ %y, %invoke2 ]
|
||||
%tok = cleanuppad within none []
|
||||
call void @use_val(i32 %val)
|
||||
cleanupret from %tok unwind to caller
|
||||
|
||||
cleanup: ; preds = %invoke.cont15, %if.else, %if.then, %ehcleanup21, %init.suspend
|
||||
%mem = call i8* @llvm.coro.free(token %id, i8* %hdl)
|
||||
call void @free(i8* %mem)
|
||||
br label %coro.ret
|
||||
|
||||
coro.ret:
|
||||
call i1 @llvm.coro.end(i8* null, i1 false)
|
||||
ret void
|
||||
|
||||
unreach:
|
||||
unreachable
|
||||
}
|
||||
|
||||
; Function Attrs: argmemonly nounwind readonly
|
||||
declare token @llvm.coro.id(i32, i8* readnone, i8* nocapture readonly, i8*)
|
||||
declare noalias i8* @malloc(i64)
|
||||
declare i64 @llvm.coro.size.i64()
|
||||
declare i8* @llvm.coro.begin(token, i8* writeonly)
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare token @llvm.coro.save(i8*)
|
||||
declare i8 @llvm.coro.suspend(token, i1)
|
||||
|
||||
; Function Attrs: argmemonly nounwind
|
||||
declare void @may_throw1()
|
||||
declare void @may_throw2()
|
||||
|
||||
declare i8* @__cxa_begin_catch(i8*)
|
||||
|
||||
declare void @use_val(i32)
|
||||
declare void @__cxa_end_catch()
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare i1 @llvm.coro.end(i8*, i1)
|
||||
declare void @free(i8*)
|
||||
declare i8* @llvm.coro.free(token, i8* nocapture readonly)
|
|
@ -1,89 +0,0 @@
|
|||
; Check that we can handle edge splits leading into a landingpad
|
||||
; RUN: opt < %s -coro-split -S | FileCheck %s
|
||||
; RUN: opt < %s -passes=coro-split -S | FileCheck %s
|
||||
|
||||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
|
||||
target triple = "x86_64-unknown-linux-gnu"
|
||||
|
||||
; CHECK-LABEL: define internal fastcc void @h.resume(
|
||||
define void @h(i1 %cond, i32 %x, i32 %y) "coroutine.presplit"="1" personality i32 0 {
|
||||
entry:
|
||||
%id = call token @llvm.coro.id(i32 16, i8* null, i8* null, i8* null)
|
||||
%size = tail call i64 @llvm.coro.size.i64()
|
||||
%alloc = call i8* @malloc(i64 %size)
|
||||
%hdl = call i8* @llvm.coro.begin(token %id, i8* %alloc)
|
||||
%sp = call i8 @llvm.coro.suspend(token none, i1 false)
|
||||
switch i8 %sp, label %coro.ret [
|
||||
i8 0, label %resume
|
||||
i8 1, label %cleanup
|
||||
]
|
||||
|
||||
resume:
|
||||
br i1 %cond, label %invoke1, label %invoke2
|
||||
|
||||
invoke1:
|
||||
invoke void @may_throw1()
|
||||
to label %coro.ret unwind label %pad.with.phi
|
||||
invoke2:
|
||||
invoke void @may_throw2()
|
||||
to label %coro.ret unwind label %pad.with.phi
|
||||
|
||||
; Verify that we created cleanuppads on every edge and inserted a reload of the spilled value
|
||||
|
||||
; CHECK: pad.with.phi.from.invoke2:
|
||||
; CHECK: %0 = cleanuppad within none []
|
||||
; CHECK: %y.reload.addr = getelementptr inbounds %h.Frame, %h.Frame* %FramePtr, i32 0, i32 6
|
||||
; CHECK: %y.reload = load i32, i32* %y.reload.addr
|
||||
; CHECK: cleanupret from %0 unwind label %pad.with.phi
|
||||
|
||||
; CHECK: pad.with.phi.from.invoke1:
|
||||
; CHECK: %1 = cleanuppad within none []
|
||||
; CHECK: %x.reload.addr = getelementptr inbounds %h.Frame, %h.Frame* %FramePtr, i32 0, i32 5
|
||||
; CHECK: %x.reload = load i32, i32* %x.reload.addr
|
||||
; CHECK: cleanupret from %1 unwind label %pad.with.phi
|
||||
|
||||
; CHECK: pad.with.phi:
|
||||
; CHECK: %val = phi i32 [ %x.reload, %pad.with.phi.from.invoke1 ], [ %y.reload, %pad.with.phi.from.invoke2 ]
|
||||
; CHECK: %switch = catchswitch within none [label %catch] unwind to caller
|
||||
pad.with.phi:
|
||||
%val = phi i32 [ %x, %invoke1 ], [ %y, %invoke2 ]
|
||||
%switch = catchswitch within none [label %catch] unwind to caller
|
||||
|
||||
catch: ; preds = %catch.dispatch
|
||||
%pad = catchpad within %switch [i8* null, i32 64, i8* null]
|
||||
call void @use_val(i32 %val)
|
||||
catchret from %pad to label %coro.ret
|
||||
|
||||
cleanup: ; preds = %invoke.cont15, %if.else, %if.then, %ehcleanup21, %init.suspend
|
||||
%mem = call i8* @llvm.coro.free(token %id, i8* %hdl)
|
||||
call void @free(i8* %mem)
|
||||
br label %coro.ret
|
||||
|
||||
coro.ret:
|
||||
call i1 @llvm.coro.end(i8* null, i1 false)
|
||||
ret void
|
||||
}
|
||||
|
||||
; Function Attrs: argmemonly nounwind readonly
|
||||
declare token @llvm.coro.id(i32, i8* readnone, i8* nocapture readonly, i8*)
|
||||
declare noalias i8* @malloc(i64)
|
||||
declare i64 @llvm.coro.size.i64()
|
||||
declare i8* @llvm.coro.begin(token, i8* writeonly)
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare token @llvm.coro.save(i8*)
|
||||
declare i8 @llvm.coro.suspend(token, i1)
|
||||
|
||||
; Function Attrs: argmemonly nounwind
|
||||
declare void @may_throw1()
|
||||
declare void @may_throw2()
|
||||
|
||||
declare i8* @__cxa_begin_catch(i8*)
|
||||
|
||||
declare void @use_val(i32)
|
||||
declare void @__cxa_end_catch()
|
||||
|
||||
; Function Attrs: nounwind
|
||||
declare i1 @llvm.coro.end(i8*, i1)
|
||||
declare void @free(i8*)
|
||||
declare i8* @llvm.coro.free(token, i8* nocapture readonly)
|
|
@ -1,87 +0,0 @@
|
|||
; Tests that coro-split removes cleanup code after coro.end in resume functions
|
||||
; and retains it in the start function.
|
||||
; RUN: opt < %s -coro-split -S | FileCheck %s
|
||||
; RUN: opt < %s -passes=coro-split -S | FileCheck %s
|
||||
|
||||
define i8* @f(i1 %val) "coroutine.presplit"="1" personality i32 3 {
|
||||
entry:
|
||||
%id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
|
||||
%hdl = call i8* @llvm.coro.begin(token %id, i8* null)
|
||||
call void @print(i32 0)
|
||||
br i1 %val, label %resume, label %susp
|
||||
|
||||
susp:
|
||||
%0 = call i8 @llvm.coro.suspend(token none, i1 false)
|
||||
switch i8 %0, label %suspend [i8 0, label %resume
|
||||
i8 1, label %suspend]
|
||||
resume:
|
||||
invoke void @print(i32 1) to label %suspend unwind label %lpad
|
||||
|
||||
suspend:
|
||||
call i1 @llvm.coro.end(i8* %hdl, i1 0)
|
||||
call void @print(i32 0) ; should not be present in f.resume
|
||||
ret i8* %hdl
|
||||
|
||||
lpad:
|
||||
%lpval = landingpad { i8*, i32 }
|
||||
cleanup
|
||||
|
||||
call void @print(i32 2)
|
||||
%need.resume = call i1 @llvm.coro.end(i8* null, i1 true)
|
||||
br i1 %need.resume, label %eh.resume, label %cleanup.cont
|
||||
|
||||
cleanup.cont:
|
||||
call void @print(i32 3) ; should not be present in f.resume
|
||||
br label %eh.resume
|
||||
|
||||
eh.resume:
|
||||
resume { i8*, i32 } %lpval
|
||||
}
|
||||
|
||||
; Verify that start function contains both print calls the one before and after coro.end
|
||||
; CHECK-LABEL: define i8* @f(
|
||||
; CHECK: invoke void @print(i32 1)
|
||||
; CHECK: to label %AfterCoroEnd unwind label %lpad
|
||||
|
||||
; CHECK: AfterCoroEnd:
|
||||
; CHECK: call void @print(i32 0)
|
||||
; CHECK: ret i8* %hdl
|
||||
|
||||
; CHECK: lpad:
|
||||
; CHECK-NEXT: %lpval = landingpad { i8*, i32 }
|
||||
; CHECK-NEXT: cleanup
|
||||
; CHECK-NEXT: call void @print(i32 2)
|
||||
; CHECK-NEXT: call void @print(i32 3)
|
||||
; CHECK-NEXT: resume { i8*, i32 } %lpval
|
||||
|
||||
; VERIFY Resume Parts
|
||||
|
||||
; Verify that resume function does not contains both print calls appearing after coro.end
|
||||
; CHECK-LABEL: define internal fastcc void @f.resume
|
||||
; CHECK: invoke void @print(i32 1)
|
||||
; CHECK: to label %CoroEnd unwind label %lpad
|
||||
|
||||
; CHECK: CoroEnd:
|
||||
; CHECK-NEXT: ret void
|
||||
|
||||
; CHECK: lpad:
|
||||
; CHECK-NEXT: %lpval = landingpad { i8*, i32 }
|
||||
; CHECK-NEXT: cleanup
|
||||
; CHECK-NEXT: call void @print(i32 2)
|
||||
; CHECK-NEXT: resume { i8*, i32 } %lpval
|
||||
|
||||
declare i8* @llvm.coro.free(token, i8*)
|
||||
declare i32 @llvm.coro.size.i32()
|
||||
declare i8 @llvm.coro.suspend(token, i1)
|
||||
declare void @llvm.coro.resume(i8*)
|
||||
declare void @llvm.coro.destroy(i8*)
|
||||
|
||||
declare token @llvm.coro.id(i32, i8*, i8*, i8*)
|
||||
declare i8* @llvm.coro.alloc(token)
|
||||
declare i8* @llvm.coro.begin(token, i8*)
|
||||
declare i1 @llvm.coro.end(i8*, i1)
|
||||
|
||||
declare noalias i8* @malloc(i32)
|
||||
declare void @print(i32)
|
||||
declare void @free(i8*)
|
||||
|
|
@ -1,81 +0,0 @@
|
|||
; Tests that coro-split removes cleanup code after coro.end in resume functions
|
||||
; and retains it in the start function.
|
||||
; RUN: opt < %s -coro-split -S | FileCheck %s
|
||||
; RUN: opt < %s -passes=coro-split -S | FileCheck %s
|
||||
|
||||
define i8* @f2(i1 %val) "coroutine.presplit"="1" personality i32 4 {
|
||||
entry:
|
||||
%id = call token @llvm.coro.id(i32 0, i8* null, i8* null, i8* null)
|
||||
%hdl = call i8* @llvm.coro.begin(token %id, i8* null)
|
||||
call void @print(i32 0)
|
||||
br i1 %val, label %resume, label %susp
|
||||
|
||||
susp:
|
||||
%0 = call i8 @llvm.coro.suspend(token none, i1 false)
|
||||
switch i8 %0, label %suspend [i8 0, label %resume
|
||||
i8 1, label %suspend]
|
||||
resume:
|
||||
invoke void @print(i32 1) to label %suspend unwind label %lpad
|
||||
|
||||
suspend:
|
||||
call i1 @llvm.coro.end(i8* %hdl, i1 0)
|
||||
call void @print(i32 0) ; should not be present in f.resume
|
||||
ret i8* %hdl
|
||||
|
||||
lpad:
|
||||
%tok = cleanuppad within none []
|
||||
call void @print(i32 2)
|
||||
%unused = call i1 @llvm.coro.end(i8* null, i1 true) [ "funclet"(token %tok) ]
|
||||
cleanupret from %tok unwind label %cleanup.cont
|
||||
|
||||
cleanup.cont:
|
||||
%tok2 = cleanuppad within none []
|
||||
call void @print(i32 3) ; should not be present in f.resume
|
||||
cleanupret from %tok2 unwind to caller
|
||||
}
|
||||
|
||||
; Verify that start function contains both print calls the one before and after coro.end
|
||||
; CHECK-LABEL: define i8* @f2(
|
||||
; CHECK: invoke void @print(i32 1)
|
||||
; CHECK: to label %AfterCoroEnd unwind label %lpad
|
||||
|
||||
; CHECK: AfterCoroEnd:
|
||||
; CHECK: call void @print(i32 0)
|
||||
; CHECK: ret i8* %hdl
|
||||
|
||||
; CHECK: lpad:
|
||||
; CHECK-NEXT: %tok = cleanuppad within none []
|
||||
; CHECK-NEXT: call void @print(i32 2)
|
||||
; CHECK-NEXT: call void @print(i32 3)
|
||||
; CHECK-NEXT: cleanupret from %tok unwind to caller
|
||||
|
||||
; VERIFY Resume Parts
|
||||
|
||||
; Verify that resume function does not contains both print calls appearing after coro.end
|
||||
; CHECK-LABEL: define internal fastcc void @f2.resume
|
||||
; CHECK: invoke void @print(i32 1)
|
||||
; CHECK: to label %CoroEnd unwind label %lpad
|
||||
|
||||
; CHECK: CoroEnd:
|
||||
; CHECK-NEXT: ret void
|
||||
|
||||
; CHECK: lpad:
|
||||
; CHECK-NEXT: %tok = cleanuppad within none []
|
||||
; CHECK-NEXT: call void @print(i32 2)
|
||||
; CHECK-NEXT: cleanupret from %tok unwind to caller
|
||||
|
||||
declare i8* @llvm.coro.free(token, i8*)
|
||||
declare i32 @llvm.coro.size.i32()
|
||||
declare i8 @llvm.coro.suspend(token, i1)
|
||||
declare void @llvm.coro.resume(i8*)
|
||||
declare void @llvm.coro.destroy(i8*)
|
||||
|
||||
declare token @llvm.coro.id(i32, i8*, i8*, i8*)
|
||||
declare i8* @llvm.coro.alloc(token)
|
||||
declare i8* @llvm.coro.begin(token, i8*)
|
||||
declare i1 @llvm.coro.end(i8*, i1)
|
||||
|
||||
declare noalias i8* @malloc(i32)
|
||||
declare void @print(i32)
|
||||
declare void @free(i8*)
|
||||
|
Loading…
Reference in New Issue