summaryrefslogtreecommitdiff
path: root/unittests/IR/MetadataTest.cpp
diff options
context:
space:
mode:
authorReid Kleckner <rnk@google.com>2016-06-08 20:34:29 +0000
committerReid Kleckner <rnk@google.com>2016-06-08 20:34:29 +0000
commit3d3aca2d9709c82c26c7d1388bb10e7c454c4411 (patch)
tree54d8fc9c3a2d068437b259df8b0ea89bff1cd159 /unittests/IR/MetadataTest.cpp
parent2ae3d2cd86abdfda2b266528b461d0703c31086d (diff)
[DebugInfo] Add calling convention support for DWARF and CodeView
Summary: Now DISubroutineType has a 'cc' field which should be a DW_CC_ enum. If it is present and non-zero, the backend will emit it as a DW_AT_calling_convention attribute. On the CodeView side, we translate it to the appropriate enum for the LF_PROCEDURE record. I added a new LLVM vendor specific enum to the list of DWARF calling conventions. DWARF does not appear to attempt to standardize these, so I assume it's OK to do this until we coordinate with GCC on how to emit vectorcall convention functions. Reviewers: dexonsmith, majnemer, aaboud, amccarth Subscribers: mehdi_amini, llvm-commits Differential Revision: http://reviews.llvm.org/D21114 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@272197 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/IR/MetadataTest.cpp')
-rw-r--r--unittests/IR/MetadataTest.cpp31
1 files changed, 23 insertions, 8 deletions
diff --git a/unittests/IR/MetadataTest.cpp b/unittests/IR/MetadataTest.cpp
index d3db053c099..a7a28e041b3 100644
--- a/unittests/IR/MetadataTest.cpp
+++ b/unittests/IR/MetadataTest.cpp
@@ -80,7 +80,7 @@ protected:
MDTuple *getTuple() { return MDTuple::getDistinct(Context, None); }
DISubroutineType *getSubroutineType() {
- return DISubroutineType::getDistinct(Context, 0, getNode(nullptr));
+ return DISubroutineType::getDistinct(Context, 0, 0, getNode(nullptr));
}
DISubprogram *getSubprogram() {
return DISubprogram::getDistinct(Context, nullptr, "", "", nullptr, 0,
@@ -969,14 +969,14 @@ TEST_F(DITypeTest, setFlags) {
Metadata *TypesOps[] = {nullptr};
Metadata *Types = MDTuple::get(Context, TypesOps);
- DIType *D = DISubroutineType::getDistinct(Context, 0u, Types);
+ DIType *D = DISubroutineType::getDistinct(Context, 0u, 0, Types);
EXPECT_EQ(0u, D->getFlags());
D->setFlags(DINode::FlagRValueReference);
EXPECT_EQ(DINode::FlagRValueReference, D->getFlags());
D->setFlags(0u);
EXPECT_EQ(0u, D->getFlags());
- TempDIType T = DISubroutineType::getTemporary(Context, 0u, Types);
+ TempDIType T = DISubroutineType::getTemporary(Context, 0u, 0, Types);
EXPECT_EQ(0u, T->getFlags());
T->setFlags(DINode::FlagRValueReference);
EXPECT_EQ(DINode::FlagRValueReference, T->getFlags());
@@ -1254,14 +1254,29 @@ TEST_F(DISubroutineTypeTest, get) {
unsigned Flags = 1;
MDTuple *TypeArray = getTuple();
- auto *N = DISubroutineType::get(Context, Flags, TypeArray);
+ auto *N = DISubroutineType::get(Context, Flags, 0, TypeArray);
EXPECT_EQ(dwarf::DW_TAG_subroutine_type, N->getTag());
EXPECT_EQ(Flags, N->getFlags());
EXPECT_EQ(TypeArray, N->getTypeArray().get());
- EXPECT_EQ(N, DISubroutineType::get(Context, Flags, TypeArray));
-
- EXPECT_NE(N, DISubroutineType::get(Context, Flags + 1, TypeArray));
- EXPECT_NE(N, DISubroutineType::get(Context, Flags, getTuple()));
+ EXPECT_EQ(N, DISubroutineType::get(Context, Flags, 0, TypeArray));
+
+ EXPECT_NE(N, DISubroutineType::get(Context, Flags + 1, 0, TypeArray));
+ EXPECT_NE(N, DISubroutineType::get(Context, Flags, 0, getTuple()));
+
+ // Test the hashing of calling conventions.
+ auto *Fast = DISubroutineType::get(
+ Context, Flags, dwarf::DW_CC_BORLAND_msfastcall, TypeArray);
+ auto *Std = DISubroutineType::get(Context, Flags,
+ dwarf::DW_CC_BORLAND_stdcall, TypeArray);
+ EXPECT_EQ(Fast,
+ DISubroutineType::get(Context, Flags,
+ dwarf::DW_CC_BORLAND_msfastcall, TypeArray));
+ EXPECT_EQ(Std, DISubroutineType::get(
+ Context, Flags, dwarf::DW_CC_BORLAND_stdcall, TypeArray));
+
+ EXPECT_NE(N, Fast);
+ EXPECT_NE(N, Std);
+ EXPECT_NE(Fast, Std);
TempDISubroutineType Temp = N->clone();
EXPECT_EQ(N, MDNode::replaceWithUniqued(std::move(Temp)));