[clang] 4dd1bff - [clang][CodeGen] Switch a few placeholders from UndefValue to PoisonValue

Nuno Lopes via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 12 11:08:06 PDT 2022


Author: Nuno Lopes
Date: 2022-06-12T19:07:59+01:00
New Revision: 4dd1bffc9dac02b34bd1de78808edd9a5955c987

URL: https://github.com/llvm/llvm-project/commit/4dd1bffc9dac02b34bd1de78808edd9a5955c987
DIFF: https://github.com/llvm/llvm-project/commit/4dd1bffc9dac02b34bd1de78808edd9a5955c987.diff

LOG: [clang][CodeGen] Switch a few placeholders from UndefValue to PoisonValue
This change is cosmetic, as these are dummy values that are not observable, but it
gets us closer to removing undef.
NFC

Added: 
    

Modified: 
    clang/lib/CodeGen/CGCall.cpp
    clang/lib/CodeGen/ConstantInitBuilder.cpp
    clang/test/CodeGen/arm-swiftcall.c
    clang/test/CodeGen/cmse-clear-arg.c
    clang/test/CodeGen/windows-swiftcall.c
    clang/test/CodeGenCXX/arm-swiftcall.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index 0d838b9aeb529..57eb8b2d93d26 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -3466,7 +3466,7 @@ llvm::Value *CodeGenFunction::EmitCMSEClearRecord(llvm::Value *Src,
   int CharsPerElt =
       ATy->getArrayElementType()->getScalarSizeInBits() / CharWidth;
   int MaskIndex = 0;
-  llvm::Value *R = llvm::UndefValue::get(ATy);
+  llvm::Value *R = llvm::PoisonValue::get(ATy);
   for (int I = 0, N = ATy->getArrayNumElements(); I != N; ++I) {
     uint64_t Mask = buildMultiCharMask(Bits, MaskIndex, CharsPerElt, CharWidth,
                                        DataLayout.isBigEndian());
@@ -3640,7 +3640,7 @@ void CodeGenFunction::EmitFunctionEpilog(const CGFunctionInfo &FI,
       // Construct a return type that lacks padding elements.
       llvm::Type *returnType = RetAI.getUnpaddedCoerceAndExpandType();
 
-      RV = llvm::UndefValue::get(returnType);
+      RV = llvm::PoisonValue::get(returnType);
       for (unsigned i = 0, e = results.size(); i != e; ++i) {
         RV = Builder.CreateInsertValue(RV, results[i], i);
       }
@@ -3747,7 +3747,7 @@ static AggValueSlot createPlaceholderSlot(CodeGenFunction &CGF,
   // placeholders.
   llvm::Type *IRTy = CGF.ConvertTypeForMem(Ty);
   llvm::Type *IRPtrTy = IRTy->getPointerTo();
-  llvm::Value *Placeholder = llvm::UndefValue::get(IRPtrTy->getPointerTo());
+  llvm::Value *Placeholder = llvm::PoisonValue::get(IRPtrTy->getPointerTo());
 
   // FIXME: When we generate this IR in one pass, we shouldn't need
   // this win32-specific alignment hack.

diff  --git a/clang/lib/CodeGen/ConstantInitBuilder.cpp b/clang/lib/CodeGen/ConstantInitBuilder.cpp
index 24e3ca19709cb..06d3e44f01b1a 100644
--- a/clang/lib/CodeGen/ConstantInitBuilder.cpp
+++ b/clang/lib/CodeGen/ConstantInitBuilder.cpp
@@ -114,7 +114,7 @@ void ConstantInitBuilderBase::abandon(size_t newEnd) {
   if (newEnd == 0) {
     for (auto &entry : SelfReferences) {
       auto dummy = entry.Dummy;
-      dummy->replaceAllUsesWith(llvm::UndefValue::get(dummy->getType()));
+      dummy->replaceAllUsesWith(llvm::PoisonValue::get(dummy->getType()));
       dummy->eraseFromParent();
     }
     SelfReferences.clear();

diff  --git a/clang/test/CodeGen/arm-swiftcall.c b/clang/test/CodeGen/arm-swiftcall.c
index bd85e7a9aed04..000602819ee01 100644
--- a/clang/test/CodeGen/arm-swiftcall.c
+++ b/clang/test/CodeGen/arm-swiftcall.c
@@ -121,7 +121,7 @@ TEST(struct_1);
 // CHECK:   [[THIRD:%.*]] = load float, float* [[T0]], align
 // CHECK:   [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 4
 // CHECK:   [[FOURTH:%.*]] = load float, float* [[T0]], align
-// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ i32, i16, float, float }]] undef, i32 [[FIRST]], 0
+// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ i32, i16, float, float }]] poison, i32 [[FIRST]], 0
 // CHECK:   [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], i16 [[SECOND]], 1
 // CHECK:   [[T2:%.*]] = insertvalue [[UAGG]] [[T1]], float [[THIRD]], 2
 // CHECK:   [[T3:%.*]] = insertvalue [[UAGG]] [[T2]], float [[FOURTH]], 3
@@ -186,7 +186,7 @@ TEST(struct_2);
 // CHECK:   [[THIRD:%.*]] = load float, float* [[T0]], align
 // CHECK:   [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 3
 // CHECK:   [[FOURTH:%.*]] = load float, float* [[T0]], align
-// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ i32, i32, float, float }]] undef, i32 [[FIRST]], 0
+// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ i32, i32, float, float }]] poison, i32 [[FIRST]], 0
 // CHECK:   [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], i32 [[SECOND]], 1
 // CHECK:   [[T2:%.*]] = insertvalue [[UAGG]] [[T1]], float [[THIRD]], 2
 // CHECK:   [[T3:%.*]] = insertvalue [[UAGG]] [[T2]], float [[FOURTH]], 3
@@ -250,7 +250,7 @@ TEST(struct_misaligned_1)
 // CHECK:   [[FIRST:%.*]] = load i32, i32* [[T0]], align
 // CHECK:   [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 1
 // CHECK:   [[SECOND:%.*]] = load i8, i8* [[T0]], align
-// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ i32, i8 }]] undef, i32 [[FIRST]], 0
+// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ i32, i8 }]] poison, i32 [[FIRST]], 0
 // CHECK:   [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], i8 [[SECOND]], 1
 // CHECK:   ret [[UAGG]] [[T1]]
 // CHECK-LABEL: define{{.*}} @take_struct_misaligned_1(i32 %0, i8 %1)
@@ -290,7 +290,7 @@ TEST(union_het_fp)
 // CHECK:   [[FIRST:%.*]] = load i32, i32* [[T0]], align {{(4|8)}}
 // CHECK:   [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 1
 // CHECK:   [[SECOND:%.*]] = load i32, i32* [[T0]], align {{(4|8)}}
-// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ i32, i32 }]] undef, i32 [[FIRST]], 0
+// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ i32, i32 }]] poison, i32 [[FIRST]], 0
 // CHECK:   [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], i32 [[SECOND]], 1
 // CHECK:   ret [[UAGG]] [[T1]]
 // CHECK-LABEL: define{{.*}} @take_union_het_fp(i32 %0, i32 %1)
@@ -422,7 +422,7 @@ TEST(int8)
 // CHECK:   [[FIRST:%.*]] = load <4 x i32>, <4 x i32>* [[T0]], align
 // CHECK:   [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 1
 // CHECK:   [[SECOND:%.*]] = load <4 x i32>, <4 x i32>* [[T0]], align
-// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, <4 x i32> }]] undef, <4 x i32> [[FIRST]], 0
+// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, <4 x i32> }]] poison, <4 x i32> [[FIRST]], 0
 // CHECK:   [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], <4 x i32> [[SECOND]], 1
 // CHECK:   ret [[UAGG]] [[T1]]
 // CHECK-LABEL: define{{.*}} @take_int8(<4 x i32> %0, <4 x i32> %1)
@@ -465,7 +465,7 @@ TEST(int5)
 // CHECK:   [[FIRST:%.*]] = load <4 x i32>, <4 x i32>* [[T0]], align
 // CHECK:   [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 1
 // CHECK:   [[SECOND:%.*]] = load i32, i32* [[T0]], align
-// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, i32 }]] undef, <4 x i32> [[FIRST]], 0
+// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, i32 }]] poison, <4 x i32> [[FIRST]], 0
 // CHECK:   [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], i32 [[SECOND]], 1
 // CHECK:   ret [[UAGG]] [[T1]]
 // CHECK-LABEL: define{{.*}} @take_int5(<4 x i32> %0, i32 %1)

diff  --git a/clang/test/CodeGen/cmse-clear-arg.c b/clang/test/CodeGen/cmse-clear-arg.c
index 39caa4cebe260..b393a0a26abb3 100644
--- a/clang/test/CodeGen/cmse-clear-arg.c
+++ b/clang/test/CodeGen/cmse-clear-arg.c
@@ -27,7 +27,7 @@ void f0(void) { g0(t0); }
 // CHECK:    define {{.*}} @f0()
 // CHECK-LE: %[[V0:.*]] = and i32 {{.*}}, 1
 // CHECK-BE: %[[V0:.*]] = and i32 {{.*}}, -2147483648
-// CHECK:    %[[V1:.*]] = insertvalue [1 x i32] undef, i32 %[[V0]], 0
+// CHECK:    %[[V1:.*]] = insertvalue [1 x i32] poison, i32 %[[V0]], 0
 // CHECK:    call {{.*}} void %0([1 x i32] %[[V1]])
 
 // LE: 11111111 111111.. 11111111 11111111 0xfffffcff/-769
@@ -46,7 +46,7 @@ void f8(void) { g8(t8); }
 // CHECK:    define {{.*}} @f8()
 // CHECK-LE: %[[V0:.*]] = and i32 {{.*}}, -769
 // CHECK-BE: %[[V0:.*]] = and i32 {{.*}}, -12582913
-// CHECK:    %[[V1:.*]] = insertvalue [1 x i32] undef, i32 %[[V0]], 0
+// CHECK:    %[[V1:.*]] = insertvalue [1 x i32] poison, i32 %[[V0]], 0
 // CHECK:    call {{.*}} void %0([1 x i32] %[[V1]])
 
 // LE(0): 11111111 ........ 11111111 11111111 0xffff00ff/-65281
@@ -69,7 +69,7 @@ void f15_0(void) {
 // CHECK: %[[FN:.*]] = load {{.*}} @g15_0
 // CHECK-LE:  %cmse.clear = and i32 {{.*}}, -65281
 // CHECK-BE:  %cmse.clear = and i32 {{.*}}, -16711681
-// CHECK: %[[R0:.*]] = insertvalue [2 x i32] undef, i32 %cmse.clear, 0
+// CHECK: %[[R0:.*]] = insertvalue [2 x i32] poison, i32 %cmse.clear, 0
 // CHECK-LE: %cmse.clear1 = and i32 {{.*}}, 134215708
 // CHECK-BE: %cmse.clear1 = and i32 {{.*}}, 941621216
 // CHECK: %[[R1:.*]] = insertvalue [2 x i32] %[[R0]], i32 %cmse.clear1, 1
@@ -83,7 +83,7 @@ void f15_1(void) {
 // CHECK: %[[FN:.*]] = load {{.*}} @g15_1
 // CHECK-LE:  %cmse.clear = and i32 {{.*}}, -65281
 // CHECK-BE:  %cmse.clear = and i32 {{.*}}, -16711681
-// CHECK: %[[R0:.*]] = insertvalue [2 x i32] undef, i32 %cmse.clear, 0
+// CHECK: %[[R0:.*]] = insertvalue [2 x i32] poison, i32 %cmse.clear, 0
 // CHECK-LE: %cmse.clear1 = and i32 {{.*}}, 134215708
 // CHECK-BE: %cmse.clear1 = and i32 {{.*}}, 941621216
 // CHECK: %[[R1:.*]] = insertvalue [2 x i32] %[[R0]], i32 %cmse.clear1, 1
@@ -110,7 +110,7 @@ void f16_0(void) {
 // CHECK: %[[FN:.*]] = load {{.*}} @g16_0
 // CHECK-LE: %cmse.clear = and i64 {{.*}}, 9079291968726434047
 // CHECK-BE: %cmse.clear = and i64 {{.*}}, -71776123088273282
-// CHECK: %[[R:.*]] = insertvalue [1 x i64] undef, i64 %cmse.clear, 0
+// CHECK: %[[R:.*]] = insertvalue [1 x i64] poison, i64 %cmse.clear, 0
 // CHECK: call {{.*}} void %0([1 x i64] %[[R]])
 
 
@@ -140,7 +140,7 @@ void f18(void) {
 // CHECK:    %[[FN:.*]] = load {{.*}} @g18
 // CHECK-LE: %cmse.clear = and i32 {{.*}}, 32702963
 // CHECK-BE: %cmse.clear = and i32 {{.*}}, -813641856
-// CHECK:    %[[R0:.*]] = insertvalue [4 x i32] undef, i32 %cmse.clear, 0
+// CHECK:    %[[R0:.*]] = insertvalue [4 x i32] poison, i32 %cmse.clear, 0
 // CHECK-LE: %cmse.clear1 = and i32 {{.*}}, 32702963
 // CHECK-BE: %cmse.clear1 = and i32 {{.*}}, -813641856
 // CHECK:    %[[R1:.*]] = insertvalue [4 x i32] %[[R0]], i32 %cmse.clear1, 1
@@ -170,7 +170,7 @@ void f19(void) {
 // CHECK:    %[[FN:.*]] = load {{.*}} @g19
 // CHECK-LE: %cmse.clear = and i32 {{.*}}, 943259647
 // CHECK-BE: %cmse.clear = and i32 {{.*}}, -58340
-// CHECK:    %[[R:.*]] = insertvalue [1 x i32] undef, i32 %cmse.clear, 0
+// CHECK:    %[[R:.*]] = insertvalue [1 x i32] poison, i32 %cmse.clear, 0
 // CHECK:    call {{.*}} void %[[FN]]([1 x i32] %[[R]])
 
 

diff  --git a/clang/test/CodeGen/windows-swiftcall.c b/clang/test/CodeGen/windows-swiftcall.c
index 697d4f8ac4f63..0aa93fae0581d 100644
--- a/clang/test/CodeGen/windows-swiftcall.c
+++ b/clang/test/CodeGen/windows-swiftcall.c
@@ -105,7 +105,7 @@ TEST(struct_1);
 // CHECK:   [[T0:%.*]] = load i64, i64* [[GEP0]], align 4
 // CHECK:   [[GEP1:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST]], i32 0, i32 1
 // CHECK:   [[T1:%.*]] = load i64, i64* [[GEP1]], align 4
-// CHECK:   [[R0:%.*]] = insertvalue { i64, i64 } undef, i64 [[T0]], 0
+// CHECK:   [[R0:%.*]] = insertvalue { i64, i64 } poison, i64 [[T0]], 0
 // CHECK:   [[R1:%.*]] = insertvalue { i64, i64 } [[R0]], i64 [[T1]], 1
 // CHECK:   ret { i64, i64 } [[R1]]
 // CHECK: }
@@ -154,7 +154,7 @@ TEST(struct_2);
 // CHECK:   [[T0:%.*]] = load i64, i64* [[GEP0]], align 4
 // CHECK:   [[GEP1:%.*]] = getelementptr inbounds { i64, i64 }, { i64, i64 }* [[CAST]], i32 0, i32 1
 // CHECK:   [[T1:%.*]] = load i64, i64* [[GEP1]], align 4
-// CHECK:   [[R0:%.*]] = insertvalue { i64, i64 } undef, i64 [[T0]], 0
+// CHECK:   [[R0:%.*]] = insertvalue { i64, i64 } poison, i64 [[T0]], 0
 // CHECK:   [[R1:%.*]] = insertvalue { i64, i64 } [[R0]], i64 [[T1]], 1
 // CHECK:   ret { i64, i64 } [[R1]]
 // CHECK: }
@@ -375,7 +375,7 @@ TEST(int8)
 // CHECK:   [[FIRST:%.*]] = load <4 x i32>, <4 x i32>* [[T0]], align
 // CHECK:   [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 1
 // CHECK:   [[SECOND:%.*]] = load <4 x i32>, <4 x i32>* [[T0]], align
-// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, <4 x i32> }]] undef, <4 x i32> [[FIRST]], 0
+// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, <4 x i32> }]] poison, <4 x i32> [[FIRST]], 0
 // CHECK:   [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], <4 x i32> [[SECOND]], 1
 // CHECK:   ret [[UAGG]] [[T1]]
 // CHECK-LABEL: define {{.*}} @take_int8(<4 x i32> noundef %0, <4 x i32> noundef %1)
@@ -419,7 +419,7 @@ TEST(int5)
 // CHECK:   [[FIRST:%.*]] = load <4 x i32>, <4 x i32>* [[T0]], align
 // CHECK:   [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 1
 // CHECK:   [[SECOND:%.*]] = load i32, i32* [[T0]], align
-// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, i32 }]] undef, <4 x i32> [[FIRST]], 0
+// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ <4 x i32>, i32 }]] poison, <4 x i32> [[FIRST]], 0
 // CHECK:   [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], i32 [[SECOND]], 1
 // CHECK:   ret [[UAGG]] [[T1]]
 // CHECK-LABEL: define {{.*}} @take_int5(<4 x i32> %0, i32 %1)

diff  --git a/clang/test/CodeGenCXX/arm-swiftcall.cpp b/clang/test/CodeGenCXX/arm-swiftcall.cpp
index 0d6c9832cd5e1..45cfd260a5d50 100644
--- a/clang/test/CodeGenCXX/arm-swiftcall.cpp
+++ b/clang/test/CodeGenCXX/arm-swiftcall.cpp
@@ -58,7 +58,7 @@ TEST(struct_1);
 // CHECK:   [[THIRD:%.*]] = load float, float* [[T0]], align 4
 // CHECK:   [[T0:%.*]] = getelementptr inbounds [[AGG]], [[AGG]]* [[CAST_TMP]], i32 0, i32 5
 // CHECK:   [[FOURTH:%.*]] = load float, float* [[T0]], align 4
-// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ i32, i8, float, float }]] undef, i32 [[FIRST]], 0
+// CHECK:   [[T0:%.*]] = insertvalue [[UAGG:{ i32, i8, float, float }]] poison, i32 [[FIRST]], 0
 // CHECK:   [[T1:%.*]] = insertvalue [[UAGG]] [[T0]], i8 [[SECOND]], 1
 // CHECK:   [[T2:%.*]] = insertvalue [[UAGG]] [[T1]], float [[THIRD]], 2
 // CHECK:   [[T3:%.*]] = insertvalue [[UAGG]] [[T2]], float [[FOURTH]], 3


        


More information about the cfe-commits mailing list