[llvm-commits] [llvm] r128430 - in /llvm/trunk: include/llvm/MC/MCContext.h lib/MC/MCContext.cpp test/MC/MachO/temp-labels.s tools/llvm-mc/llvm-mc.cpp
Daniel Dunbar
daniel at zuster.org
Mon Mar 28 15:49:15 PDT 2011
Author: ddunbar
Date: Mon Mar 28 17:49:15 2011
New Revision: 128430
URL: http://llvm.org/viewvc/llvm-project?rev=128430&view=rev
Log:
MC: Add support for disabling "temporary label" behavior. Useful for debugging
on Darwin.
Added:
llvm/trunk/test/MC/MachO/temp-labels.s
Modified:
llvm/trunk/include/llvm/MC/MCContext.h
llvm/trunk/lib/MC/MCContext.cpp
llvm/trunk/tools/llvm-mc/llvm-mc.cpp
Modified: llvm/trunk/include/llvm/MC/MCContext.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCContext.h?rev=128430&r1=128429&r2=128430&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCContext.h (original)
+++ llvm/trunk/include/llvm/MC/MCContext.h Mon Mar 28 17:49:15 2011
@@ -84,6 +84,11 @@
MCDwarfLoc CurrentDwarfLoc;
bool DwarfLocSeen;
+ /// Honor temporary labels, this is useful for debugging semantic
+ /// differences between temporary and non-temporary labels (primarily on
+ /// Darwin).
+ bool AllowTemporaryLabels;
+
/// The dwarf line information from the .loc directives for the sections
/// with assembled machine instructions have after seeing .loc directives.
DenseMap<const MCSection *, MCLineSection *> MCLineSections;
@@ -109,6 +114,8 @@
const TargetAsmInfo &getTargetAsmInfo() const { return *TAI; }
+ void setAllowTemporaryLabels(bool Value) { AllowTemporaryLabels = Value; }
+
/// @name Symbol Management
/// @{
Modified: llvm/trunk/lib/MC/MCContext.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCContext.cpp?rev=128430&r1=128429&r2=128430&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCContext.cpp (original)
+++ llvm/trunk/lib/MC/MCContext.cpp Mon Mar 28 17:49:15 2011
@@ -28,7 +28,8 @@
MCContext::MCContext(const MCAsmInfo &mai, const TargetAsmInfo *tai) :
MAI(mai), TAI(tai), NextUniqueID(0),
- CurrentDwarfLoc(0,0,0,DWARF2_FLAG_IS_STMT,0,0) {
+ CurrentDwarfLoc(0,0,0,DWARF2_FLAG_IS_STMT,0,0),
+ AllowTemporaryLabels(true) {
MachOUniquingMap = 0;
ELFUniquingMap = 0;
COFFUniquingMap = 0;
@@ -76,8 +77,10 @@
}
MCSymbol *MCContext::CreateSymbol(StringRef Name) {
- // Determine whether this is an assembler temporary or normal label.
- bool isTemporary = Name.startswith(MAI.getPrivateGlobalPrefix());
+ // Determine whether this is an assembler temporary or normal label, if used.
+ bool isTemporary = false;
+ if (AllowTemporaryLabels)
+ isTemporary = Name.startswith(MAI.getPrivateGlobalPrefix());
StringMapEntry<bool> *NameEntry = &UsedNames.GetOrCreateValue(Name);
if (NameEntry->getValue()) {
Added: llvm/trunk/test/MC/MachO/temp-labels.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/MachO/temp-labels.s?rev=128430&view=auto
==============================================================================
--- llvm/trunk/test/MC/MachO/temp-labels.s (added)
+++ llvm/trunk/test/MC/MachO/temp-labels.s Mon Mar 28 17:49:15 2011
@@ -0,0 +1,33 @@
+// RUN: llvm-mc -triple x86_64-apple-darwin10 %s -filetype=obj -L -o - | macho-dump --dump-section-data | FileCheck %s
+
+// CHECK: # Load Command 1
+// CHECK: (('command', 2)
+// CHECK: ('size', 24)
+// CHECK: ('symoff', 296)
+// CHECK: ('nsyms', 2)
+// CHECK: ('stroff', 328)
+// CHECK: ('strsize', 8)
+// CHECK: ('_string_data', '\x00_f0\x00L0\x00')
+// CHECK: ('_symbols', [
+// CHECK: # Symbol 0
+// CHECK: (('n_strx', 1)
+// CHECK: ('n_type', 0xe)
+// CHECK: ('n_sect', 1)
+// CHECK: ('n_desc', 0)
+// CHECK: ('n_value', 0)
+// CHECK: ('_string', '_f0')
+// CHECK: ),
+// CHECK: # Symbol 1
+// CHECK: (('n_strx', 5)
+// CHECK: ('n_type', 0xe)
+// CHECK: ('n_sect', 1)
+// CHECK: ('n_desc', 0)
+// CHECK: ('n_value', 4)
+// CHECK: ('_string', 'L0')
+// CHECK: ),
+// CHECK: ])
+// CHECK: ),
+_f0:
+ .long 0
+L0:
+ .long 0
Modified: llvm/trunk/tools/llvm-mc/llvm-mc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/llvm-mc.cpp?rev=128430&r1=128429&r2=128430&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original)
+++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Mon Mar 28 17:49:15 2011
@@ -113,6 +113,10 @@
NoInitialTextSection("n", cl::desc(
"Don't assume assembly file starts in the text section"));
+static cl::opt<bool>
+SaveTempLabels("L", cl::desc(
+ "Don't discard temporary labels"));
+
enum ActionType {
AC_AsLex,
AC_Assemble,
@@ -327,6 +331,8 @@
const TargetAsmInfo *tai = new TargetAsmInfo(*TM);
MCContext Ctx(*MAI, tai);
+ if (SaveTempLabels)
+ Ctx.setAllowTemporaryLabels(false);
OwningPtr<tool_output_file> Out(GetOutputStream());
if (!Out)
More information about the llvm-commits
mailing list