[PATCH] D140906: [DebugInfo] Replace UndefValue with PoisonValue in AssignmentTrackingAnalysis

Orlando Cazalet-Hyams via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jan 3 09:10:56 PST 2023


Orlando created this revision.
Orlando added reviewers: StephenTozer, jmorse, djtodoro, jryans, scott.linder, nlopes.
Orlando added a project: debug-info.
Herald added a subscriber: hiraditya.
Herald added a project: All.
Orlando requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This helps towards the effort to remove UndefValue from LLVM.

Related to https://discourse.llvm.org/t/auto-undef-debug-uses-of-a-deleted-value


https://reviews.llvm.org/D140906

Files:
  llvm/include/llvm/IR/IntrinsicInst.h
  llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
  llvm/lib/IR/IntrinsicInst.cpp


Index: llvm/lib/IR/IntrinsicInst.cpp
===================================================================
--- llvm/lib/IR/IntrinsicInst.cpp
+++ llvm/lib/IR/IntrinsicInst.cpp
@@ -217,6 +217,11 @@
              MetadataAsValue::get(getContext(), ValueAsMetadata::get(V)));
 }
 
+bool DbgAssignIntrinsic::isAddressKillLocation() {
+  Value *Addr = getAddress();
+  return !Addr || isa<UndefValue>(Addr);
+}
+
 int llvm::Intrinsic::lookupLLVMIntrinsicByName(ArrayRef<const char *> NameTable,
                                                StringRef Name) {
   assert(Name.startswith("llvm."));
Index: llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
===================================================================
--- llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
+++ llvm/lib/CodeGen/AssignmentTrackingAnalysis.cpp
@@ -1235,10 +1235,8 @@
   DILocation *DL = Source->getDebugLoc();
   auto Emit = [this, Source, After, DL](Value *Val, DIExpression *Expr) {
     assert(Expr);
-    // It's possible that getVariableLocationOp(0) is null. Occurs in
-    // llvm/test/DebugInfo/Generic/2010-05-03-OriginDIE.ll Treat it as undef.
     if (!Val)
-      Val = UndefValue::get(Type::getInt1Ty(Source->getContext()));
+      Val = PoisonValue::get(Type::getInt1Ty(Source->getContext()));
 
     // Find a suitable insert point.
     Instruction *InsertBefore = After->getNextNode();
@@ -1284,16 +1282,13 @@
   if (Kind == LocKind::Val) {
     /// Get the value component, converting to Undef if it is variadic.
     Value *Val =
-        Source->hasArgList()
-            ? UndefValue::get(Source->getVariableLocationOp(0)->getType())
-            : Source->getVariableLocationOp(0);
+        Source->hasArgList() ? nullptr : Source->getVariableLocationOp(0);
     Emit(Val, Source->getExpression());
     return;
   }
 
   if (Kind == LocKind::None) {
-    Value *Val = UndefValue::get(Source->getVariableLocationOp(0)->getType());
-    Emit(Val, Source->getExpression());
+    Emit(nullptr, Source->getExpression());
     return;
   }
 }
@@ -1479,7 +1474,7 @@
     // that an assignment happened here, and we know that specific assignment
     // was the last one to take place in memory for this variable.
     LocKind Kind;
-    if (isa<UndefValue>(DAI.getAddress())) {
+    if (DAI.isAddressKillLocation()) {
       // Address may be undef to indicate that although the store does take
       // place, this part of the original store has been elided.
       LLVM_DEBUG(
@@ -2110,7 +2105,7 @@
         // We can't handle variadic DIExpressions yet so treat those as
         // kill locations.
         if (DVI->isKillLocation() || DVI->hasArgList())
-          return UndefValue::get(Type::getInt32Ty(DVI->getContext()));
+          return PoisonValue::get(Type::getInt32Ty(DVI->getContext()));
         return DVI->getValue();
       };
       Instruction *InsertBefore = I.getNextNode();
Index: llvm/include/llvm/IR/IntrinsicInst.h
===================================================================
--- llvm/include/llvm/IR/IntrinsicInst.h
+++ llvm/include/llvm/IR/IntrinsicInst.h
@@ -448,6 +448,7 @@
   void setAssignId(DIAssignID *New);
   void setAddress(Value *V);
   void setValue(Value *V);
+  bool isAddressKillLocation();
   /// \name Casting methods
   /// @{
   static bool classof(const IntrinsicInst *I) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140906.486009.patch
Type: text/x-patch
Size: 3320 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230103/df115d23/attachment.bin>


More information about the llvm-commits mailing list