[PATCH] D139789: Use poison instead of undef where its used as a placeholder [NFC]

Manuel Brito via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Dec 11 09:06:34 PST 2022


ManuelJBrito created this revision.
ManuelJBrito added a reviewer: nlopes.
Herald added subscribers: Enna1, ThomasRaoux, hiraditya.
Herald added a project: All.
ManuelJBrito requested review of this revision.
Herald added a reviewer: zuban32.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The following instances of undef are used as placeholders for aggregate construction so this patch intends to replace them with poison.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139789

Files:
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/CodeGen/SjLjEHPrepare.cpp
  llvm/lib/Target/SPIRV/SPIRVPrepareFunctions.cpp
  llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
  llvm/test/Instrumentation/ThreadSanitizer/atomic.ll


Index: llvm/test/Instrumentation/ThreadSanitizer/atomic.ll
===================================================================
--- llvm/test/Instrumentation/ThreadSanitizer/atomic.ll
+++ llvm/test/Instrumentation/ThreadSanitizer/atomic.ll
@@ -1645,7 +1645,7 @@
 ; CHECK-NEXT: {{.*}} = call i64 @__tsan_atomic64_compare_exchange_val(ptr {{.*}}, i64 {{.*}}, i64 {{.*}}, i32 5, i32 5), !dbg
 ; CHECK-NEXT: {{.*}} = icmp eq i64
 ; CHECK-NEXT: {{.*}} = inttoptr i64 {{.*}} to ptr
-; CHECK-NEXT: {{.*}} = insertvalue { ptr, i1 } undef, ptr {{.*}}, 0
+; CHECK-NEXT: {{.*}} = insertvalue { ptr, i1 } poison, ptr {{.*}}, 0
 ; CHECK-NEXT: {{.*}} = insertvalue { ptr, i1 } {{.*}}, i1 {{.*}}, 1
 
 define i128 @atomic128_load_unordered(ptr %a) nounwind uwtable {
Index: llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
@@ -801,7 +801,7 @@
     }
 
     Value *Res =
-      IRB.CreateInsertValue(UndefValue::get(CASI->getType()), OldVal, 0);
+      IRB.CreateInsertValue(PoisonValue::get(CASI->getType()), OldVal, 0);
     Res = IRB.CreateInsertValue(Res, Success, 1);
 
     I->replaceAllUsesWith(Res);
Index: llvm/lib/Target/SPIRV/SPIRVPrepareFunctions.cpp
===================================================================
--- llvm/lib/Target/SPIRV/SPIRVPrepareFunctions.cpp
+++ llvm/lib/Target/SPIRV/SPIRVPrepareFunctions.cpp
@@ -283,7 +283,7 @@
   // umul.with.overflow intrinsic return a structure, where the first element
   // is the multiplication result, and the second is an overflow bit.
   Type *StructTy = UMulFunc->getReturnType();
-  Value *Agg = IRB.CreateInsertValue(UndefValue::get(StructTy), Mul, {0});
+  Value *Agg = IRB.CreateInsertValue(PoisonValue::get(StructTy), Mul, {0});
   Value *Res = IRB.CreateInsertValue(Agg, Overflow, {1});
   IRB.CreateRet(Res);
 }
Index: llvm/lib/CodeGen/SjLjEHPrepare.cpp
===================================================================
--- llvm/lib/CodeGen/SjLjEHPrepare.cpp
+++ llvm/lib/CodeGen/SjLjEHPrepare.cpp
@@ -164,7 +164,7 @@
   // There are still some uses of LPI. Construct an aggregate with the exception
   // values and replace the LPI with that aggregate.
   Type *LPadType = LPI->getType();
-  Value *LPadVal = UndefValue::get(LPadType);
+  Value *LPadVal = PoisonValue::get(LPadType);
   auto *SelI = cast<Instruction>(SelVal);
   IRBuilder<> Builder(SelI->getParent(), std::next(SelI->getIterator()));
   LPadVal = Builder.CreateInsertValue(LPadVal, ExnVal, 0, "lpad.val");
Index: llvm/lib/Analysis/ValueTracking.cpp
===================================================================
--- llvm/lib/Analysis/ValueTracking.cpp
+++ llvm/lib/Analysis/ValueTracking.cpp
@@ -4107,7 +4107,7 @@
   assert(InsertBefore && "Must have someplace to insert!");
   Type *IndexedType = ExtractValueInst::getIndexedType(From->getType(),
                                                              idx_range);
-  Value *To = UndefValue::get(IndexedType);
+  Value *To = PoisonValue::get(IndexedType);
   SmallVector<unsigned, 10> Idxs(idx_range.begin(), idx_range.end());
   unsigned IdxSkip = Idxs.size();
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139789.481915.patch
Type: text/x-patch
Size: 3253 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221211/85dc9890/attachment-0001.bin>


More information about the llvm-commits mailing list