mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-08-23 17:29:19 +00:00
[Stackmaps] Record the stack size of each function that contains a stackmap/patchpoint intrinsic.
Reviewed by Andy git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@200444 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
efdbec8b0a
commit
2baaf25bf5
@ -314,6 +314,11 @@ format of this section follows:
|
|||||||
.. code-block:: none
|
.. code-block:: none
|
||||||
|
|
||||||
uint32 : Reserved (header)
|
uint32 : Reserved (header)
|
||||||
|
uint32 : NumFunctions
|
||||||
|
StkSizeRecord[NumFunctions] {
|
||||||
|
uint32 : Function Offset
|
||||||
|
uint32 : Stack Size
|
||||||
|
}
|
||||||
uint32 : NumConstants
|
uint32 : NumConstants
|
||||||
Constants[NumConstants] {
|
Constants[NumConstants] {
|
||||||
uint64 : LargeConstant
|
uint64 : LargeConstant
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#ifndef LLVM_STACKMAPS
|
#ifndef LLVM_STACKMAPS
|
||||||
#define LLVM_STACKMAPS
|
#define LLVM_STACKMAPS
|
||||||
|
|
||||||
|
#include "llvm/ADT/MapVector.h"
|
||||||
#include "llvm/ADT/SmallVector.h"
|
#include "llvm/ADT/SmallVector.h"
|
||||||
#include "llvm/CodeGen/MachineInstr.h"
|
#include "llvm/CodeGen/MachineInstr.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -132,6 +133,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
typedef SmallVector<Location, 8> LocationVec;
|
typedef SmallVector<Location, 8> LocationVec;
|
||||||
typedef SmallVector<LiveOutReg, 8> LiveOutVec;
|
typedef SmallVector<LiveOutReg, 8> LiveOutVec;
|
||||||
|
typedef MapVector<const MCSymbol *, uint32_t> FnStackSizeMap;
|
||||||
|
|
||||||
struct CallsiteInfo {
|
struct CallsiteInfo {
|
||||||
const MCExpr *CSOffsetExpr;
|
const MCExpr *CSOffsetExpr;
|
||||||
@ -170,6 +172,7 @@ private:
|
|||||||
AsmPrinter &AP;
|
AsmPrinter &AP;
|
||||||
CallsiteInfoList CSInfos;
|
CallsiteInfoList CSInfos;
|
||||||
ConstantPool ConstPool;
|
ConstantPool ConstPool;
|
||||||
|
FnStackSizeMap FnStackSize;
|
||||||
|
|
||||||
MachineInstr::const_mop_iterator
|
MachineInstr::const_mop_iterator
|
||||||
parseOperand(MachineInstr::const_mop_iterator MOI,
|
parseOperand(MachineInstr::const_mop_iterator MOI,
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
#include "llvm/CodeGen/StackMaps.h"
|
#include "llvm/CodeGen/StackMaps.h"
|
||||||
#include "llvm/CodeGen/AsmPrinter.h"
|
#include "llvm/CodeGen/AsmPrinter.h"
|
||||||
|
#include "llvm/CodeGen/MachineFunction.h"
|
||||||
|
#include "llvm/CodeGen/MachineFrameInfo.h"
|
||||||
#include "llvm/CodeGen/MachineInstr.h"
|
#include "llvm/CodeGen/MachineInstr.h"
|
||||||
#include "llvm/IR/DataLayout.h"
|
#include "llvm/IR/DataLayout.h"
|
||||||
#include "llvm/MC/MCContext.h"
|
#include "llvm/MC/MCContext.h"
|
||||||
@ -216,12 +218,19 @@ void StackMaps::recordStackMapOpers(const MachineInstr &MI, uint64_t ID,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create an expression to calculate the offset of the callsite from function
|
||||||
|
// entry.
|
||||||
const MCExpr *CSOffsetExpr = MCBinaryExpr::CreateSub(
|
const MCExpr *CSOffsetExpr = MCBinaryExpr::CreateSub(
|
||||||
MCSymbolRefExpr::Create(MILabel, OutContext),
|
MCSymbolRefExpr::Create(MILabel, OutContext),
|
||||||
MCSymbolRefExpr::Create(AP.CurrentFnSym, OutContext),
|
MCSymbolRefExpr::Create(AP.CurrentFnSym, OutContext),
|
||||||
OutContext);
|
OutContext);
|
||||||
|
|
||||||
CSInfos.push_back(CallsiteInfo(CSOffsetExpr, ID, Locations, LiveOuts));
|
CSInfos.push_back(CallsiteInfo(CSOffsetExpr, ID, Locations, LiveOuts));
|
||||||
|
|
||||||
|
// Record the stack size of the current function.
|
||||||
|
const MachineFrameInfo *MFI = AP.MF->getFrameInfo();
|
||||||
|
FnStackSize[AP.CurrentFnSym] =
|
||||||
|
MFI->hasVarSizedObjects() ? ~0U : MFI->getStackSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void StackMaps::recordStackMap(const MachineInstr &MI) {
|
void StackMaps::recordStackMap(const MachineInstr &MI) {
|
||||||
@ -258,6 +267,11 @@ void StackMaps::recordPatchPoint(const MachineInstr &MI) {
|
|||||||
/// serializeToStackMapSection conceptually populates the following fields:
|
/// serializeToStackMapSection conceptually populates the following fields:
|
||||||
///
|
///
|
||||||
/// uint32 : Reserved (header)
|
/// uint32 : Reserved (header)
|
||||||
|
/// uint32 : NumFunctions
|
||||||
|
/// StkSizeRecord[NumFunctions] {
|
||||||
|
/// uint32 : Function Offset
|
||||||
|
/// uint32 : Stack Size
|
||||||
|
/// }
|
||||||
/// uint32 : NumConstants
|
/// uint32 : NumConstants
|
||||||
/// int64 : Constants[NumConstants]
|
/// int64 : Constants[NumConstants]
|
||||||
/// uint32 : NumRecords
|
/// uint32 : NumRecords
|
||||||
@ -313,6 +327,16 @@ void StackMaps::serializeToStackMapSection() {
|
|||||||
// Header.
|
// Header.
|
||||||
AP.OutStreamer.EmitIntValue(0, 4);
|
AP.OutStreamer.EmitIntValue(0, 4);
|
||||||
|
|
||||||
|
// Num functions.
|
||||||
|
AP.OutStreamer.EmitIntValue(FnStackSize.size(), 4);
|
||||||
|
|
||||||
|
// Stack size entries.
|
||||||
|
for (FnStackSizeMap::iterator I = FnStackSize.begin(), E = FnStackSize.end();
|
||||||
|
I != E; ++I) {
|
||||||
|
AP.EmitLabelReference(I->first, 4, true);
|
||||||
|
AP.OutStreamer.EmitIntValue(I->second, 4);
|
||||||
|
}
|
||||||
|
|
||||||
// Num constants.
|
// Num constants.
|
||||||
AP.OutStreamer.EmitIntValue(ConstPool.getNumConstants(), 4);
|
AP.OutStreamer.EmitIntValue(ConstPool.getNumConstants(), 4);
|
||||||
|
|
||||||
|
@ -1,13 +1,31 @@
|
|||||||
; RUN: llc < %s -mtriple=x86_64-apple-darwin -disable-fp-elim | FileCheck %s
|
; RUN: llc < %s -mtriple=x86_64-apple-darwin -disable-fp-elim | FileCheck %s
|
||||||
; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=corei7 | FileCheck --check-prefix=SSE %s
|
; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=corei7 -disable-fp-elim | FileCheck --check-prefix=SSE %s
|
||||||
; RUN: llc < %s -march=x86-64 -mcpu=corei7-avx | FileCheck --check-prefix=AVX %s
|
; RUN: llc < %s -mtriple=x86_64-apple-darwin -mcpu=corei7-avx -disable-fp-elim | FileCheck --check-prefix=AVX %s
|
||||||
|
|
||||||
|
|
||||||
; Stackmap Header: no constants - 6 callsites
|
; Stackmap Header: no constants - 6 callsites
|
||||||
; CHECK-LABEL: .section __LLVM_STACKMAPS,__llvm_stackmaps
|
; CHECK-LABEL: .section __LLVM_STACKMAPS,__llvm_stackmaps
|
||||||
; CHECK-NEXT: __LLVM_StackMaps:
|
; CHECK-NEXT: __LLVM_StackMaps:
|
||||||
; Header
|
; Header
|
||||||
; CHECK-NEXT: .long 0
|
; CHECK-NEXT: .long 0
|
||||||
|
; Num Functions
|
||||||
|
; CHECK-NEXT: .long 8
|
||||||
|
; CHECK-NEXT: .long _test
|
||||||
|
; CHECK-NEXT: .long 8
|
||||||
|
; CHECK-NEXT: .long _property_access1
|
||||||
|
; CHECK-NEXT: .long 8
|
||||||
|
; CHECK-NEXT: .long _property_access2
|
||||||
|
; CHECK-NEXT: .long 24
|
||||||
|
; CHECK-NEXT: .long _property_access3
|
||||||
|
; CHECK-NEXT: .long 24
|
||||||
|
; CHECK-NEXT: .long _anyreg_test1
|
||||||
|
; CHECK-NEXT: .long 56
|
||||||
|
; CHECK-NEXT: .long _anyreg_test2
|
||||||
|
; CHECK-NEXT: .long 56
|
||||||
|
; CHECK-NEXT: .long _patchpoint_spilldef
|
||||||
|
; CHECK-NEXT: .long 56
|
||||||
|
; CHECK-NEXT: .long _patchpoint_spillargs
|
||||||
|
; CHECK-NEXT: .long 88
|
||||||
; Num Constants
|
; Num Constants
|
||||||
; CHECK-NEXT: .long 0
|
; CHECK-NEXT: .long 0
|
||||||
; Num Callsites
|
; Num Callsites
|
||||||
@ -343,8 +361,8 @@ entry:
|
|||||||
define anyregcc void @anyregcc1() {
|
define anyregcc void @anyregcc1() {
|
||||||
entry:
|
entry:
|
||||||
;SSE-LABEL: anyregcc1
|
;SSE-LABEL: anyregcc1
|
||||||
;SSE: pushq %rax
|
|
||||||
;SSE: pushq %rbp
|
;SSE: pushq %rbp
|
||||||
|
;SSE: pushq %rax
|
||||||
;SSE: pushq %r15
|
;SSE: pushq %r15
|
||||||
;SSE: pushq %r14
|
;SSE: pushq %r14
|
||||||
;SSE: pushq %r13
|
;SSE: pushq %r13
|
||||||
@ -375,8 +393,8 @@ entry:
|
|||||||
;SSE-NEXT: movaps %xmm1
|
;SSE-NEXT: movaps %xmm1
|
||||||
;SSE-NEXT: movaps %xmm0
|
;SSE-NEXT: movaps %xmm0
|
||||||
;AVX-LABEL:anyregcc1
|
;AVX-LABEL:anyregcc1
|
||||||
;AVX: pushq %rax
|
|
||||||
;AVX: pushq %rbp
|
;AVX: pushq %rbp
|
||||||
|
;AVX: pushq %rax
|
||||||
;AVX: pushq %r15
|
;AVX: pushq %r15
|
||||||
;AVX: pushq %r14
|
;AVX: pushq %r14
|
||||||
;AVX: pushq %r13
|
;AVX: pushq %r13
|
||||||
@ -390,22 +408,22 @@ entry:
|
|||||||
;AVX: pushq %rdx
|
;AVX: pushq %rdx
|
||||||
;AVX: pushq %rcx
|
;AVX: pushq %rcx
|
||||||
;AVX: pushq %rbx
|
;AVX: pushq %rbx
|
||||||
;AVX: vmovups %ymm15
|
;AVX: vmovaps %ymm15
|
||||||
;AVX-NEXT: vmovups %ymm14
|
;AVX-NEXT: vmovaps %ymm14
|
||||||
;AVX-NEXT: vmovups %ymm13
|
;AVX-NEXT: vmovaps %ymm13
|
||||||
;AVX-NEXT: vmovups %ymm12
|
;AVX-NEXT: vmovaps %ymm12
|
||||||
;AVX-NEXT: vmovups %ymm11
|
;AVX-NEXT: vmovaps %ymm11
|
||||||
;AVX-NEXT: vmovups %ymm10
|
;AVX-NEXT: vmovaps %ymm10
|
||||||
;AVX-NEXT: vmovups %ymm9
|
;AVX-NEXT: vmovaps %ymm9
|
||||||
;AVX-NEXT: vmovups %ymm8
|
;AVX-NEXT: vmovaps %ymm8
|
||||||
;AVX-NEXT: vmovups %ymm7
|
;AVX-NEXT: vmovaps %ymm7
|
||||||
;AVX-NEXT: vmovups %ymm6
|
;AVX-NEXT: vmovaps %ymm6
|
||||||
;AVX-NEXT: vmovups %ymm5
|
;AVX-NEXT: vmovaps %ymm5
|
||||||
;AVX-NEXT: vmovups %ymm4
|
;AVX-NEXT: vmovaps %ymm4
|
||||||
;AVX-NEXT: vmovups %ymm3
|
;AVX-NEXT: vmovaps %ymm3
|
||||||
;AVX-NEXT: vmovups %ymm2
|
;AVX-NEXT: vmovaps %ymm2
|
||||||
;AVX-NEXT: vmovups %ymm1
|
;AVX-NEXT: vmovaps %ymm1
|
||||||
;AVX-NEXT: vmovups %ymm0
|
;AVX-NEXT: vmovaps %ymm0
|
||||||
call void asm sideeffect "", "~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{rbp},~{xmm0},~{xmm1},~{xmm2},~{xmm3},~{xmm4},~{xmm5},~{xmm6},~{xmm7},~{xmm8},~{xmm9},~{xmm10},~{xmm11},~{xmm12},~{xmm13},~{xmm14},~{xmm15}"()
|
call void asm sideeffect "", "~{rax},~{rbx},~{rcx},~{rdx},~{rsi},~{rdi},~{r8},~{r9},~{r10},~{r11},~{r12},~{r13},~{r14},~{r15},~{rbp},~{xmm0},~{xmm1},~{xmm2},~{xmm3},~{xmm4},~{xmm5},~{xmm6},~{xmm7},~{xmm8},~{xmm9},~{xmm10},~{xmm11},~{xmm12},~{xmm13},~{xmm14},~{xmm15}"()
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,13 @@
|
|||||||
|
|
||||||
; CHECK-LABEL: .section __LLVM_STACKMAPS,__llvm_stackmaps
|
; CHECK-LABEL: .section __LLVM_STACKMAPS,__llvm_stackmaps
|
||||||
; CHECK-NEXT: __LLVM_StackMaps:
|
; CHECK-NEXT: __LLVM_StackMaps:
|
||||||
; CHECK-NEXT: .long 0
|
; CHECK-NEXT: .long 0
|
||||||
|
; Num Functions
|
||||||
|
; CHECK-NEXT: .long 2
|
||||||
|
; CHECK-NEXT: .long _stackmap_liveness
|
||||||
|
; CHECK-NEXT: .long 8
|
||||||
|
; CHECK-NEXT: .long _mixed_liveness
|
||||||
|
; CHECK-NEXT: .long 8
|
||||||
; Num LargeConstants
|
; Num LargeConstants
|
||||||
; CHECK-NEXT: .long 0
|
; CHECK-NEXT: .long 0
|
||||||
; Num Callsites
|
; Num Callsites
|
||||||
|
@ -4,7 +4,37 @@
|
|||||||
|
|
||||||
; CHECK-LABEL: .section __LLVM_STACKMAPS,__llvm_stackmaps
|
; CHECK-LABEL: .section __LLVM_STACKMAPS,__llvm_stackmaps
|
||||||
; CHECK-NEXT: __LLVM_StackMaps:
|
; CHECK-NEXT: __LLVM_StackMaps:
|
||||||
; CHECK-NEXT: .long 0
|
; CHECK-NEXT: .long 0
|
||||||
|
; Num Functions
|
||||||
|
; CHECK-NEXT: .long 14
|
||||||
|
; CHECK-NEXT: .long _constantargs
|
||||||
|
; CHECK-NEXT: .long 8
|
||||||
|
; CHECK-NEXT: .long _osrinline
|
||||||
|
; CHECK-NEXT: .long 24
|
||||||
|
; CHECK-NEXT: .long _osrcold
|
||||||
|
; CHECK-NEXT: .long 8
|
||||||
|
; CHECK-NEXT: .long _propertyRead
|
||||||
|
; CHECK-NEXT: .long 8
|
||||||
|
; CHECK-NEXT: .long _propertyWrite
|
||||||
|
; CHECK-NEXT: .long 8
|
||||||
|
; CHECK-NEXT: .long _jsVoidCall
|
||||||
|
; CHECK-NEXT: .long 8
|
||||||
|
; CHECK-NEXT: .long _jsIntCall
|
||||||
|
; CHECK-NEXT: .long 8
|
||||||
|
; CHECK-NEXT: .long _spilledValue
|
||||||
|
; CHECK-NEXT: .long 56
|
||||||
|
; CHECK-NEXT: .long _spilledStackMapValue
|
||||||
|
; CHECK-NEXT: .long 56
|
||||||
|
; CHECK-NEXT: .long _spillSubReg
|
||||||
|
; CHECK-NEXT: .long 56
|
||||||
|
; CHECK-NEXT: .long _subRegOffset
|
||||||
|
; CHECK-NEXT: .long 56
|
||||||
|
; CHECK-NEXT: .long _liveConstant
|
||||||
|
; CHECK-NEXT: .long 8
|
||||||
|
; CHECK-NEXT: .long _directFrameIdx
|
||||||
|
; CHECK-NEXT: .long 56
|
||||||
|
; CHECK-NEXT: .long _longid
|
||||||
|
; CHECK-NEXT: .long 8
|
||||||
; Num LargeConstants
|
; Num LargeConstants
|
||||||
; CHECK-NEXT: .long 3
|
; CHECK-NEXT: .long 3
|
||||||
; CHECK-NEXT: .quad 2147483648
|
; CHECK-NEXT: .quad 2147483648
|
||||||
|
Loading…
Reference in New Issue
Block a user