summaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 9b1965c7d6c9..f111b4aea06f 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -1260,13 +1260,6 @@ void DwarfDebug::finalizeModuleInfo() {
finishEntityDefinitions();
- // Include the DWO file name in the hash if there's more than one CU.
- // This handles ThinLTO's situation where imported CUs may very easily be
- // duplicate with the same CU partially imported into another ThinLTO unit.
- StringRef DWOName;
- if (CUMap.size() > 1)
- DWOName = Asm->TM.Options.MCOptions.SplitDwarfFile;
-
bool HasEmittedSplitCU = false;
// Handle anything that needs to be done on a per-unit basis after
@@ -1295,11 +1288,13 @@ void DwarfDebug::finalizeModuleInfo() {
? dwarf::DW_AT_dwo_name
: dwarf::DW_AT_GNU_dwo_name;
finishUnitAttributes(TheCU.getCUNode(), TheCU);
- TheCU.addString(TheCU.getUnitDie(), attrDWOName,
- Asm->TM.Options.MCOptions.SplitDwarfFile);
- SkCU->addString(SkCU->getUnitDie(), attrDWOName,
- Asm->TM.Options.MCOptions.SplitDwarfFile);
- // Emit a unique identifier for this CU.
+ StringRef DWOName = Asm->TM.Options.MCOptions.SplitDwarfFile;
+ TheCU.addString(TheCU.getUnitDie(), attrDWOName, DWOName);
+ SkCU->addString(SkCU->getUnitDie(), attrDWOName, DWOName);
+ // Emit a unique identifier for this CU. Include the DWO file name in the
+ // hash to avoid the case where two (almost) empty compile units have the
+ // same contents. This can happen if link-time optimization removes nearly
+ // all (unused) code from a CU.
uint64_t ID =
DIEHash(Asm, &TheCU).computeCUSignature(DWOName, TheCU.getUnitDie());
if (getDwarfVersion() >= 5) {