aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShan Huang <52285902006@stu.ecnu.edu.cn>2024-07-08 11:05:00 +0800
committerGitHub <noreply@github.com>2024-07-08 11:05:00 +0800
commit431b9965f59ad68e5c7d7112bc6b7ea154e5f85c (patch)
treeff10ae901b7620e6243bd1fd1bbc122d296cc489
parent73bfb65c5714c6442a00bce866132d28ea609254 (diff)
downloadllvm-431b9965f59ad68e5c7d7112bc6b7ea154e5f85c.zip
llvm-431b9965f59ad68e5c7d7112bc6b7ea154e5f85c.tar.gz
llvm-431b9965f59ad68e5c7d7112bc6b7ea154e5f85c.tar.bz2
[DebugInfo][SpeculativeExecution] Drop the debug location of the hoisted instruction (#97384)
Fix #97375 .
-rw-r--r--llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp1
-rw-r--r--llvm/test/Transforms/SpeculativeExecution/dropping-debugloc-hoist.ll36
2 files changed, 37 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp b/llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp
index f921ee72..ed9c182 100644
--- a/llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp
+++ b/llvm/lib/Transforms/Scalar/SpeculativeExecution.cpp
@@ -328,6 +328,7 @@ bool SpeculativeExecutionPass::considerHoistingFromTo(
++I;
if (!NotHoisted.count(&*Current)) {
Current->moveBefore(ToBlock.getTerminator());
+ Current->dropLocation();
}
}
return true;
diff --git a/llvm/test/Transforms/SpeculativeExecution/dropping-debugloc-hoist.ll b/llvm/test/Transforms/SpeculativeExecution/dropping-debugloc-hoist.ll
new file mode 100644
index 0000000..6355219
--- /dev/null
+++ b/llvm/test/Transforms/SpeculativeExecution/dropping-debugloc-hoist.ll
@@ -0,0 +1,36 @@
+; RUN: opt -S -passes=speculative-execution %s | FileCheck %s
+
+; Check that SpeculativeExecution's considerHoistingFromTo() drops
+; the debug location of the hoisted instructions in a certain branch.
+
+define void @ifThen() !dbg !5 {
+; CHECK-LABEL: define void @ifThen(
+; CHECK-SAME: ) !dbg [[DBG5:![0-9]+]] {
+; CHECK-NEXT: [[X:%.*]] = add i32 2, 3{{$}}
+;
+ br i1 true, label %a, label %b, !dbg !8
+
+a: ; preds = %0
+ %x = add i32 2, 3, !dbg !9
+ br label %b, !dbg !10
+
+b: ; preds = %a, %0
+ ret void, !dbg !11
+}
+
+!llvm.dbg.cu = !{!0}
+!llvm.debugify = !{!2, !3}
+!llvm.module.flags = !{!4}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C, file: !1, producer: "debugify", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
+!1 = !DIFile(filename: "main.ll", directory: "/")
+!2 = !{i32 4}
+!3 = !{i32 0}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = distinct !DISubprogram(name: "ifThen", linkageName: "ifThen", scope: null, file: !1, line: 1, type: !6, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
+!6 = !DISubroutineType(types: !7)
+!7 = !{}
+!8 = !DILocation(line: 1, column: 1, scope: !5)
+!9 = !DILocation(line: 2, column: 1, scope: !5)
+!10 = !DILocation(line: 3, column: 1, scope: !5)
+!11 = !DILocation(line: 4, column: 1, scope: !5)