[llvm] 46788a2 - [X86][AsmPrinter] PrintSymbolOperand: prefer to lower ELF MO_GlobalAddress to .Lfoo$local
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Feb 15 13:45:55 PST 2020
Author: Fangrui Song
Date: 2020-02-15T13:45:29-08:00
New Revision: 46788a21f9152be3950e57dc526454655682bdd4
URL: https://github.com/llvm/llvm-project/commit/46788a21f9152be3950e57dc526454655682bdd4
DIFF: https://github.com/llvm/llvm-project/commit/46788a21f9152be3950e57dc526454655682bdd4.diff
LOG: [X86][AsmPrinter] PrintSymbolOperand: prefer to lower ELF MO_GlobalAddress to .Lfoo$local
Added:
llvm/test/CodeGen/X86/semantic-interposition-asm.ll
Modified:
llvm/lib/Target/X86/X86AsmPrinter.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/X86/X86AsmPrinter.cpp b/llvm/lib/Target/X86/X86AsmPrinter.cpp
index eeb3d9d2ab0e..f526e9f07951 100644
--- a/llvm/lib/Target/X86/X86AsmPrinter.cpp
+++ b/llvm/lib/Target/X86/X86AsmPrinter.cpp
@@ -124,7 +124,7 @@ void X86AsmPrinter::PrintSymbolOperand(const MachineOperand &MO,
MO.getTargetFlags() == X86II::MO_DARWIN_NONLAZY_PIC_BASE)
GVSym = getSymbolWithGlobalValueBase(GV, "$non_lazy_ptr");
else
- GVSym = getSymbol(GV);
+ GVSym = getSymbolPreferLocal(*GV);
// Handle dllimport linkage.
if (MO.getTargetFlags() == X86II::MO_DLLIMPORT)
diff --git a/llvm/test/CodeGen/X86/semantic-interposition-asm.ll b/llvm/test/CodeGen/X86/semantic-interposition-asm.ll
new file mode 100644
index 000000000000..a9c1895256eb
--- /dev/null
+++ b/llvm/test/CodeGen/X86/semantic-interposition-asm.ll
@@ -0,0 +1,21 @@
+; RUN: llc -mtriple=x86_64 -relocation-model=pic < %s | FileCheck %s
+
+;; Test that we use the local alias for dso_local globals in inline assembly.
+
+ at mxcsr0 = dso_local global i32 0
+ at mxcsr1 = dso_preemptable global i32 1
+
+define <2 x double> @foo(<2 x double> %a, <2 x double> %b) {
+; CHECK-LABEL: foo:
+; CHECK: movq mxcsr1 at GOTPCREL(%rip), %rax
+; CHECK: #APP
+; CHECK-NEXT: ldmxcsr .Lmxcsr0$local(%rip)
+; CHECK-NEXT: addpd %xmm1, %xmm0
+; CHECK-NEXT: ldmxcsr (%rax)
+; CHECK-NEXT: #NO_APP
+entry:
+ %0 = call <2 x double> asm sideeffect "ldmxcsr $2; addpd $1, $0; ldmxcsr $3",
+ "=x,x,*m,*m,0,~{dirflag},~{fpsr},~{flags}"(
+ <2 x double> %b, i32* nonnull @mxcsr0, i32* nonnull @mxcsr1, <2 x double> %a)
+ ret <2 x double> %0
+}
More information about the llvm-commits
mailing list