[PATCH] D158101: [Verifier] Allow undef/poison in entry_values expressions.

Felipe de Azevedo Piovezan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 16 11:10:56 PDT 2023


fdeazeve created this revision.
fdeazeve added a reviewer: aprantl.
Herald added a subscriber: hiraditya.
Herald added a project: All.
fdeazeve requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

This patch relaxes the verifier when it checks whether an OP_entry_value has a
valid Value associated with it. We now allow undef/poison values as well, since
those may be introduced naturally through optimization.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D158101

Files:
  llvm/lib/IR/Verifier.cpp
  llvm/test/Verifier/diexpression-entry-value-llvm-ir.ll


Index: llvm/test/Verifier/diexpression-entry-value-llvm-ir.ll
===================================================================
--- llvm/test/Verifier/diexpression-entry-value-llvm-ir.ll
+++ llvm/test/Verifier/diexpression-entry-value-llvm-ir.ll
@@ -1,14 +1,18 @@
 ; RUN: llvm-as -disable-output <%s 2>&1| FileCheck %s
 
+; CHECK-NOT: llvm.dbg.value
 ; CHECK: Entry values are only allowed in MIR unless they target a swiftasync Argument
 ; CHECK: call void @llvm.dbg.value(metadata i32 %param, metadata !{{.*}}, metadata !DIExpression(DW_OP_LLVM_entry_value, 1))
 ; CHECK-NOT: llvm.dbg.value
+; CHECK-NOT: Entry values are only allowed
 ; CHECK: warning: ignoring invalid debug info
 
 define void @foo(i32 %param, ptr swiftasync %ok_param) !dbg !4 {
 entry:
   call void @llvm.dbg.value(metadata i32 %param, metadata !8, metadata !DIExpression(DW_OP_LLVM_entry_value, 1)), !dbg !9
   call void @llvm.dbg.value(metadata ptr %ok_param, metadata !8, metadata !DIExpression(DW_OP_LLVM_entry_value, 1)), !dbg !9
+  call void @llvm.dbg.value(metadata ptr poison, metadata !8, metadata !DIExpression(DW_OP_LLVM_entry_value, 1)), !dbg !9
+  call void @llvm.dbg.value(metadata ptr undef, metadata !8, metadata !DIExpression(DW_OP_LLVM_entry_value, 1)), !dbg !9
   ret void
 }
 
Index: llvm/lib/IR/Verifier.cpp
===================================================================
--- llvm/lib/IR/Verifier.cpp
+++ llvm/lib/IR/Verifier.cpp
@@ -6398,12 +6398,16 @@
   if (!E || !E->isValid())
     return;
 
-  // We allow EntryValues for swift async arguments, as they have an
-  // ABI-guarantee to be turned into a specific register.
-  if (isa<ValueAsMetadata>(I.getRawLocation()))
-    if (auto *ArgLoc = dyn_cast_or_null<Argument>(I.getVariableLocationOp(0));
+  if (isa<ValueAsMetadata>(I.getRawLocation())) {
+    Value *VarValue = I.getVariableLocationOp(0);
+    if (isa<UndefValue>(VarValue) || isa<PoisonValue>(VarValue))
+      return;
+    // We allow EntryValues for swift async arguments, as they have an
+    // ABI-guarantee to be turned into a specific register.
+    if (auto *ArgLoc = dyn_cast_or_null<Argument>(VarValue);
         ArgLoc && ArgLoc->hasAttribute(Attribute::SwiftAsync))
       return;
+  }
 
   CheckDI(!E->isEntryValue(),
           "Entry values are only allowed in MIR unless they target a "


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D158101.550816.patch
Type: text/x-patch
Size: 2323 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230816/5e17f7f6/attachment.bin>


More information about the llvm-commits mailing list