diff --git a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp --- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp +++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp @@ -54,8 +54,8 @@ STATISTIC(NumArgumentsEliminated, "Number of unread args removed"); STATISTIC(NumRetValsEliminated , "Number of unused return values removed"); -STATISTIC(NumArgumentsReplacedWithUndef, - "Number of unread args replaced with undef"); +STATISTIC(NumArgumentsReplacedWithPoison, + "Number of unread args replaced with poison"); namespace { @@ -251,14 +251,14 @@ } /// RemoveDeadArgumentsFromCallers - Checks if the given function has any -/// arguments that are unused, and changes the caller parameters to be undefined +/// arguments that are unused, and changes the caller parameters to be poison /// instead. bool DeadArgumentEliminationPass::RemoveDeadArgumentsFromCallers(Function &Fn) { // We cannot change the arguments if this TU does not define the function or // if the linker may choose a function body from another TU, even if the // nominal linkage indicates that other copies of the function have the same // semantics. In the below example, the dead load from %p may not have been - // eliminated from the linker-chosen copy of f, so replacing %p with undef + // eliminated from the linker-chosen copy of f, so replacing %p with poison // in callers may introduce undefined behavior. // // define linkonce_odr void @f(i32* %p) { @@ -294,7 +294,7 @@ if (!Arg.hasSwiftErrorAttr() && Arg.use_empty() && !Arg.hasPassPointeeByValueCopyAttr()) { if (Arg.isUsedByMetadata()) { - Arg.replaceAllUsesWith(UndefValue::get(Arg.getType())); + Arg.replaceAllUsesWith(PoisonValue::get(Arg.getType())); Changed = true; } UnusedArgs.push_back(Arg.getArgNo()); @@ -311,15 +311,15 @@ CB->getFunctionType() != Fn.getFunctionType()) continue; - // Now go through all unused args and replace them with "undef". + // Now go through all unused args and replace them with poison. for (unsigned I = 0, E = UnusedArgs.size(); I != E; ++I) { unsigned ArgNo = UnusedArgs[I]; Value *Arg = CB->getArgOperand(ArgNo); - CB->setArgOperand(ArgNo, UndefValue::get(Arg->getType())); + CB->setArgOperand(ArgNo, PoisonValue::get(Arg->getType())); CB->removeParamAttrs(ArgNo, UBImplyingAttributes); - ++NumArgumentsReplacedWithUndef; + ++NumArgumentsReplacedWithPoison; Changed = true; } } @@ -964,10 +964,10 @@ CB.replaceAllUsesWith(NewCB); NewCB->takeName(&CB); } else if (NewCB->getType()->isVoidTy()) { - // If the return value is dead, replace any uses of it with undef + // If the return value is dead, replace any uses of it with poison // (any non-debug value uses will get removed later on). if (!CB.getType()->isX86_MMXTy()) - CB.replaceAllUsesWith(UndefValue::get(CB.getType())); + CB.replaceAllUsesWith(PoisonValue::get(CB.getType())); } else { assert((RetTy->isStructTy() || RetTy->isArrayTy()) && "Return type changed, but not into a void. The old return type" @@ -983,8 +983,8 @@ // with all the uses, we will just rebuild it using extract/insertvalue // chaining and let instcombine clean that up. // - // Start out building up our return value from undef - Value *RetVal = UndefValue::get(RetTy); + // Start out building up our return value from poison + Value *RetVal = PoisonValue::get(RetTy); for (unsigned Ri = 0; Ri != RetCount; ++Ri) if (NewRetIdxs[Ri] != -1) { Value *V; @@ -1029,10 +1029,10 @@ I2->takeName(&*I); ++I2; } else { - // If this argument is dead, replace any uses of it with undef + // If this argument is dead, replace any uses of it with poison // (any non-debug value uses will get removed later on). if (!I->getType()->isX86_MMXTy()) - I->replaceAllUsesWith(UndefValue::get(I->getType())); + I->replaceAllUsesWith(PoisonValue::get(I->getType())); } // If we change the return value of the function we must rewrite any return @@ -1051,8 +1051,8 @@ // This does generate messy code, but we'll let it to instcombine to // clean that up. Value *OldRet = RI->getOperand(0); - // Start out building up our return value from undef - RetVal = UndefValue::get(NRetTy); + // Start out building up our return value from poison + RetVal = PoisonValue::get(NRetTy); for (unsigned RetI = 0; RetI != RetCount; ++RetI) if (NewRetIdxs[RetI] != -1) { Value *EV = IRB.CreateExtractValue(OldRet, RetI, "oldret"); @@ -1117,7 +1117,7 @@ Changed |= RemoveDeadStuffFromFunction(&F); // Finally, look for any unused parameters in functions with non-local - // linkage and replace the passed in parameters with undef. + // linkage and replace the passed in parameters with poison. for (auto &F : M) Changed |= RemoveDeadArgumentsFromCallers(F); diff --git a/llvm/test/Transforms/DeadArgElim/NoundefAttrs.ll b/llvm/test/Transforms/DeadArgElim/NoundefAttrs.ll --- a/llvm/test/Transforms/DeadArgElim/NoundefAttrs.ll +++ b/llvm/test/Transforms/DeadArgElim/NoundefAttrs.ll @@ -12,7 +12,7 @@ } define i64 @foo(i64* %p, i64 %v) { -; CHECK: %retval = call i64 @bar(i64* nonnull undef, i64 %v) +; CHECK: %retval = call i64 @bar(i64* nonnull poison, i64 %v) %retval = call i64 @bar(i64* nonnull dereferenceable(8) %p, i64 %v) ret i64 %retval } diff --git a/llvm/test/Transforms/DeadArgElim/aggregates.ll b/llvm/test/Transforms/DeadArgElim/aggregates.ll --- a/llvm/test/Transforms/DeadArgElim/aggregates.ll +++ b/llvm/test/Transforms/DeadArgElim/aggregates.ll @@ -36,7 +36,7 @@ ; This use can be classified as applying only to ret 1. %val0 = extractvalue { i32, i32 } %val, 1 call void @callee(i32 %val0) - ret { i32, i32 } undef + ret { i32, i32 } poison use_aggregate: ; This use is assumed to apply to both 0 and 1. @@ -61,7 +61,7 @@ ; This use can be classified as applying only to ret 1. %val0 = extractvalue { i32, i32 } %val, 1 call void @callee(i32 %val0) - ret { i32, i32 } undef + ret { i32, i32 } poison use_aggregate: ; This use is assumed to apply to both 0 and 1. @@ -77,7 +77,7 @@ ; CHECK-LABEL: define internal [2 x i32] @array_rets_have_multiple_slots(i32 %in) define internal [2 x i32] @array_rets_have_multiple_slots(i32 %in) { - %ret = insertvalue [2 x i32] undef, i32 %in, 1 + %ret = insertvalue [2 x i32] poison, i32 %in, 1 ret [2 x i32] %ret } @@ -91,7 +91,7 @@ ; CHECK-LABEL: define internal [2 x i32] @can_shrink_arrays() ; CHECK: [[VAL0:%.*]] = extractvalue [3 x i32] [i32 42, i32 43, i32 44], 0 -; CHECK: [[RESTMP:%.*]] = insertvalue [2 x i32] undef, i32 [[VAL0]], 0 +; CHECK: [[RESTMP:%.*]] = insertvalue [2 x i32] poison, i32 [[VAL0]], 0 ; CHECK: [[VAL2:%.*]] = extractvalue [3 x i32] [i32 42, i32 43, i32 44], 2 ; CHECK: [[RES:%.*]] = insertvalue [2 x i32] [[RESTMP]], i32 [[VAL2]], 1 ; CHECK: ret [2 x i32] [[RES]] @@ -168,9 +168,9 @@ ; CHECK-LABEL: define void @PR24906 ; CHECK: %[[invoke:.*]] = invoke i32 @agg_ret() -; CHECK: %[[oldret:.*]] = insertvalue { i32 } undef, i32 %[[invoke]], 0 +; CHECK: %[[oldret:.*]] = insertvalue { i32 } poison, i32 %[[invoke]], 0 ; CHECK: phi { i32 } [ %[[oldret]], -define void @PR24906() personality i32 (i32)* undef { +define void @PR24906() personality i32 (i32)* poison { entry: %tmp2 = invoke { i32 } @agg_ret() to label %bb3 unwind label %bb4 diff --git a/llvm/test/Transforms/DeadArgElim/byref.ll b/llvm/test/Transforms/DeadArgElim/byref.ll --- a/llvm/test/Transforms/DeadArgElim/byref.ll +++ b/llvm/test/Transforms/DeadArgElim/byref.ll @@ -12,9 +12,9 @@ ret void } -define void @dont_replace_by_undef(i32* %ptr) { -; CHECK-LABEL: @dont_replace_by_undef( -; CHECK-NEXT: call void @unused_byref_arg(i32* byref(i32) undef) +define void @dont_replace_by_poison(i32* %ptr) { +; CHECK-LABEL: @dont_replace_by_poison( +; CHECK-NEXT: call void @unused_byref_arg(i32* byref(i32) poison) ; CHECK-NEXT: ret void ; call void @unused_byref_arg(i32* byref(i32) %ptr) diff --git a/llvm/test/Transforms/DeadArgElim/dbginfo-update-dbgval-local.ll b/llvm/test/Transforms/DeadArgElim/dbginfo-update-dbgval-local.ll --- a/llvm/test/Transforms/DeadArgElim/dbginfo-update-dbgval-local.ll +++ b/llvm/test/Transforms/DeadArgElim/dbginfo-update-dbgval-local.ll @@ -1,12 +1,12 @@ ; RUN: opt -passes=deadargelim -S < %s | FileCheck %s ; Verify that the dbg.value intrinsics that use the dead argument and return -; value are marked as undef to indicate that the values are optimized out. +; value are marked as poison to indicate that the values are optimized out. ; Reproducer for PR23260. ; CHECK-LABEL: define internal void @bar() -; CHECK: call void @llvm.dbg.value(metadata i32 undef, metadata ![[LOCAL1:[0-9]+]] +; CHECK: call void @llvm.dbg.value(metadata i32 poison, metadata ![[LOCAL1:[0-9]+]] ; CHECK: call void @sink() ; Function Attrs: alwaysinline nounwind uwtable @@ -19,7 +19,7 @@ ; CHECK-LABEL: define void @foo() ; CHECK: call void @bar() -; CHECK: call void @llvm.dbg.value(metadata i32 undef, metadata ![[LOCAL2:[0-9]+]] +; CHECK: call void @llvm.dbg.value(metadata i32 poison, metadata ![[LOCAL2:[0-9]+]] ; CHECK: call void @bar() ; Function Attrs: nounwind uwtable diff --git a/llvm/test/Transforms/DeadArgElim/dbginfo-update-dbgval.ll b/llvm/test/Transforms/DeadArgElim/dbginfo-update-dbgval.ll --- a/llvm/test/Transforms/DeadArgElim/dbginfo-update-dbgval.ll +++ b/llvm/test/Transforms/DeadArgElim/dbginfo-update-dbgval.ll @@ -24,7 +24,7 @@ ; Function Attrs: noinline nounwind uwtable define dso_local void @f2(i32 %k) local_unnamed_addr !dbg !11 { entry: -; CHECK: call void @llvm.dbg.value(metadata i32 undef, metadata !15, metadata !DIExpression()), !dbg !16 +; CHECK: call void @llvm.dbg.value(metadata i32 poison, metadata !15, metadata !DIExpression()), !dbg !16 call void @llvm.dbg.value(metadata i32 %k, metadata !15, metadata !DIExpression()), !dbg !16 %0 = load i32, i32* @s, align 4, !dbg !17 %inc = add nsw i32 %0, 1, !dbg !17 @@ -36,7 +36,7 @@ ; Function Attrs: noinline nounwind uwtable define dso_local void @f() local_unnamed_addr !dbg !19 { entry: -; CHECK: tail call void @f2(i32 undef), !dbg !22 +; CHECK: tail call void @f2(i32 poison), !dbg !22 tail call void @f2(i32 4), !dbg !22 ret void, !dbg !23 } diff --git a/llvm/test/Transforms/DeadArgElim/deadexternal.ll b/llvm/test/Transforms/DeadArgElim/deadexternal.ll --- a/llvm/test/Transforms/DeadArgElim/deadexternal.ll +++ b/llvm/test/Transforms/DeadArgElim/deadexternal.ll @@ -8,7 +8,7 @@ call void @test(i32 0) ret void ; CHECK-LABEL: @foo( -; CHECK: i32 undef +; CHECK: i32 poison } define void @f(i32 %X) { @@ -22,7 +22,7 @@ define void @g(i32 %n) { entry: %add = add nsw i32 %n, 1 -; CHECK: tail call void @f(i32 undef) +; CHECK: tail call void @f(i32 poison) tail call void @f(i32 %add) ret void } @@ -32,7 +32,7 @@ %i = alloca i32, align 4 store volatile i32 10, i32* %i, align 4 ; CHECK: %tmp = load volatile i32, i32* %i, align 4 -; CHECK-NEXT: call void @f(i32 undef) +; CHECK-NEXT: call void @f(i32 poison) %tmp = load volatile i32, i32* %i, align 4 call void @f(i32 %tmp) ret void @@ -57,9 +57,9 @@ ret void } -; CHECK-LABEL: @dont_replace_by_undef -; CHECK-NOT: call void @unused_swifterror_arg({{.*}}undef) -define void @dont_replace_by_undef() { +; CHECK-LABEL: @dont_replace_by_poison +; CHECK-NOT: call void @unused_swifterror_arg({{.*}}poison) +define void @dont_replace_by_poison() { %error_ptr_ref = alloca swifterror %swift_error* store %swift_error* null, %swift_error** %error_ptr_ref call void @unused_swifterror_arg(%swift_error** %error_ptr_ref) diff --git a/llvm/test/Transforms/DeadArgElim/fct_ptr.ll b/llvm/test/Transforms/DeadArgElim/fct_ptr.ll --- a/llvm/test/Transforms/DeadArgElim/fct_ptr.ll +++ b/llvm/test/Transforms/DeadArgElim/fct_ptr.ll @@ -5,7 +5,7 @@ ; Because of that use, we used to bail out on removing the ; unused arguments for this function. ; Yet, we should still be able to rewrite the direct calls that are -; statically known, by replacing the related arguments with undef. +; statically known, by replacing the related arguments with poison. ; This is what we check on the call that produces %res2. define i32 @call_indirect(i32 (i32, i32, i32)* readnone %fct_ptr, i32 %arg1, i32 %arg2, i32 %arg3) { @@ -13,13 +13,13 @@ ; CHECK-NEXT: [[CMP0:%.*]] = icmp eq i32 (i32, i32, i32)* [[FCT_PTR:%.*]], @external_fct ; CHECK-NEXT: br i1 [[CMP0]], label [[CALL_EXT:%.*]], label [[CHK2:%.*]] ; CHECK: call_ext: -; CHECK-NEXT: [[RES1:%.*]] = tail call i32 @external_fct(i32 undef, i32 [[ARG2:%.*]], i32 undef) +; CHECK-NEXT: [[RES1:%.*]] = tail call i32 @external_fct(i32 poison, i32 [[ARG2:%.*]], i32 poison) ; CHECK-NEXT: br label [[END:%.*]] ; CHECK: chk2: ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i32 (i32, i32, i32)* [[FCT_PTR]], @internal_fct ; CHECK-NEXT: br i1 [[CMP1]], label [[CALL_INT:%.*]], label [[CALL_OTHER:%.*]] ; CHECK: call_int: -; CHECK-NEXT: [[RES2:%.*]] = tail call i32 @internal_fct(i32 undef, i32 [[ARG2]], i32 undef) +; CHECK-NEXT: [[RES2:%.*]] = tail call i32 @internal_fct(i32 poison, i32 [[ARG2]], i32 poison) ; CHECK-NEXT: br label [[END]] ; CHECK: call_other: ; CHECK-NEXT: [[RES3:%.*]] = tail call i32 @other_fct(i32 [[ARG2]]) diff --git a/llvm/test/Transforms/DeadArgElim/opaque-ptr.ll b/llvm/test/Transforms/DeadArgElim/opaque-ptr.ll --- a/llvm/test/Transforms/DeadArgElim/opaque-ptr.ll +++ b/llvm/test/Transforms/DeadArgElim/opaque-ptr.ll @@ -11,7 +11,7 @@ define void @caller() { ; CHECK-LABEL: define {{[^@]+}}@caller() { -; CHECK-NEXT: call void @callee(i32 undef) +; CHECK-NEXT: call void @callee(i32 poison) ; CHECK-NEXT: call void @callee() ; CHECK-NEXT: call void @callee(i32 42, i32 24) ; CHECK-NEXT: ret void diff --git a/llvm/test/Transforms/DeadArgElim/variadic_safety.ll b/llvm/test/Transforms/DeadArgElim/variadic_safety.ll --- a/llvm/test/Transforms/DeadArgElim/variadic_safety.ll +++ b/llvm/test/Transforms/DeadArgElim/variadic_safety.ll @@ -17,9 +17,9 @@ define i32 @call_va(i32 %in) { %stacked = alloca i32 store i32 42, i32* %stacked - %res = call i32(i32, i32, ...) @va_func(i32 %in, i32 %in, [6 x i32] undef, i32* byval(i32) %stacked) + %res = call i32(i32, i32, ...) @va_func(i32 %in, i32 %in, [6 x i32] poison, i32* byval(i32) %stacked) ret i32 %res -; CHECK: call i32 (i32, i32, ...) @va_func(i32 undef, i32 %in, [6 x i32] undef, i32* byval(i32) %stacked) +; CHECK: call i32 (i32, i32, ...) @va_func(i32 poison, i32 %in, [6 x i32] poison, i32* byval(i32) %stacked) } define internal i32 @va_deadret_func(i32 %a, i32 %b, ...) { @@ -32,7 +32,7 @@ define void @call_deadret(i32 %in) { %stacked = alloca i32 store i32 42, i32* %stacked - call i32 (i32, i32, ...) @va_deadret_func(i32 undef, i32 %in, [6 x i32] undef, i32* byval(i32) %stacked) + call i32 (i32, i32, ...) @va_deadret_func(i32 poison, i32 %in, [6 x i32] poison, i32* byval(i32) %stacked) ret void -; CHECK: call void (i32, i32, ...) @va_deadret_func(i32 undef, i32 undef, [6 x i32] undef, i32* byval(i32) %stacked) +; CHECK: call void (i32, i32, ...) @va_deadret_func(i32 poison, i32 poison, [6 x i32] poison, i32* byval(i32) %stacked) }