This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rG243e62b9d876: [Coroutines] Directly remove unnecessary lifetime intrinsics (authored by nikic). Herald added a project: clang. Herald added a subscriber: cfe-commits.
Changed prior to commit: https://reviews.llvm.org/D148240?vs=513251&id=513475#toc Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D148240/new/ https://reviews.llvm.org/D148240 Files: clang/test/CodeGenCoroutines/coro-always-inline.cpp llvm/lib/Transforms/Coroutines/CoroFrame.cpp llvm/test/Transforms/Coroutines/coro-alloca-loop-carried-address.ll Index: llvm/test/Transforms/Coroutines/coro-alloca-loop-carried-address.ll =================================================================== --- llvm/test/Transforms/Coroutines/coro-alloca-loop-carried-address.ll +++ llvm/test/Transforms/Coroutines/coro-alloca-loop-carried-address.ll @@ -7,7 +7,6 @@ define void @foo() presplitcoroutine { ; CHECK-LABEL: @foo( ; CHECK-NEXT: entry: -; CHECK-NEXT: [[STACKVAR0:%.*]] = alloca i64, align 8 ; CHECK-NEXT: [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr @foo.resumers) ; CHECK-NEXT: [[ALLOC:%.*]] = call ptr @malloc(i64 40) ; CHECK-NEXT: [[VFRAME:%.*]] = call noalias nonnull ptr @llvm.coro.begin(token [[ID]], ptr [[ALLOC]]) Index: llvm/lib/Transforms/Coroutines/CoroFrame.cpp =================================================================== --- llvm/lib/Transforms/Coroutines/CoroFrame.cpp +++ llvm/lib/Transforms/Coroutines/CoroFrame.cpp @@ -1946,11 +1946,13 @@ DVI->replaceUsesOfWith(Alloca, G); for (Instruction *I : UsersToUpdate) { - // It is meaningless to remain the lifetime intrinsics refer for the + // It is meaningless to retain the lifetime intrinsics refer for the // member of coroutine frames and the meaningless lifetime intrinsics // are possible to block further optimizations. - if (I->isLifetimeStartOrEnd()) + if (I->isLifetimeStartOrEnd()) { + I->eraseFromParent(); continue; + } I->replaceUsesOfWith(Alloca, G); } Index: clang/test/CodeGenCoroutines/coro-always-inline.cpp =================================================================== --- clang/test/CodeGenCoroutines/coro-always-inline.cpp +++ clang/test/CodeGenCoroutines/coro-always-inline.cpp @@ -33,11 +33,8 @@ // CHECK-LABEL: @_Z3foov // CHECK-LABEL: entry: -// CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %ref.tmp{{.*}}) -// CHECK: call void @llvm.lifetime.end.p0(i64 1, ptr %ref.tmp{{.*}}) - -// CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %ref.tmp{{.*}}) -// CHECK: call void @llvm.lifetime.end.p0(i64 1, ptr %ref.tmp{{.*}}) +// CHECK: %ref.tmp.reload.addr = getelementptr +// CHECK: %ref.tmp4.reload.addr = getelementptr void foo() { co_return; } // Check that bar is not inlined even it's marked as always_inline.
Index: llvm/test/Transforms/Coroutines/coro-alloca-loop-carried-address.ll =================================================================== --- llvm/test/Transforms/Coroutines/coro-alloca-loop-carried-address.ll +++ llvm/test/Transforms/Coroutines/coro-alloca-loop-carried-address.ll @@ -7,7 +7,6 @@ define void @foo() presplitcoroutine { ; CHECK-LABEL: @foo( ; CHECK-NEXT: entry: -; CHECK-NEXT: [[STACKVAR0:%.*]] = alloca i64, align 8 ; CHECK-NEXT: [[ID:%.*]] = call token @llvm.coro.id(i32 0, ptr null, ptr null, ptr @foo.resumers) ; CHECK-NEXT: [[ALLOC:%.*]] = call ptr @malloc(i64 40) ; CHECK-NEXT: [[VFRAME:%.*]] = call noalias nonnull ptr @llvm.coro.begin(token [[ID]], ptr [[ALLOC]]) Index: llvm/lib/Transforms/Coroutines/CoroFrame.cpp =================================================================== --- llvm/lib/Transforms/Coroutines/CoroFrame.cpp +++ llvm/lib/Transforms/Coroutines/CoroFrame.cpp @@ -1946,11 +1946,13 @@ DVI->replaceUsesOfWith(Alloca, G); for (Instruction *I : UsersToUpdate) { - // It is meaningless to remain the lifetime intrinsics refer for the + // It is meaningless to retain the lifetime intrinsics refer for the // member of coroutine frames and the meaningless lifetime intrinsics // are possible to block further optimizations. - if (I->isLifetimeStartOrEnd()) + if (I->isLifetimeStartOrEnd()) { + I->eraseFromParent(); continue; + } I->replaceUsesOfWith(Alloca, G); } Index: clang/test/CodeGenCoroutines/coro-always-inline.cpp =================================================================== --- clang/test/CodeGenCoroutines/coro-always-inline.cpp +++ clang/test/CodeGenCoroutines/coro-always-inline.cpp @@ -33,11 +33,8 @@ // CHECK-LABEL: @_Z3foov // CHECK-LABEL: entry: -// CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %ref.tmp{{.*}}) -// CHECK: call void @llvm.lifetime.end.p0(i64 1, ptr %ref.tmp{{.*}}) - -// CHECK: call void @llvm.lifetime.start.p0(i64 1, ptr %ref.tmp{{.*}}) -// CHECK: call void @llvm.lifetime.end.p0(i64 1, ptr %ref.tmp{{.*}}) +// CHECK: %ref.tmp.reload.addr = getelementptr +// CHECK: %ref.tmp4.reload.addr = getelementptr void foo() { co_return; } // Check that bar is not inlined even it's marked as always_inline.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits