Skip to content

Commit 0222dc0

Browse files
committed
Salvage debug info from ptrauth intrinsics.
rdar://80227769
1 parent 1f82a27 commit 0222dc0

File tree

3 files changed

+32
-5
lines changed

3 files changed

+32
-5
lines changed

llvm/lib/Transforms/Coroutines/CoroFrame.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2527,11 +2527,6 @@ void coro::salvageDebugInfo(
25272527
Expr = DIExpression::prepend(Expr, DIExpression::DerefBefore);
25282528
} else if (auto *StInst = dyn_cast<StoreInst>(Inst)) {
25292529
Storage = StInst->getOperand(0);
2530-
} else if (auto *IInst = dyn_cast<llvm::IntrinsicInst>(Inst)) {
2531-
if (IInst->getIntrinsicID() == Intrinsic::ptrauth_auth)
2532-
Storage = IInst->getArgOperand(0);
2533-
else
2534-
break;
25352530
} else if (auto *Phi = dyn_cast<PHINode>(Inst)) {
25362531
if (Phi->getNumIncomingValues() != 1)
25372532
return;

llvm/lib/Transforms/Utils/Local.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1937,6 +1937,11 @@ Value *llvm::salvageDebugInfoImpl(Instruction &I, uint64_t CurrentLocOps,
19371937
// *Not* to do: we should not attempt to salvage load instructions,
19381938
// because the validity and lifetime of a dbg.value containing
19391939
// DW_OP_deref becomes difficult to analyze. See PR40628 for examples.
1940+
1941+
if (auto *IInst = dyn_cast<llvm::IntrinsicInst>(&I))
1942+
if (IInst->getIntrinsicID() == Intrinsic::ptrauth_auth)
1943+
return IInst->getArgOperand(0);
1944+
19401945
return nullptr;
19411946
}
19421947

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
; RUN: opt -mtriple arm64e-apple-darwin -adce %s -S -o - | FileCheck %s
2+
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
3+
4+
declare i64 @llvm.ptrauth.auth.i64(i64, i32, i64)
5+
6+
define void @f(i64 %arg, i64 %arg1) !dbg !8 {
7+
entry:
8+
%tmp = call i64 @llvm.ptrauth.auth.i64(i64 %arg, i32 0, i64 %arg1)
9+
; CHECK: call void @llvm.dbg.value(metadata i64 %arg,
10+
; CHECK-SAME: !DIExpression())
11+
call void @llvm.dbg.value(metadata i64 %tmp, metadata !11, metadata !DIExpression()), !dbg !13
12+
ret void, !dbg !13
13+
}
14+
declare void @llvm.dbg.value(metadata, metadata, metadata)
15+
16+
!llvm.dbg.cu = !{!0}
17+
!llvm.module.flags = !{!3, !4}
18+
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, emissionKind: FullDebug)
19+
!1 = !DIFile(filename: "salavage.c", directory: "/")
20+
!3 = !{i32 2, !"Dwarf Version", i32 4}
21+
!4 = !{i32 2, !"Debug Info Version", i32 3}
22+
!8 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !9, isLocal: false, isDefinition: true, scopeLine: 1, isOptimized: false, unit: !0)
23+
!9 = !DISubroutineType(types: !10)
24+
!10 = !{null}
25+
!11 = !DILocalVariable(name: "x", scope: !8, file: !1, line: 2, type: !12)
26+
!12 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
27+
!13 = !DILocation(line: 1, column: 1, scope: !8)

0 commit comments

Comments
 (0)