diff options
author | Wei Xiao <wei3.xiao@intel.com> | 2023-02-24 14:33:15 +0800 |
---|---|---|
committer | Wei Xiao <wei3.xiao@intel.com> | 2023-03-01 10:35:38 +0800 |
commit | 3fd533fd33f394e256a8ae38a3eabd7e998b68a0 (patch) | |
tree | a759c4585ea7d66935511d7bb81634414abc5c4d /llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | |
parent | 368c9f881320d86c20f24d23965cd30758304b30 (diff) | |
download | llvm-3fd533fd33f394e256a8ae38a3eabd7e998b68a0.zip llvm-3fd533fd33f394e256a8ae38a3eabd7e998b68a0.tar.gz llvm-3fd533fd33f394e256a8ae38a3eabd7e998b68a0.tar.bz2 |
[COFF][X86_64] Put jump table in .rdata for Windows
Put jump table in .rdata for Windows to align with that for Linux.
It can avoid loading the same code page into I$ and D$ simultaneously
and thus favor performance.
Differential Revision: https://reviews.llvm.org/D144701
Diffstat (limited to 'llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp')
-rw-r--r-- | llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp index 9852ffe..b78a4d2 100644 --- a/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp +++ b/llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp @@ -71,6 +71,10 @@ using namespace llvm; using namespace dwarf; +static cl::opt<bool> JumpTableInFunctionSection( + "jumptable-in-function-section", cl::Hidden, cl::init(false), + cl::desc("Putting Jump Table in function section")); + static void GetObjCImageInfo(Module &M, unsigned &Version, unsigned &Flags, StringRef &Section) { SmallVector<Module::ModuleFlagEntry, 8> ModuleFlags; @@ -1777,6 +1781,19 @@ MCSection *TargetLoweringObjectFileCOFF::getSectionForJumpTable( COFF::IMAGE_COMDAT_SELECT_ASSOCIATIVE, UniqueID); } +bool TargetLoweringObjectFileCOFF::shouldPutJumpTableInFunctionSection( + bool UsesLabelDifference, const Function &F) const { + if (TM->getTargetTriple().getArch() == Triple::x86_64) { + if (!JumpTableInFunctionSection) { + // We can always create relative relocations, so use another section + // that can be marked non-executable. + return false; + } + } + return TargetLoweringObjectFile::shouldPutJumpTableInFunctionSection( + UsesLabelDifference, F); +} + void TargetLoweringObjectFileCOFF::emitModuleMetadata(MCStreamer &Streamer, Module &M) const { emitLinkerDirectives(Streamer, M); |