File tree Expand file tree Collapse file tree 7 files changed +32
-35
lines changed Expand file tree Collapse file tree 7 files changed +32
-35
lines changed Original file line number Diff line number Diff line change @@ -123,12 +123,6 @@ class MachineModuleInfo {
123
123
// / point. This is used to emit an undefined reference to _fltused.
124
124
bool UsesMSVCFloatingPoint;
125
125
126
- // / True if the module calls the __morestack function indirectly, as is
127
- // / required under the large code model on x86. This is used to emit
128
- // / a definition of a symbol, __morestack_addr, containing the address. See
129
- // / comments in lib/Target/X86/X86FrameLowering.cpp for more details.
130
- bool UsesMorestackAddr;
131
-
132
126
// / Maps IR Functions to their corresponding MachineFunctions.
133
127
DenseMap<const Function*, std::unique_ptr<MachineFunction>> MachineFunctions;
134
128
// / Next unique number available for a MachineFunction.
@@ -195,14 +189,6 @@ class MachineModuleInfo {
195
189
196
190
void setUsesMSVCFloatingPoint (bool b) { UsesMSVCFloatingPoint = b; }
197
191
198
- bool usesMorestackAddr () const {
199
- return UsesMorestackAddr;
200
- }
201
-
202
- void setUsesMorestackAddr (bool b) {
203
- UsesMorestackAddr = b;
204
- }
205
-
206
192
// / Return the symbol to be used for the specified basic block when its
207
193
// / address is taken. This cannot be its normal LBB label because the block
208
194
// / may be accessed outside its containing function.
Original file line number Diff line number Diff line change @@ -1904,23 +1904,6 @@ bool AsmPrinter::doFinalization(Module &M) {
1904
1904
// Emit bytes for llvm.commandline metadata.
1905
1905
emitModuleCommandLines (M);
1906
1906
1907
- // Emit __morestack address if needed for indirect calls.
1908
- if (MMI->usesMorestackAddr ()) {
1909
- Align Alignment (1 );
1910
- MCSection *ReadOnlySection = getObjFileLowering ().getSectionForConstant (
1911
- getDataLayout (), SectionKind::getReadOnly (),
1912
- /* C=*/ nullptr , Alignment);
1913
- OutStreamer->SwitchSection (ReadOnlySection);
1914
-
1915
- MCSymbol *AddrSymbol =
1916
- OutContext.getOrCreateSymbol (StringRef (" __morestack_addr" ));
1917
- OutStreamer->emitLabel (AddrSymbol);
1918
-
1919
- unsigned PtrSize = MAI->getCodePointerSize ();
1920
- OutStreamer->emitSymbolValue (GetExternalSymbolSymbol (" __morestack" ),
1921
- PtrSize);
1922
- }
1923
-
1924
1907
// Emit .note.GNU-split-stack and .note.GNU-no-split-stack sections if
1925
1908
// split-stack is used.
1926
1909
if (TM.getTargetTriple ().isOSBinFormatELF () && HasSplitStack) {
Original file line number Diff line number Diff line change @@ -202,7 +202,7 @@ void MachineModuleInfo::initialize() {
202
202
ObjFileMMI = nullptr ;
203
203
CurCallSite = 0 ;
204
204
NextFnNum = 0 ;
205
- UsesMSVCFloatingPoint = UsesMorestackAddr = false ;
205
+ UsesMSVCFloatingPoint = false ;
206
206
AddrLabelSymbols = nullptr ;
207
207
DbgInfoAvailable = false ;
208
208
}
@@ -230,7 +230,6 @@ MachineModuleInfo::MachineModuleInfo(MachineModuleInfo &&MMI)
230
230
ObjFileMMI = MMI.ObjFileMMI ;
231
231
CurCallSite = MMI.CurCallSite ;
232
232
UsesMSVCFloatingPoint = MMI.UsesMSVCFloatingPoint ;
233
- UsesMorestackAddr = MMI.UsesMorestackAddr ;
234
233
AddrLabelSymbols = MMI.AddrLabelSymbols ;
235
234
ExternalContext = MMI.ExternalContext ;
236
235
TheModule = MMI.TheModule ;
Original file line number Diff line number Diff line change 29
29
#include " llvm/IR/Mangler.h"
30
30
#include " llvm/IR/Module.h"
31
31
#include " llvm/IR/Type.h"
32
+ #include " llvm/MC/MCAsmInfo.h"
32
33
#include " llvm/MC/MCCodeEmitter.h"
33
34
#include " llvm/MC/MCContext.h"
34
35
#include " llvm/MC/MCExpr.h"
@@ -803,6 +804,22 @@ void X86AsmPrinter::emitEndOfAsmFile(Module &M) {
803
804
emitStackMaps (SM);
804
805
FM.serializeToFaultMapSection ();
805
806
}
807
+
808
+ // Emit __morestack address if needed for indirect calls.
809
+ if (TT.getArch () == Triple::x86_64 && TM.getCodeModel () == CodeModel::Large) {
810
+ if (MCSymbol *AddrSymbol = OutContext.lookupSymbol (" __morestack_addr" )) {
811
+ Align Alignment (1 );
812
+ MCSection *ReadOnlySection = getObjFileLowering ().getSectionForConstant (
813
+ getDataLayout (), SectionKind::getReadOnly (),
814
+ /* C=*/ nullptr , Alignment);
815
+ OutStreamer->SwitchSection (ReadOnlySection);
816
+ OutStreamer->emitLabel (AddrSymbol);
817
+
818
+ unsigned PtrSize = MAI->getCodePointerSize ();
819
+ OutStreamer->emitSymbolValue (GetExternalSymbolSymbol (" __morestack" ),
820
+ PtrSize);
821
+ }
822
+ }
806
823
}
807
824
808
825
// ===----------------------------------------------------------------------===//
Original file line number Diff line number Diff line change @@ -3128,7 +3128,6 @@ void X86FrameLowering::adjustForSegmentedStacks(
3128
3128
.addReg (0 )
3129
3129
.addExternalSymbol (" __morestack_addr" )
3130
3130
.addReg (0 );
3131
- MF.getMMI ().setUsesMorestackAddr (true );
3132
3131
} else {
3133
3132
if (Is64Bit)
3134
3133
BuildMI (allocMBB, DL, TII.get (X86::CALL64pcrel32))
Original file line number Diff line number Diff line change
1
+ ; RUN: llc -mcpu=generic -mtriple=x86_64-linux -code-model=large < %s | FileCheck %s
2
+
3
+ ; Check what happens if we have an existing declaration of __morestack_addr
4
+
5
+ ; CHECK: .section ".note.GNU-stack","",@progbits
6
+ ; CHECK-NEXT: .section .rodata,"a",@progbits
7
+ ; CHECK-NEXT: __morestack_addr:
8
+ ; CHECK-NEXT: .quad __morestack
9
+
10
+ declare void @__morestack_addr ()
Original file line number Diff line number Diff line change @@ -2123,7 +2123,10 @@ define i32 @test_nested_unused(i32 * nest %unused) #0 {
2123
2123
2124
2124
attributes #0 = { "split-stack" }
2125
2125
2126
- ; X64-Linux-Large: .rodata
2126
+ ; X64-Linux-Large: .section ".note.GNU-split-stack","",@progbits
2127
+ ; X64-Linux-Large-NEXT: .section ".note.GNU-no-split-stack","",@progbits
2128
+ ; X64-Linux-Large-NEXT: .section ".note.GNU-stack","",@progbits
2129
+ ; X64-Linux-Large-NEXT: .rodata
2127
2130
; X64-Linux-Large-NEXT: __morestack_addr:
2128
2131
; X64-Linux-Large-NEXT: .quad __morestack
2129
2132
You can’t perform that action at this time.
0 commit comments