aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
diff options
context:
space:
mode:
authorAmy Huang <akhuang@google.com>2020-11-24 11:26:14 -0800
committerAmy Huang <akhuang@google.com>2020-11-25 16:13:32 -0800
commit1363dfaf3105470e1724ed1f17c6d9c0713f442e (patch)
tree61ea5dbbfdf2fd282f8ec945fe3d9f0a6f13d793 /llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
parentb534beabeed3ba1777cd0ff9ce552d077e496726 (diff)
downloadllvm-1363dfaf3105470e1724ed1f17c6d9c0713f442e.zip
llvm-1363dfaf3105470e1724ed1f17c6d9c0713f442e.tar.gz
llvm-1363dfaf3105470e1724ed1f17c6d9c0713f442e.tar.bz2
[CodeView] Avoid emitting empty debug globals subsection.
In https://reviews.llvm.org/D89072 I added static const data members to the debug subsection for globals. It skipped emitting an S_CONSTANT if it didn't have a value, which meant the subsection could be empty. This patch fixes the empty subsection issue. Differential Revision: https://reviews.llvm.org/D92049
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 4d618cf..b15e750 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -2150,10 +2150,13 @@ void CodeViewDebug::collectMemberInfo(ClassInfo &Info,
if (!DDTy->getName().empty()) {
Info.Members.push_back({DDTy, 0});
- // Collect static const data members.
+ // Collect static const data members with values.
if ((DDTy->getFlags() & DINode::FlagStaticMember) ==
- DINode::FlagStaticMember)
- StaticConstMembers.push_back(DDTy);
+ DINode::FlagStaticMember) {
+ if (DDTy->getConstant() && (isa<ConstantInt>(DDTy->getConstant()) ||
+ isa<ConstantFP>(DDTy->getConstant())))
+ StaticConstMembers.push_back(DDTy);
+ }
return;
}
@@ -3134,7 +3137,7 @@ void CodeViewDebug::emitStaticConstMemberList() {
dyn_cast_or_null<ConstantFP>(DTy->getConstant()))
Value = APSInt(CFP->getValueAPF().bitcastToAPInt(), true);
else
- continue;
+ llvm_unreachable("cannot emit a constant without a value");
std::string QualifiedName = getFullyQualifiedName(Scope, DTy->getName());