[llvm] r236123 - [X86] Avoid mangling frameescape labels
Reid Kleckner
reid at kleckner.net
Wed Apr 29 09:46:01 PDT 2015
Author: rnk
Date: Wed Apr 29 11:46:01 2015
New Revision: 236123
URL: http://llvm.org/viewvc/llvm-project?rev=236123&view=rev
Log:
[X86] Avoid mangling frameescape labels
x86 Windows uses the '_' prefix for all global symbols, and this was
mistakenly being applied to frameescape labels, which are not externally
visible global symbols. They use the private global prefix 'L'.
The *right* way to fix this is probably to stop masquerading this label
as an ExternalSymbol and create a new SDNode type. These labels are not
"external", and we know they will be resolved by assembly time. Having a
custom SDNode type would allow us to do better X86 address mode
matching, so it's probably worth doing eventually.
Modified:
llvm/trunk/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
llvm/trunk/lib/Target/X86/X86MCInstLower.cpp
llvm/trunk/test/CodeGen/X86/frameescape.ll
Modified: llvm/trunk/lib/Target/X86/MCTargetDesc/X86BaseInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/MCTargetDesc/X86BaseInfo.h?rev=236123&r1=236122&r2=236123&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/MCTargetDesc/X86BaseInfo.h (original)
+++ llvm/trunk/lib/Target/X86/MCTargetDesc/X86BaseInfo.h Wed Apr 29 11:46:01 2015
@@ -213,7 +213,11 @@ namespace X86II {
/// the offset from beginning of section.
///
/// This is the TLS offset for the COFF/Windows TLS mechanism.
- MO_SECREL
+ MO_SECREL,
+
+ /// MO_NOPREFIX - On a symbol operand this indicates that the symbol should
+ /// not be mangled with a prefix.
+ MO_NOPREFIX,
};
enum : uint64_t {
Modified: llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp?rev=236123&r1=236122&r2=236123&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelDAGToDAG.cpp Wed Apr 29 11:46:01 2015
@@ -1009,7 +1009,9 @@ bool X86DAGToDAGISel::MatchAddressRecurs
if (!AM.hasSymbolicDisplacement())
if (const auto *ESNode = dyn_cast<ExternalSymbolSDNode>(N.getOperand(0)))
if (ESNode->getOpcode() == ISD::TargetExternalSymbol) {
+ // Use the symbol and don't prefix it.
AM.ES = ESNode->getSymbol();
+ AM.SymbolFlags = X86II::MO_NOPREFIX;
return false;
}
break;
Modified: llvm/trunk/lib/Target/X86/X86MCInstLower.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCInstLower.cpp?rev=236123&r1=236122&r2=236123&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86MCInstLower.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86MCInstLower.cpp Wed Apr 29 11:46:01 2015
@@ -154,7 +154,10 @@ GetSymbolFromOperand(const MachineOperan
const GlobalValue *GV = MO.getGlobal();
AsmPrinter.getNameWithPrefix(Name, GV);
} else if (MO.isSymbol()) {
- getMang()->getNameWithPrefix(Name, MO.getSymbolName());
+ if (MO.getTargetFlags() == X86II::MO_NOPREFIX)
+ Name += MO.getSymbolName();
+ else
+ getMang()->getNameWithPrefix(Name, MO.getSymbolName());
} else if (MO.isMBB()) {
Name += MO.getMBB()->getSymbol()->getName();
}
@@ -231,6 +234,7 @@ MCOperand X86MCInstLower::LowerSymbolOpe
case X86II::MO_DARWIN_NONLAZY:
case X86II::MO_DLLIMPORT:
case X86II::MO_DARWIN_STUB:
+ case X86II::MO_NOPREFIX:
break;
case X86II::MO_TLVP: RefKind = MCSymbolRefExpr::VK_TLVP; break;
Modified: llvm/trunk/test/CodeGen/X86/frameescape.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/frameescape.ll?rev=236123&r1=236122&r2=236123&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/frameescape.ll (original)
+++ llvm/trunk/test/CodeGen/X86/frameescape.ll Wed Apr 29 11:46:01 2015
@@ -37,15 +37,15 @@ define void @print_framealloc_from_fp(i8
; X86: pushl %esi
; X86: subl $8, %esp
; X86: movl 16(%esp), %esi
-; X86: movl _Lalloc_func$frame_escape_0(%esi), %eax
+; X86: movl Lalloc_func$frame_escape_0(%esi), %eax
; X86: movl %eax, 4(%esp)
; X86: movl $_str, (%esp)
; X86: calll _printf
-; X86: movl _Lalloc_func$frame_escape_1(%esi), %eax
+; X86: movl Lalloc_func$frame_escape_1(%esi), %eax
; X86: movl %eax, 4(%esp)
; X86: movl $_str, (%esp)
; X86: calll _printf
-; X86: movl $42, _Lalloc_func$frame_escape_1(%esi)
+; X86: movl $42, Lalloc_func$frame_escape_1(%esi)
; X86: addl $8, %esp
; X86: popl %esi
; X86: retl
More information about the llvm-commits
mailing list