Skip to content

Commit

Permalink
Merge branch 'main' of github.com:ykjit/ykllvm into clone-llvm-module…
Browse files Browse the repository at this point in the history
…-pass
  • Loading branch information
Pavel-Durov committed Oct 6, 2024
2 parents 934af15 + 1056ba1 commit a16462c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
4 changes: 3 additions & 1 deletion llvm/lib/LTO/LTOBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -521,11 +521,13 @@ Error lto::backend(const Config &C, AddStreamFn AddStream,
}

// Yk can't tolerate backend optimisations, so we mark every function with
// `optnone` from here onwards.
// `optnone` from here onwards. Note that `noinline` is a required
// prerequisite of `optnone`.
if (YkOptNoneAfterIRPasses) {
for (Function &F: Mod) {
if (!F.isDeclaration()) {
F.addFnAttr(Attribute::OptimizeNone);
F.addFnAttr(Attribute::NoInline);
}
}
}
Expand Down
23 changes: 17 additions & 6 deletions llvm/lib/YkIR/YkIRWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,10 @@ class YkIRWriter {
unsigned &InstIdx) {
// Tail calls:
//
// - The `tail` keyword is documented as ignorable, so we do.
// - The `tail` keyword is ignorable and merely means that the call *could*
// be tail called, should an appropriate calling convention be used for
// the call. It's safe for us to ignore this because we check the calling
// convention of the call separately below.
//
// - The `notail` keyword just means don't add `tail` or `musttail`. I
// think this has no consequences for us.
Expand All @@ -674,13 +677,20 @@ class YkIRWriter {
AttributeList Attrs = I->getAttributes();
for (unsigned AI = 0; AI < I->arg_size(); AI++) {
for (auto &Attr : Attrs.getParamAttrs(AI)) {
// `nonull`, `noundef` and `dereferencable` are used a lot. I think
// for our purposes they can be safely ignored.
// `nonull`, `noundef`, `nounwind` and `dereferencable` are used a lot.
// I think for our purposes they can be safely ignored.
if (((Attr.getKindAsEnum() == Attribute::NonNull) ||
(Attr.getKindAsEnum() == Attribute::NoUndef) ||
(Attr.getKindAsEnum() == Attribute::NoUnwind) ||
(Attr.getKindAsEnum() == Attribute::Dereferenceable))) {
continue;
}
// "indicates that the annotated function will always return at least a
// given number of bytes (or null)" -- not relevant for Yk at this
// time.
if (Attr.getKindAsEnum() == Attribute::AllocSize) {
continue;
}
serialiseUnimplementedInstruction(I, FLCtxt, BBIdx, InstIdx);
return;
}
Expand Down Expand Up @@ -1248,18 +1258,19 @@ class YkIRWriter {
void serialiseCastInst(CastInst *I, FuncLowerCtxt &FLCtxt, unsigned BBIdx,
unsigned &InstIdx) {
// We don't support:
// - truncating ptrtoint
// - truncating ptrtoint/inttoptr
// - any cast we've not thought about
// - vector casts
std::optional<CastKind> CK = getCastKind(I->getOpcode());
if (isa<PtrToIntInst>(I)) {
if (isa<PtrToIntInst>(I) || isa<IntToPtrInst>(I)) {
TypeSize SrcSize = DL.getTypeSizeInBits(I->getSrcTy());
TypeSize DstSize = DL.getTypeSizeInBits(I->getDestTy());
if (DstSize < SrcSize) {
serialiseUnimplementedInstruction(I, FLCtxt, BBIdx, InstIdx);
return;
}
// After excluding truncation from ptrtoint, it's just a zext in disguise.
// After excluding truncation from ptrtoint/inttoptr, it's just a zext in
// disguise.
CK = CastKindZeroExt;
}
if (!CK.has_value() || (I->getOperand(0)->getType()->isVectorTy())) {
Expand Down

0 comments on commit a16462c

Please sign in to comment.