Revert "Reverting r193835 due to weirdness with Go..."
[oota-llvm.git] / lib / CodeGen / AsmPrinter / DwarfUnit.cpp
index 93df498377c349833ba322f2f37c17ab8057cda5..0e3db3c50859c1fed31e563bd4a74dad71f203e4 100644 (file)
@@ -1920,10 +1920,14 @@ void DwarfUnit::constructMemberDIE(DIE &Buffer, DIDerivedType DT) {
       // This is not a bitfield.
       OffsetInBytes = DT.getOffsetInBits() >> 3;
 
-    DIEBlock *MemLocationDie = new (DIEValueAllocator) DIEBlock();
-    addUInt(MemLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
-    addUInt(MemLocationDie, dwarf::DW_FORM_udata, OffsetInBytes);
-    addBlock(MemberDie, dwarf::DW_AT_data_member_location, MemLocationDie);
+    if (DD->getDwarfVersion() <= 2) {
+      DIEBlock *MemLocationDie = new (DIEValueAllocator) DIEBlock();
+      addUInt(MemLocationDie, dwarf::DW_FORM_data1, dwarf::DW_OP_plus_uconst);
+      addUInt(MemLocationDie, dwarf::DW_FORM_udata, OffsetInBytes);
+      addBlock(MemberDie, dwarf::DW_AT_data_member_location, MemLocationDie);
+    } else
+      addUInt(MemberDie, dwarf::DW_AT_data_member_location, None,
+              OffsetInBytes);
   }
 
   if (DT.isProtected())