diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp --- a/llvm/lib/IR/Verifier.cpp +++ b/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(I.getRawLocation())) - if (auto *ArgLoc = dyn_cast_or_null(I.getVariableLocationOp(0)); + if (isa(I.getRawLocation())) { + Value *VarValue = I.getVariableLocationOp(0); + if (isa(VarValue) || isa(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(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 --- 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 }