[Lldb-commits] [PATCH] D61146: Set a CXXRecordDecl to not be passed in registers if DW_CC_pass_by_reference when loading from DWARF
Shafik Yaghmour via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed May 1 15:22:26 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL359732: Set a CXXRecordDecl to not be passed in registers if DW_CC_pass_by_reference… (authored by shafik, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Changed prior to commit:
https://reviews.llvm.org/D61146?vs=197636&id=197655#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D61146/new/
https://reviews.llvm.org/D61146
Files:
lldb/trunk/packages/Python/lldbsuite/test/expression_command/argument_passing_restrictions/Makefile
lldb/trunk/packages/Python/lldbsuite/test/expression_command/argument_passing_restrictions/TestArgumentPassingRestrictions.py
lldb/trunk/packages/Python/lldbsuite/test/expression_command/argument_passing_restrictions/main.cpp
lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
Index: lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
===================================================================
--- lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
+++ lldb/trunk/source/Plugins/SymbolFile/DWARF/DWARFASTParserClang.cpp
@@ -959,6 +959,14 @@
}
}
+ if (calling_convention == llvm::dwarf::DW_CC_pass_by_reference) {
+ clang::CXXRecordDecl *record_decl =
+ m_ast.GetAsCXXRecordDecl(clang_type.GetOpaqueQualType());
+ if (record_decl)
+ record_decl->setArgPassingRestrictions(
+ clang::RecordDecl::APK_CannotPassInRegs);
+ }
+
} break;
case DW_TAG_enumeration_type: {
Index: lldb/trunk/packages/Python/lldbsuite/test/expression_command/argument_passing_restrictions/Makefile
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/argument_passing_restrictions/Makefile
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/argument_passing_restrictions/Makefile
@@ -0,0 +1,5 @@
+LEVEL = ../../make
+
+CXX_SOURCES := main.cpp
+
+include $(LEVEL)/Makefile.rules
Index: lldb/trunk/packages/Python/lldbsuite/test/expression_command/argument_passing_restrictions/TestArgumentPassingRestrictions.py
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/argument_passing_restrictions/TestArgumentPassingRestrictions.py
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/argument_passing_restrictions/TestArgumentPassingRestrictions.py
@@ -0,0 +1,32 @@
+"""
+This is a test to ensure that both lldb is reconstructing the right
+calling convention for a CXXRecordDecl as represented by:
+
+ DW_CC_pass_by_reference
+ DW_CC_pass_by_value
+
+and to also make sure that the ASTImporter is copying over this
+setting when importing the CXXRecordDecl via setArgPassingRestrictions.
+"""
+
+
+import lldb
+from lldbsuite.test.decorators import *
+from lldbsuite.test.lldbtest import *
+from lldbsuite.test import lldbutil
+
+class TestArgumentPassingRestrictions(TestBase):
+
+ mydir = TestBase.compute_mydir(__file__)
+
+ def test_argument_passing_restrictions(self):
+ self.build()
+
+ lldbutil.run_to_source_breakpoint(self, '// break here',
+ lldb.SBFileSpec("main.cpp"))
+
+ self.expect("expr returnPassByRef()",
+ substrs=['(PassByRef)', '= 11223344'])
+
+ self.expect("expr takePassByRef(p)",
+ substrs=['(int)', '= 42'])
Index: lldb/trunk/packages/Python/lldbsuite/test/expression_command/argument_passing_restrictions/main.cpp
===================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/argument_passing_restrictions/main.cpp
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/argument_passing_restrictions/main.cpp
@@ -0,0 +1,19 @@
+// This structure has a non-trivial copy constructor so
+// it needs to be passed by reference.
+struct PassByRef {
+ PassByRef() = default;
+ PassByRef(const PassByRef &p){x = p.x;};
+
+ int x = 11223344;
+};
+
+PassByRef returnPassByRef() { return PassByRef(); }
+int takePassByRef(PassByRef p) {
+ return p.x;
+}
+
+int main() {
+ PassByRef p = returnPassByRef();
+ p.x = 42;
+ return takePassByRef(p); // break here
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D61146.197655.patch
Type: text/x-patch
Size: 3454 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20190501/bfcf46e0/attachment-0001.bin>
More information about the lldb-commits
mailing list