[llvm] 26ea983 - [Verifier] Allow undef/poison in entry_values expressions.

Felipe de Azevedo Piovezan via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 17 06:16:14 PDT 2023


Author: Felipe de Azevedo Piovezan
Date: 2023-08-17T09:16:08-04:00
New Revision: 26ea983d228dd00db1599c7718fa687e5e0bbe6a

URL: https://github.com/llvm/llvm-project/commit/26ea983d228dd00db1599c7718fa687e5e0bbe6a
DIFF: https://github.com/llvm/llvm-project/commit/26ea983d228dd00db1599c7718fa687e5e0bbe6a.diff

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

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.

Differential Revision: https://reviews.llvm.org/D158101

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp
index dff3cef96dfba6..116651c8365e8e 100644
--- a/llvm/lib/IR/Verifier.cpp
+++ b/llvm/lib/IR/Verifier.cpp
@@ -6403,12 +6403,16 @@ void Verifier::verifyNotEntryValue(const DbgVariableIntrinsic &I) {
   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 "

diff  --git a/llvm/test/Verifier/diexpression-entry-value-llvm-ir.ll b/llvm/test/Verifier/diexpression-entry-value-llvm-ir.ll
index 484e6713761cdf..652e6667bfc5c1 100644
--- a/llvm/test/Verifier/diexpression-entry-value-llvm-ir.ll
+++ b/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
 }
 


        


More information about the llvm-commits mailing list