[llvm] 9e1b681 - [CoroSplit] Use poison instead of undef as placeholder [NFC]
Nuno Lopes via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 22 04:56:11 PDT 2023
Author: Nuno Lopes
Date: 2023-07-22T12:56:03+01:00
New Revision: 9e1b6817f114a5a838238980a5076a72d502d12d
URL: https://github.com/llvm/llvm-project/commit/9e1b6817f114a5a838238980a5076a72d502d12d
DIFF: https://github.com/llvm/llvm-project/commit/9e1b6817f114a5a838238980a5076a72d502d12d.diff
LOG: [CoroSplit] Use poison instead of undef as placeholder [NFC]
Used to construct full structs/vectors
also, covert freeze undef -> freeze poison (same semantics)
Added:
Modified:
llvm/lib/Transforms/Coroutines/CoroSplit.cpp
llvm/test/Transforms/Coroutines/coro-debug-dbg.values-not_used_in_frame.ll
llvm/test/Transforms/Coroutines/coro-retcon-alloca-opaque-ptr.ll
llvm/test/Transforms/Coroutines/coro-retcon-alloca.ll
llvm/test/Transforms/Coroutines/coro-retcon-once-value.ll
llvm/test/Transforms/Coroutines/coro-retcon-once-value2.ll
llvm/test/Transforms/Coroutines/coro-retcon-opaque-ptr.ll
llvm/test/Transforms/Coroutines/coro-retcon-value.ll
llvm/test/Transforms/Coroutines/coro-retcon.ll
Removed:
################################################################################
diff --git a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
index 358f72d63fb82c..39e909bf3316ca 100644
--- a/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
+++ b/llvm/lib/Transforms/Coroutines/CoroSplit.cpp
@@ -576,7 +576,7 @@ void CoroCloner::replaceRetconOrAsyncSuspendUses() {
if (NewS->use_empty()) return;
// Otherwise, we need to create an aggregate.
- Value *Agg = UndefValue::get(NewS->getType());
+ Value *Agg = PoisonValue::get(NewS->getType());
for (size_t I = 0, E = Args.size(); I != E; ++I)
Agg = Builder.CreateInsertValue(Agg, Args[I], I);
@@ -897,7 +897,7 @@ void CoroCloner::create() {
// frame.
SmallVector<Instruction *> DummyArgs;
for (Argument &A : OrigF.args()) {
- DummyArgs.push_back(new FreezeInst(UndefValue::get(A.getType())));
+ DummyArgs.push_back(new FreezeInst(PoisonValue::get(A.getType())));
VMap[&A] = DummyArgs.back();
}
@@ -1055,7 +1055,7 @@ void CoroCloner::create() {
// All uses of the arguments should have been resolved by this point,
// so we can safely remove the dummy values.
for (Instruction *DummyArg : DummyArgs) {
- DummyArg->replaceAllUsesWith(UndefValue::get(DummyArg->getType()));
+ DummyArg->replaceAllUsesWith(PoisonValue::get(DummyArg->getType()));
DummyArg->deleteValue();
}
@@ -1901,7 +1901,7 @@ static void splitRetconCoroutine(Function &F, coro::Shape &Shape,
if (ReturnPHIs.size() == 1) {
RetV = CastedContinuation;
} else {
- RetV = UndefValue::get(RetTy);
+ RetV = PoisonValue::get(RetTy);
RetV = Builder.CreateInsertValue(RetV, CastedContinuation, 0);
for (size_t I = 1, E = ReturnPHIs.size(); I != E; ++I)
RetV = Builder.CreateInsertValue(RetV, ReturnPHIs[I], I);
diff --git a/llvm/test/Transforms/Coroutines/coro-debug-dbg.values-not_used_in_frame.ll b/llvm/test/Transforms/Coroutines/coro-debug-dbg.values-not_used_in_frame.ll
index d90e255d290ad3..ed76c67860ee19 100644
--- a/llvm/test/Transforms/Coroutines/coro-debug-dbg.values-not_used_in_frame.ll
+++ b/llvm/test/Transforms/Coroutines/coro-debug-dbg.values-not_used_in_frame.ll
@@ -4,8 +4,8 @@
; This file is based on coro-debug-frame-variable.ll.
; CHECK: define internal fastcc void @f.resume(ptr noundef nonnull align 16 dereferenceable(80) %begin) !dbg ![[RESUME_FN_DBG_NUM:[0-9]+]]
; CHECK: await.ready:
-; CHECK: call void @llvm.dbg.value(metadata i32 undef, metadata ![[IVAR_RESUME:[0-9]+]], metadata !DIExpression(
-; CHECK: call void @llvm.dbg.value(metadata i32 undef, metadata ![[JVAR_RESUME:[0-9]+]], metadata !DIExpression(
+; CHECK: call void @llvm.dbg.value(metadata i32 poison, metadata ![[IVAR_RESUME:[0-9]+]], metadata !DIExpression(
+; CHECK: call void @llvm.dbg.value(metadata i32 poison, metadata ![[JVAR_RESUME:[0-9]+]], metadata !DIExpression(
;
; CHECK: ![[RESUME_FN_DBG_NUM]] = distinct !DISubprogram(name: "foo", linkageName: "_Z3foov"
; CHECK: ![[IVAR_RESUME]] = !DILocalVariable(name: "i"
diff --git a/llvm/test/Transforms/Coroutines/coro-retcon-alloca-opaque-ptr.ll b/llvm/test/Transforms/Coroutines/coro-retcon-alloca-opaque-ptr.ll
index f07c88c63793a9..879e368489a6a2 100644
--- a/llvm/test/Transforms/Coroutines/coro-retcon-alloca-opaque-ptr.ll
+++ b/llvm/test/Transforms/Coroutines/coro-retcon-alloca-opaque-ptr.ll
@@ -12,7 +12,7 @@ define {ptr, ptr, i32} @f(ptr %buffer, i32 %n, { i32 } %dummy) {
; CHECK-NEXT: store i32 [[N:%.*]], ptr [[N_VAL_SPILL_ADDR]], align 4
; CHECK-NEXT: [[TMP0:%.*]] = tail call ptr @allocate(i32 [[N]])
; CHECK-NEXT: store ptr [[TMP0]], ptr [[BUFFER]], align 8
-; CHECK-NEXT: [[TMP1:%.*]] = insertvalue { ptr, ptr, i32 } { ptr @f.resume.0, ptr undef, i32 undef }, ptr [[TMP0]], 1
+; CHECK-NEXT: [[TMP1:%.*]] = insertvalue { ptr, ptr, i32 } { ptr @f.resume.0, ptr poison, i32 poison }, ptr [[TMP0]], 1
; CHECK-NEXT: [[TMP2:%.*]] = insertvalue { ptr, ptr, i32 } [[TMP1]], i32 [[N]], 2
; CHECK-NEXT: ret { ptr, ptr, i32 } [[TMP2]]
;
@@ -47,7 +47,7 @@ define {ptr, i32} @g(ptr %buffer, i32 %n) {
; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[N]] to i64
; CHECK-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[TMP0]], align 8
; CHECK-NEXT: tail call void @use(ptr nonnull [[TMP1]])
-; CHECK-NEXT: [[TMP2:%.*]] = insertvalue { ptr, i32 } { ptr @g.resume.0, i32 undef }, i32 [[N]], 1
+; CHECK-NEXT: [[TMP2:%.*]] = insertvalue { ptr, i32 } { ptr @g.resume.0, i32 poison }, i32 [[N]], 1
; CHECK-NEXT: ret { ptr, i32 } [[TMP2]]
;
entry:
diff --git a/llvm/test/Transforms/Coroutines/coro-retcon-alloca.ll b/llvm/test/Transforms/Coroutines/coro-retcon-alloca.ll
index a4b6945b58798a..ab3da8cde729ac 100644
--- a/llvm/test/Transforms/Coroutines/coro-retcon-alloca.ll
+++ b/llvm/test/Transforms/Coroutines/coro-retcon-alloca.ll
@@ -11,7 +11,7 @@ define {ptr, ptr, i32} @f(ptr %buffer, i32 %n) {
; CHECK-NEXT: store i32 [[N:%.*]], ptr [[N_VAL_SPILL_ADDR]], align 4
; CHECK-NEXT: [[TMP0:%.*]] = tail call ptr @allocate(i32 [[N]])
; CHECK-NEXT: store ptr [[TMP0]], ptr [[BUFFER]], align 8
-; CHECK-NEXT: [[TMP1:%.*]] = insertvalue { ptr, ptr, i32 } { ptr @f.resume.0, ptr undef, i32 undef }, ptr [[TMP0]], 1
+; CHECK-NEXT: [[TMP1:%.*]] = insertvalue { ptr, ptr, i32 } { ptr @f.resume.0, ptr poison, i32 poison }, ptr [[TMP0]], 1
; CHECK-NEXT: [[TMP2:%.*]] = insertvalue { ptr, ptr, i32 } [[TMP1]], i32 [[N]], 2
; CHECK-NEXT: ret { ptr, ptr, i32 } [[TMP2]]
;
@@ -47,7 +47,7 @@ define {ptr, i32} @g(ptr %buffer, i32 %n) {
; CHECK-NEXT: [[TMP0:%.*]] = zext i32 [[N]] to i64
; CHECK-NEXT: [[TMP1:%.*]] = alloca i8, i64 [[TMP0]], align 8
; CHECK-NEXT: tail call void @use(ptr nonnull [[TMP1]])
-; CHECK-NEXT: [[TMP2:%.*]] = insertvalue { ptr, i32 } { ptr @g.resume.0, i32 undef }, i32 [[N]], 1
+; CHECK-NEXT: [[TMP2:%.*]] = insertvalue { ptr, i32 } { ptr @g.resume.0, i32 poison }, i32 [[N]], 1
; CHECK-NEXT: ret { ptr, i32 } [[TMP2]]
;
entry:
@@ -80,7 +80,7 @@ define {ptr, i32} @h(ptr %buffer, i32 %n) {
; CHECK-LABEL: @h(
; CHECK-NEXT: coro.return:
; CHECK-NEXT: store i32 [[N:%.*]], ptr [[BUFFER:%.*]], align 4
-; CHECK-NEXT: [[TMP0:%.*]] = insertvalue { ptr, i32 } { ptr @h.resume.0, i32 undef }, i32 [[N]], 1
+; CHECK-NEXT: [[TMP0:%.*]] = insertvalue { ptr, i32 } { ptr @h.resume.0, i32 poison }, i32 [[N]], 1
; CHECK-NEXT: ret { ptr, i32 } [[TMP0]]
;
entry:
@@ -113,7 +113,7 @@ define {ptr, i32} @i(ptr %buffer, i32 %n) {
; CHECK-LABEL: @i(
; CHECK-NEXT: coro.return:
; CHECK-NEXT: store i32 [[N:%.*]], ptr [[BUFFER:%.*]], align 4
-; CHECK-NEXT: [[TMP0:%.*]] = insertvalue { ptr, i32 } { ptr @i.resume.0, i32 undef }, i32 [[N]], 1
+; CHECK-NEXT: [[TMP0:%.*]] = insertvalue { ptr, i32 } { ptr @i.resume.0, i32 poison }, i32 [[N]], 1
; CHECK-NEXT: ret { ptr, i32 } [[TMP0]]
;
entry:
@@ -145,7 +145,7 @@ define {ptr, i32} @j(ptr %buffer, i32 %n) {
; CHECK-LABEL: @j(
; CHECK-NEXT: coro.return:
; CHECK-NEXT: store i32 [[N:%.*]], ptr [[BUFFER:%.*]], align 4
-; CHECK-NEXT: [[TMP0:%.*]] = insertvalue { ptr, i32 } { ptr @j.resume.0, i32 undef }, i32 [[N]], 1
+; CHECK-NEXT: [[TMP0:%.*]] = insertvalue { ptr, i32 } { ptr @j.resume.0, i32 poison }, i32 [[N]], 1
; CHECK-NEXT: ret { ptr, i32 } [[TMP0]]
;
entry:
@@ -181,7 +181,7 @@ define {ptr, i32} @k(ptr %buffer, i32 %n, i1 %cond) {
; CHECK-NEXT: [[SIZE:%.*]] = tail call i32 @getSize()
; CHECK-NEXT: br i1 [[COND:%.*]], label [[ALLOCA_BLOCK:%.*]], label [[CORO_RETURN:%.*]]
; CHECK: coro.return:
-; CHECK-NEXT: [[TMP0:%.*]] = insertvalue { ptr, i32 } { ptr @k.resume.0, i32 undef }, i32 [[N:%.*]], 1
+; CHECK-NEXT: [[TMP0:%.*]] = insertvalue { ptr, i32 } { ptr @k.resume.0, i32 poison }, i32 [[N:%.*]], 1
; CHECK-NEXT: ret { ptr, i32 } [[TMP0]]
; CHECK: alloca_block:
; CHECK-NEXT: [[TMP1:%.*]] = zext i32 [[SIZE]] to i64
diff --git a/llvm/test/Transforms/Coroutines/coro-retcon-once-value.ll b/llvm/test/Transforms/Coroutines/coro-retcon-once-value.ll
index eb4626dceaf299..c76a76c5fb85a3 100644
--- a/llvm/test/Transforms/Coroutines/coro-retcon-once-value.ll
+++ b/llvm/test/Transforms/Coroutines/coro-retcon-once-value.ll
@@ -12,7 +12,7 @@ define {ptr, i32} @f(ptr %buffer, ptr %array) {
; CHECK-NEXT: [[LOAD_POS:%.*]] = icmp sgt i32 [[LOAD]], 0
; CHECK-NEXT: [[SPEC_SELECT:%.*]] = select i1 [[LOAD_POS]], ptr @f.resume.0, ptr @f.resume.1
; CHECK-NEXT: [[SPEC_SELECT4:%.*]] = tail call i32 @llvm.smax.i32(i32 [[LOAD]], i32 0)
-; CHECK-NEXT: [[TMP0:%.*]] = insertvalue { ptr, i32 } undef, ptr [[SPEC_SELECT]], 0
+; CHECK-NEXT: [[TMP0:%.*]] = insertvalue { ptr, i32 } poison, ptr [[SPEC_SELECT]], 0
; CHECK-NEXT: [[TMP1:%.*]] = insertvalue { ptr, i32 } [[TMP0]], i32 [[SPEC_SELECT4]], 1
; CHECK-NEXT: ret { ptr, i32 } [[TMP1]]
;
diff --git a/llvm/test/Transforms/Coroutines/coro-retcon-once-value2.ll b/llvm/test/Transforms/Coroutines/coro-retcon-once-value2.ll
index 83c293f0a44f63..17a0a1d0e6b9e8 100644
--- a/llvm/test/Transforms/Coroutines/coro-retcon-once-value2.ll
+++ b/llvm/test/Transforms/Coroutines/coro-retcon-once-value2.ll
@@ -44,7 +44,7 @@ declare void @print(i32)
; CHECK-NEXT: store ptr [[PTR:%.*]], ptr [[TMP0]], align 8
; CHECK-NEXT: [[OLDVALUE:%.*]] = load i32, ptr [[PTR]], align 4
; CHECK-NEXT: store i32 [[OLDVALUE]], ptr [[TEMP]], align 4
-; CHECK-NEXT: [[TMP2:%.*]] = insertvalue { ptr, ptr } { ptr @f.resume.0, ptr undef }, ptr [[TEMP]], 1
+; CHECK-NEXT: [[TMP2:%.*]] = insertvalue { ptr, ptr } { ptr @f.resume.0, ptr poison }, ptr [[TEMP]], 1
; CHECK-NEXT: ret { ptr, ptr } [[TMP2]]
;
;
diff --git a/llvm/test/Transforms/Coroutines/coro-retcon-opaque-ptr.ll b/llvm/test/Transforms/Coroutines/coro-retcon-opaque-ptr.ll
index 38629efef6d220..868a9c4966756a 100644
--- a/llvm/test/Transforms/Coroutines/coro-retcon-opaque-ptr.ll
+++ b/llvm/test/Transforms/Coroutines/coro-retcon-opaque-ptr.ll
@@ -54,7 +54,7 @@ define hidden { ptr, ptr } @g(ptr %buffer, ptr %ptr) {
; CHECK-NEXT: [[TMP0:%.*]] = tail call ptr @allocate(i32 8)
; CHECK-NEXT: store ptr [[TMP0]], ptr [[BUFFER:%.*]], align 8
; CHECK-NEXT: store ptr [[PTR:%.*]], ptr [[TMP0]], align 8
-; CHECK-NEXT: [[TMP1:%.*]] = insertvalue { ptr, ptr } { ptr @g.resume.0, ptr undef }, ptr [[PTR]], 1
+; CHECK-NEXT: [[TMP1:%.*]] = insertvalue { ptr, ptr } { ptr @g.resume.0, ptr poison }, ptr [[PTR]], 1
; CHECK-NEXT: ret { ptr, ptr } [[TMP1]]
;
entry:
diff --git a/llvm/test/Transforms/Coroutines/coro-retcon-value.ll b/llvm/test/Transforms/Coroutines/coro-retcon-value.ll
index 27344ffe63c940..0b0f5dfd56c953 100644
--- a/llvm/test/Transforms/Coroutines/coro-retcon-value.ll
+++ b/llvm/test/Transforms/Coroutines/coro-retcon-value.ll
@@ -6,7 +6,7 @@ define {ptr, i32} @f(ptr %buffer, i32 %n) {
; CHECK-LABEL: @f(
; CHECK-NEXT: coro.return:
; CHECK-NEXT: store i32 [[N:%.*]], ptr [[BUFFER:%.*]], align 4
-; CHECK-NEXT: [[TMP0:%.*]] = insertvalue { ptr, i32 } { ptr @f.resume.0, i32 undef }, i32 [[N]], 1
+; CHECK-NEXT: [[TMP0:%.*]] = insertvalue { ptr, i32 } { ptr @f.resume.0, i32 poison }, i32 [[N]], 1
; CHECK-NEXT: ret { ptr, i32 } [[TMP0]]
;
entry:
diff --git a/llvm/test/Transforms/Coroutines/coro-retcon.ll b/llvm/test/Transforms/Coroutines/coro-retcon.ll
index b42f1c51855e62..774c609ed6c441 100644
--- a/llvm/test/Transforms/Coroutines/coro-retcon.ll
+++ b/llvm/test/Transforms/Coroutines/coro-retcon.ll
@@ -75,7 +75,7 @@ define hidden { ptr, ptr } @g(ptr %buffer, ptr %ptr) {
; CHECK-NEXT: [[TMP0:%.*]] = tail call ptr @allocate(i32 8)
; CHECK-NEXT: store ptr [[TMP0]], ptr [[BUFFER:%.*]], align 8
; CHECK-NEXT: store ptr [[PTR:%.*]], ptr [[TMP0]], align 8
-; CHECK-NEXT: [[TMP1:%.*]] = insertvalue { ptr, ptr } { ptr @g.resume.0, ptr undef }, ptr [[PTR]], 1
+; CHECK-NEXT: [[TMP1:%.*]] = insertvalue { ptr, ptr } { ptr @g.resume.0, ptr poison }, ptr [[PTR]], 1
; CHECK-NEXT: ret { ptr, ptr } [[TMP1]]
;
; CORO-LABEL: @g(
@@ -86,7 +86,7 @@ define hidden { ptr, ptr } @g(ptr %buffer, ptr %ptr) {
; CORO-NEXT: store ptr [[PTR:%.*]], ptr [[PTR_SPILL_ADDR]], align 8
; CORO-NEXT: [[PTR_RELOAD_ADDR:%.*]] = getelementptr inbounds [[G_FRAME]], ptr [[TMP0]], i32 0, i32 0
; CORO-NEXT: [[PTR_RELOAD:%.*]] = load ptr, ptr [[PTR_RELOAD_ADDR]], align 8
-; CORO-NEXT: [[TMP1:%.*]] = insertvalue { ptr, ptr } undef, ptr @g.resume.0, 0
+; CORO-NEXT: [[TMP1:%.*]] = insertvalue { ptr, ptr } poison, ptr @g.resume.0, 0
; CORO-NEXT: [[TMP2:%.*]] = insertvalue { ptr, ptr } [[TMP1]], ptr [[PTR_RELOAD]], 1
; CORO-NEXT: ret { ptr, ptr } [[TMP2]]
;
More information about the llvm-commits
mailing list