[debuginfo-tests] r363952 - Store a pointer to the return value in a static alloca and let the debugger use that
Amy Huang via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 20 10:15:22 PDT 2019
Author: akhuang
Date: Thu Jun 20 10:15:21 2019
New Revision: 363952
URL: http://llvm.org/viewvc/llvm-project?rev=363952&view=rev
Log:
Store a pointer to the return value in a static alloca and let the debugger use that
as the variable address for NRVO variables.
Subscribers: hiraditya, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D63361
Added:
debuginfo-tests/trunk/win_cdb/nrvo.cpp
Modified:
debuginfo-tests/trunk/nrvo-string.cpp
Modified: debuginfo-tests/trunk/nrvo-string.cpp
URL: http://llvm.org/viewvc/llvm-project/debuginfo-tests/trunk/nrvo-string.cpp?rev=363952&r1=363951&r2=363952&view=diff
==============================================================================
--- debuginfo-tests/trunk/nrvo-string.cpp (original)
+++ debuginfo-tests/trunk/nrvo-string.cpp Thu Jun 20 10:15:21 2019
@@ -17,11 +17,32 @@ struct string {
string get_string() {
string unused;
string result = 3;
-// DEBUGGER: break 21
+ // DEBUGGER: break 21
return result;
}
-int main() { get_string(); }
+void some_function(int) {}
+struct string2 {
+ string2() = default;
+ string2(string2 &&other) { i = other.i; }
+ int i;
+};
+string2 get_string2() {
+ string2 result;
+ result.i = 5;
+ some_function(result.i);
+ // Test that the debugger can get the value of result after another
+ // function is called.
+ // DEBUGGER: break 35
+ return result;
+}
+int main() {
+ get_string();
+ get_string2();
+}
// DEBUGGER: r
// DEBUGGER: print result.i
// CHECK: = 3
+// DEBUGGER: c
+// DEBUGGER: print result.i
+// CHECK: = 5
Added: debuginfo-tests/trunk/win_cdb/nrvo.cpp
URL: http://llvm.org/viewvc/llvm-project/debuginfo-tests/trunk/win_cdb/nrvo.cpp?rev=363952&view=auto
==============================================================================
--- debuginfo-tests/trunk/win_cdb/nrvo.cpp (added)
+++ debuginfo-tests/trunk/win_cdb/nrvo.cpp Thu Jun 20 10:15:21 2019
@@ -0,0 +1,49 @@
+// This ensures that DW_OP_deref is inserted when necessary, such as when NRVO
+// of a string object occurs in C++.
+//
+// RUN: %clang_cl %s -o %t.exe -fuse-ld=lld -Z7
+// RUN: grep DE[B]UGGER: %s | sed -e 's/.*DE[B]UGGER: //' > %t.script
+// RUN: %cdb -cf %t.script %t.exe | FileCheck %s --check-prefixes=DEBUGGER,CHECK
+//
+
+struct string {
+ string() {}
+ string(int i) : i(i) {}
+ ~string() {}
+ int i = 0;
+};
+string get_string() {
+ string unused;
+ string result = 3;
+ __debugbreak();
+ return result;
+}
+void some_function(int) {}
+struct string2 {
+ string2() = default;
+ string2(string2 &&other) { i = other.i; }
+ int i;
+};
+string2 get_string2() {
+ string2 result;
+ result.i = 5;
+ some_function(result.i);
+ // Test that the debugger can get the value of result after another
+ // function is called.
+ __debugbreak();
+ return result;
+}
+int main() {
+ get_string();
+ get_string2();
+}
+
+// DEBUGGER: g
+// DEBUGGER: ?? result
+// CHECK: struct string *
+// CHECK: +0x000 i : 0n3
+// DEBUGGER: g
+// DEBUGGER: ?? result
+// CHECK: struct string2 *
+// CHECK: +0x000 i : 0n5
+// DEBUGGER: q
More information about the llvm-commits
mailing list