Skip to content

Commit

Permalink
Merge rust-lang#74
Browse files Browse the repository at this point in the history
74: Stuff required for AOT optimisations. r=ptersilie a=vext01



Co-authored-by: Edd Barrett <[email protected]>
  • Loading branch information
bors[bot] and vext01 authored Jul 12, 2023
2 parents 23597b1 + ddc9c1e commit 3517652
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions llvm/include/llvm/Support/Yk.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ namespace llvm {
void initYkOptions(void);
} // namespace llvm

// YKFIXME: all of our command-line arguments should be collected here instead
// of us randomly introducing `extern bool`s all over the place.
extern bool YkOptNoneAfterIRPasses;

#endif
11 changes: 11 additions & 0 deletions llvm/lib/LTO/LTOBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include "llvm/Support/ThreadPool.h"
#include "llvm/Support/ToolOutputFile.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/Yk.h"
#include "llvm/Target/TargetMachine.h"
#include "llvm/Transforms/IPO/WholeProgramDevirt.h"
#include "llvm/Transforms/Scalar/LoopPassManager.h"
Expand Down Expand Up @@ -509,6 +510,16 @@ Error lto::backend(const Config &C, AddStreamFn AddStream,
return Error::success();
}

// Yk can't tolerate backend optimisations, so we mark every function with
// `optnone` from here onwards.
if (YkOptNoneAfterIRPasses) {
for (Function &F: Mod) {
if (!F.isDeclaration()) {
F.addFnAttr(Attribute::OptimizeNone);
}
}
}

if (ParallelCodeGenParallelismLevel == 1) {
codegen(C, TM.get(), AddStream, 0, Mod, CombinedIndex);
} else {
Expand Down
16 changes: 16 additions & 0 deletions llvm/lib/Support/Yk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,27 @@ static ManagedStatic<cl::opt<bool, true>,
CreateYkStackmapsSpillReloadsFixParser>
YkStackmapsSpillFixParser;

bool YkOptNoneAfterIRPasses;
namespace {
struct CreateYkOptNoneAfterIRPassesParser {
static void *call() {
return new cl::opt<bool, true>(
"yk-optnone-after-ir-passes",
cl::desc(
"Apply `optnone` to all functions prior to instruction selection."),
cl::NotHidden, cl::location(YkOptNoneAfterIRPasses));
}
};
} // namespace
static ManagedStatic<cl::opt<bool, true>,
CreateYkOptNoneAfterIRPassesParser> YkOptNoneAfterIRPassesParser;

void llvm::initYkOptions() {
*YkAllocLLVMBCSectionParser;
*YkAllocLLVMBBAddrMapSectionParser;
*YkExtendedLLVMBBAddrMapSectionParser;
*YkStackMapOffsetFixParser;
*YkStackMapAdditionalLocsParser;
*YkStackmapsSpillFixParser;
*YkOptNoneAfterIRPassesParser;
}

0 comments on commit 3517652

Please sign in to comment.