Don't use EmitAbsValue with symbol references.
authorRafael Espindola <rafael.espindola@gmail.com>
Thu, 20 Mar 2014 21:26:38 +0000 (21:26 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Thu, 20 Mar 2014 21:26:38 +0000 (21:26 +0000)
The function exists to force an expression to be absolute, but there it is not
possible to force a symbol reference since

a = b
.long a

means something else.

This is an alternative fix for pr9951 that uses an assert. It then deletes
the old pr9951 test that was testing nothing already.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204399 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/MCDwarf.cpp
lib/MC/MCStreamer.cpp
test/DebugInfo/X86/pr9951.ll [deleted file]

index c1e53d7bfe82e35785892057089ccef404cd41d1..79f1312fcaa3b39a6c9fbc7db09c4a4a567ea010 100644 (file)
@@ -619,7 +619,7 @@ static void EmitGenDwarfAranges(MCStreamer *MCOS,
     context.getGenDwarfSectionStartSym(), MCSymbolRefExpr::VK_None, context);
   const MCExpr *Size = MakeStartMinusEndExpr(*MCOS,
     *context.getGenDwarfSectionStartSym(), *SectionEndSym, 0);
-  MCOS->EmitAbsValue(Addr, AddrSize);
+  MCOS->EmitValue(Addr, AddrSize);
   MCOS->EmitAbsValue(Size, AddrSize);
 
   // And finally the pair of terminating zeros.
@@ -682,12 +682,12 @@ static void EmitGenDwarfInfo(MCStreamer *MCOS,
   // AT_low_pc, the first address of the default .text section.
   const MCExpr *Start = MCSymbolRefExpr::Create(
     context.getGenDwarfSectionStartSym(), MCSymbolRefExpr::VK_None, context);
-  MCOS->EmitAbsValue(Start, AddrSize);
+  MCOS->EmitValue(Start, AddrSize);
 
   // AT_high_pc, the last address of the default .text section.
   const MCExpr *End = MCSymbolRefExpr::Create(
     context.getGenDwarfSectionEndSym(), MCSymbolRefExpr::VK_None, context);
-  MCOS->EmitAbsValue(End, AddrSize);
+  MCOS->EmitValue(End, AddrSize);
 
   // AT_name, the name of the source file.  Reconstruct from the first directory
   // and file table entries.
@@ -756,7 +756,7 @@ static void EmitGenDwarfInfo(MCStreamer *MCOS,
     // AT_low_pc, start address of the label.
     const MCExpr *AT_low_pc = MCSymbolRefExpr::Create(Entry->getLabel(),
                                              MCSymbolRefExpr::VK_None, context);
-    MCOS->EmitAbsValue(AT_low_pc, AddrSize);
+    MCOS->EmitValue(AT_low_pc, AddrSize);
 
     // DW_AT_prototyped, a one byte flag value of 0 saying we have no prototype.
     MCOS->EmitIntValue(0, 1);
index 6638fdeb486601c44821d54dbfb60471dd233119..0558a58abfd129904005ff5b2d782d7e9de245e7 100644 (file)
@@ -73,8 +73,8 @@ const MCExpr *MCStreamer::BuildSymbolDiff(MCContext &Context,
 }
 
 const MCExpr *MCStreamer::ForceExpAbs(const MCExpr* Expr) {
-  if (Context.getAsmInfo()->hasAggressiveSymbolFolding() ||
-      isa<MCSymbolRefExpr>(Expr))
+  assert(!isa<MCSymbolRefExpr>(Expr));
+  if (Context.getAsmInfo()->hasAggressiveSymbolFolding())
     return Expr;
 
   MCSymbol *ABS = Context.CreateTempSymbol();
diff --git a/test/DebugInfo/X86/pr9951.ll b/test/DebugInfo/X86/pr9951.ll
deleted file mode 100644 (file)
index d933beb..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-; RUN: llc -mtriple x86_64-apple-darwin10.0.0 -disable-cfi %s -o - | FileCheck %s
-
-define i32 @f() nounwind {
-entry:
-  ret i32 42
-}
-
-!llvm.dbg.cu = !{!2}
-!llvm.module.flags = !{!9}
-!6 = metadata !{metadata !0}
-
-!0 = metadata !{i32 786478, metadata !7, metadata !1, metadata !"f", metadata !"f", metadata !"", i32 1, metadata !3, i1 false, i1 true, i32 0, i32 0, null, i32 256, i1 false, i32 ()* @f, null, null, null, i32 1} ; [ DW_TAG_subprogram ] [line 1] [def] [f]
-!1 = metadata !{i32 786473, metadata !7} ; [ DW_TAG_file_type ]
-!2 = metadata !{i32 786449, metadata !7, i32 12, metadata !"clang version 3.0 ()", i1 true, metadata !"", i32 0, metadata !8, metadata !8, metadata !6, null, null, metadata !""} ; [ DW_TAG_compile_unit ]
-!3 = metadata !{i32 786453, metadata !7, metadata !1, metadata !"", i32 0, i64 0, i64 0, i32 0, i32 0, null, metadata !4, i32 0, null, null, null} ; [ DW_TAG_subroutine_type ] [line 0, size 0, align 0, offset 0] [from ]
-!4 = metadata !{metadata !5}
-!5 = metadata !{i32 786468, null, metadata !2, metadata !"int", i32 0, i64 32, i64 32, i64 0, i32 0, i32 5} ; [ DW_TAG_base_type ]
-!7 = metadata !{metadata !"/home/espindola/llvm/test.c", metadata !"/home/espindola/llvm/build-rust2"}
-!8 = metadata !{i32 0}
-
-; CHECK:      _f:                                     ## @f
-; CHECK-NEXT: Ltmp0:
-
-; CHECK:      Ltmp9 = (Ltmp3-Ltmp2)-0
-; CHECK-NEXT:  .long   Ltmp9
-; CHECK-NEXT:  .quad   Ltmp0
-!9 = metadata !{i32 1, metadata !"Debug Info Version", i32 1}