aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/BinaryFormat/Dwarf.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2018-02-06 23:45:59 +0000
committerAdrian Prantl <aprantl@apple.com>2018-02-06 23:45:59 +0000
commit8c59921ca3284ced1c358c4c86ec2c830db0bd70 (patch)
tree3147d5f8e22b4be9bea10fa0e9b295b19f4ca2a3 /llvm/lib/BinaryFormat/Dwarf.cpp
parent4c687f38c6369de9ad2fe734b99abd743fa60026 (diff)
downloadllvm-8c59921ca3284ced1c358c4c86ec2c830db0bd70.zip
llvm-8c59921ca3284ced1c358c4c86ec2c830db0bd70.tar.gz
llvm-8c59921ca3284ced1c358c4c86ec2c830db0bd70.tar.bz2
Add DWARF for discriminated unions
n Rust, an enum that carries data in the variants is, essentially, a discriminated union. Furthermore, the Rust compiler will perform space optimizations on such enums in some situations. Previously, DWARF for these constructs was emitted using a hack (a magic field name); but this approach stopped working when more space optimizations were added in https://github.com/rust-lang/rust/pull/45225. This patch changes LLVM to allow discriminated unions to be represented in DWARF. It adds createDiscriminatedUnionType and createDiscriminatedMemberType to DIBuilder and then arranges for this to be emitted using DWARF's DW_TAG_variant_part and DW_TAG_variant. Note that DWARF requires that a discriminated union be represented as a structure with a variant part. However, as Rust only needs to emit pure discriminated unions, this is what I chose to expose on DIBuilder. Patch by Tom Tromey! Differential Revision: https://reviews.llvm.org/D42082 llvm-svn: 324426
Diffstat (limited to 'llvm/lib/BinaryFormat/Dwarf.cpp')
-rw-r--r--llvm/lib/BinaryFormat/Dwarf.cpp12
1 files changed, 0 insertions, 12 deletions
diff --git a/llvm/lib/BinaryFormat/Dwarf.cpp b/llvm/lib/BinaryFormat/Dwarf.cpp
index 169e50e..bea3df8 100644
--- a/llvm/lib/BinaryFormat/Dwarf.cpp
+++ b/llvm/lib/BinaryFormat/Dwarf.cpp
@@ -393,16 +393,6 @@ StringRef llvm::dwarf::ArrayOrderString(unsigned Order) {
return StringRef();
}
-StringRef llvm::dwarf::DiscriminantString(unsigned Discriminant) {
- switch (Discriminant) {
- case DW_DSC_label:
- return "DW_DSC_label";
- case DW_DSC_range:
- return "DW_DSC_range";
- }
- return StringRef();
-}
-
StringRef llvm::dwarf::LNStandardString(unsigned Standard) {
switch (Standard) {
default:
@@ -563,8 +553,6 @@ StringRef llvm::dwarf::AttributeValueString(uint16_t Attr, unsigned Val) {
return InlineCodeString(Val);
case DW_AT_ordering:
return ArrayOrderString(Val);
- case DW_AT_discr_value:
- return DiscriminantString(Val);
}
return StringRef();