diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 000000000000..ff9e3b76fdaf --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,10 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +## Version: 7.7.34 + +### New + + + diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt index 42f063e2af48..7a3a91909744 100644 --- a/llvm/CMakeLists.txt +++ b/llvm/CMakeLists.txt @@ -30,10 +30,10 @@ if(NOT DEFINED LLVM_VERSION_MAJOR) set(LLVM_VERSION_MAJOR 7) endif() if(NOT DEFINED LLVM_VERSION_MINOR) - set(LLVM_VERSION_MINOR 0) + set(LLVM_VERSION_MINOR 7) endif() if(NOT DEFINED LLVM_VERSION_PATCH) - set(LLVM_VERSION_PATCH 0) + set(LLVM_VERSION_PATCH 34) endif() if(NOT DEFINED LLVM_VERSION_SUFFIX) set(LLVM_VERSION_SUFFIX "") diff --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td index 28b86003cb4f..a204d0b692de 100644 --- a/llvm/include/llvm/IR/Intrinsics.td +++ b/llvm/include/llvm/IR/Intrinsics.td @@ -781,7 +781,7 @@ def int_experimental_gc_relocate : Intrinsic<[llvm_any_ty], // Coroutine Structure Intrinsics. // TVM local begin -def int_coro_id : Intrinsic<[llvm_token_ty], [llvm_i257_ty, llvm_ptr_ty, +def int_coro_id : Intrinsic<[llvm_token_ty], [llvm_i32_ty, llvm_ptr_ty, llvm_ptr_ty, llvm_ptr_ty], [IntrArgMemOnly, IntrReadMem, ReadNone<1>, ReadOnly<2>, NoCapture<2>]>; @@ -799,7 +799,7 @@ def int_coro_noop : Intrinsic<[llvm_ptr_ty], [], [IntrNoMem]>; def int_coro_size : Intrinsic<[llvm_anyint_ty], [], [IntrNoMem]>; def int_coro_save : Intrinsic<[llvm_token_ty], [llvm_ptr_ty], []>; -def int_coro_suspend : Intrinsic<[llvm_i257_ty], [llvm_token_ty, llvm_i1_ty], []>; +def int_coro_suspend : Intrinsic<[llvm_i8_ty], [llvm_token_ty, llvm_i1_ty], []>; def int_coro_param : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty, llvm_ptr_ty], [IntrNoMem, ReadNone<0>, ReadNone<1>]>; @@ -817,12 +817,12 @@ def int_coro_destroy : Intrinsic<[], [llvm_ptr_ty], [Throws]>; def int_coro_done : Intrinsic<[llvm_i1_ty], [llvm_ptr_ty], [IntrArgMemOnly, ReadOnly<0>, NoCapture<0>]>; def int_coro_promise : Intrinsic<[llvm_ptr_ty], - [llvm_ptr_ty, llvm_i257_ty, llvm_i1_ty], + [llvm_ptr_ty, llvm_i32_ty, llvm_i1_ty], [IntrNoMem, NoCapture<0>]>; // Coroutine Lowering Intrinsics. Used internally by coroutine passes. -def int_coro_subfn_addr : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_i257_ty], +def int_coro_subfn_addr : Intrinsic<[llvm_ptr_ty], [llvm_ptr_ty, llvm_i8_ty], [IntrReadMem, IntrArgMemOnly, ReadOnly<0>, NoCapture<0>]>; // TVM local end diff --git a/llvm/lib/Analysis/InlineCost.cpp b/llvm/lib/Analysis/InlineCost.cpp index 54a50f57c1ce..0a05ab5a700c 100644 --- a/llvm/lib/Analysis/InlineCost.cpp +++ b/llvm/lib/Analysis/InlineCost.cpp @@ -17,6 +17,7 @@ #include "llvm/ADT/SmallPtrSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/Statistic.h" +#include "llvm/ADT/Triple.h" #include "llvm/Analysis/AssumptionCache.h" #include "llvm/Analysis/BlockFrequencyInfo.h" #include "llvm/Analysis/CodeMetrics.h" @@ -2029,7 +2030,8 @@ bool llvm::isInlineViable(Function &F) { // TVM local begin #define CORO_PRESPLIT_ATTR "coroutine.presplit" // Disallow inlining of pre-split coroutines - if (F.hasFnAttribute(CORO_PRESPLIT_ATTR)) { + if (Triple(F.getParent()->getTargetTriple()).isTVM() && + F.hasFnAttribute(CORO_PRESPLIT_ATTR)) { return false; } // TVM local end diff --git a/llvm/lib/Transforms/Coroutines/CoroEarly.cpp b/llvm/lib/Transforms/Coroutines/CoroEarly.cpp index 59c7fde27691..5b036a54fd21 100644 --- a/llvm/lib/Transforms/Coroutines/CoroEarly.cpp +++ b/llvm/lib/Transforms/Coroutines/CoroEarly.cpp @@ -12,6 +12,7 @@ //===----------------------------------------------------------------------===// #include "CoroInternal.h" +#include "llvm/ADT/Triple.h" #include "llvm/IR/CallSite.h" #include "llvm/IR/IRBuilder.h" #include "llvm/IR/InstIterator.h" @@ -80,9 +81,14 @@ void Lowerer::lowerCoroPromise(CoroPromiseInst *Intrin) { Builder.SetInsertPoint(Intrin); // TVM local begin + Value *Replacement; // Fix: Offset as a signed constant - Value *Idx = ConstantInt::get(Type::getInt32Ty(Context), Offset, true); - Value *Replacement = Builder.CreateInBoundsGEP(Int8Ty, Operand, Idx); + if (Triple((Intrin->getModule()->getTargetTriple())).isTVM()) { + Value *Idx = ConstantInt::get(Type::getInt32Ty(Context), Offset, true); + Replacement = Builder.CreateInBoundsGEP(Int8Ty, Operand, Idx); + } else { + Replacement = Builder.CreateConstInBoundsGEP1_32(Int8Ty, Operand, Offset); + } // TVM local end Intrin->replaceAllUsesWith(Replacement); diff --git a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp index 1e593b05e5c1..ccffe72be016 100644 --- a/llvm/lib/Transforms/Coroutines/CoroFrame.cpp +++ b/llvm/lib/Transforms/Coroutines/CoroFrame.cpp @@ -771,15 +771,16 @@ static bool materializable(Instruction &V, Value *ThisPtr) { return true; } } - // Rematerializing load from contract class data for TVM - if (auto *Load = dyn_cast(&V)) { - auto *Ptr = Load->getPointerOperand()->stripInBoundsConstantOffsets(); - if (Ptr == ThisPtr) + if (Triple(V.getModule()->getTargetTriple()).isTVM()) { + // Rematerializing load from contract class data for TVM + if (auto *Load = dyn_cast(&V)) { + auto *Ptr = Load->getPointerOperand()->stripInBoundsConstantOffsets(); + if (Ptr == ThisPtr) + return true; + } + if (isa(&V)) return true; } - if (isa(&V)) - return true; - return isa(&V) || isa(&V) || isa(&V) || isa(&V) || isa(&V); } @@ -932,7 +933,8 @@ void coro::buildCoroutineFrame(Function &F, Shape &Shape) { for (int Repeat = 0; Repeat < 4; ++Repeat) { // See if there are materializable instructions across suspend points. // TVM local begin - assert(F.arg_size() >= 2 && + assert((!Triple(F.getParent()->getTargetTriple()).isTVM() || + F.arg_size() >= 2) && "We only support coroutine methods in TVM (resumable sret + this)"); auto *ThisPtr = &*std::next(F.arg_begin()); for (Instruction &I : instructions(F)) diff --git a/llvm/lib/Transforms/Coroutines/CoroInstr.h b/llvm/lib/Transforms/Coroutines/CoroInstr.h index 18d924128b90..b2059291506f 100644 --- a/llvm/lib/Transforms/Coroutines/CoroInstr.h +++ b/llvm/lib/Transforms/Coroutines/CoroInstr.h @@ -37,9 +37,7 @@ class LLVM_LIBRARY_VISIBILITY CoroSubFnInst : public IntrinsicInst { public: enum ResumeKind { - // TVM local begin RestartTrigger = -1, - // TVM local end ResumeIndex, DestroyIndex, CleanupIndex, @@ -49,10 +47,6 @@ class LLVM_LIBRARY_VISIBILITY CoroSubFnInst : public IntrinsicInst { Value *getFrame() const { return getArgOperand(FrameArg); } ResumeKind getIndex() const { - // TVM local begin - if (getRawIndex()->getValue().getMinSignedBits() > 64) - return RestartTrigger; - // TVM local end int64_t Index = getRawIndex()->getValue().getSExtValue(); assert(Index >= IndexFirst && Index < IndexLast && "unexpected CoroSubFnInst index argument"); diff --git a/llvm/lib/Transforms/Coroutines/CoroTVMExpand.cpp b/llvm/lib/Transforms/Coroutines/CoroTVMExpand.cpp index 919817454481..01b05f587b6e 100644 --- a/llvm/lib/Transforms/Coroutines/CoroTVMExpand.cpp +++ b/llvm/lib/Transforms/Coroutines/CoroTVMExpand.cpp @@ -458,6 +458,8 @@ struct CoroTVMExpand : FunctionPass { } bool runOnFunction(Function &F) override { + if (!Triple(F.getParent()->getTargetTriple()).isTVM()) + return false; if (!L) return false; diff --git a/llvm/tools/clang/lib/CodeGen/CGCleanup.cpp b/llvm/tools/clang/lib/CodeGen/CGCleanup.cpp index 72ea3076a171..0a766d176200 100644 --- a/llvm/tools/clang/lib/CodeGen/CGCleanup.cpp +++ b/llvm/tools/clang/lib/CodeGen/CGCleanup.cpp @@ -343,11 +343,9 @@ static void ResolveAllBranchFixups(CodeGenFunction &CGF, // i.e. where there's an unresolved fixup inside a single cleanup // entry which we're currently popping. if (Fixup.OptimisticBranchBlock == nullptr) { - // TVM local begin - createStoreInstBefore(CGF.Builder.getInt257(Fixup.DestinationIndex), + createStoreInstBefore(CGF.Builder.getInt32(Fixup.DestinationIndex), CGF.getNormalCleanupDestSlot(), Fixup.InitialBranch); - // TVM local end Fixup.InitialBranch->setSuccessor(0, CleanupEntry); } @@ -355,10 +353,8 @@ static void ResolveAllBranchFixups(CodeGenFunction &CGF, if (!CasesAdded.insert(Fixup.Destination).second) continue; - // TVM local begin - Switch->addCase(CGF.Builder.getInt257(Fixup.DestinationIndex), + Switch->addCase(CGF.Builder.getInt32(Fixup.DestinationIndex), Fixup.Destination); - // TVM local end } CGF.EHStack.clearFixups(); @@ -417,9 +413,7 @@ void CodeGenFunction::ResolveBranchFixups(llvm::BasicBlock *Block) { llvm::SwitchInst *Switch = TransitionToCleanupSwitch(*this, BranchBB); // Add a case to the switch. - // TVM local begin - Switch->addCase(Builder.getInt257(Fixup.DestinationIndex), Block); - // TVM local end + Switch->addCase(Builder.getInt32(Fixup.DestinationIndex), Block); } if (ResolvedAny) @@ -800,10 +794,8 @@ void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough) { // If there's a fallthrough, we need to store the cleanup // destination index. For fall-throughs this is always zero. if (HasFallthrough) { - // TVM local begin if (!HasPrebranchedFallthrough) - Builder.CreateStore(Builder.getInt257(0), getNormalCleanupDestSlot()); - // TVM local end + Builder.CreateStore(Builder.getInt32(0), getNormalCleanupDestSlot()); // Otherwise, save and clear the IP if we don't have fallthrough // because the cleanup is inactive. @@ -885,10 +877,8 @@ void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough) { // Branch-after fallthrough. if (FallthroughSource && !FallthroughIsBranchThrough) { FallthroughDest = createBasicBlock("cleanup.cont"); - // TVM local begin if (HasFallthrough) - Switch->addCase(Builder.getInt257(0), FallthroughDest); - // TVM local end + Switch->addCase(Builder.getInt32(0), FallthroughDest); } for (unsigned I = 0, E = Scope.getNumBranchAfters(); I != E; ++I) { @@ -923,11 +913,9 @@ void CodeGenFunction::PopCleanupBlock(bool FallthroughIsBranchThrough) { BranchFixup &Fixup = EHStack.getBranchFixup(I); if (!Fixup.Destination) continue; if (!Fixup.OptimisticBranchBlock) { - // TVM local begin - createStoreInstBefore(Builder.getInt257(Fixup.DestinationIndex), + createStoreInstBefore(Builder.getInt32(Fixup.DestinationIndex), getNormalCleanupDestSlot(), Fixup.InitialBranch); - // TVM local end Fixup.InitialBranch->setSuccessor(0, NormalEntry); } Fixup.OptimisticBranchBlock = NormalExit; @@ -1098,9 +1086,7 @@ void CodeGenFunction::EmitBranchThroughCleanup(JumpDest Dest) { // Otherwise, thread through all the normal cleanups in scope. // Store the index at the start. - // TVM local begin - llvm::ConstantInt *Index = Builder.getInt257(Dest.getDestIndex()); - // TVM local end + llvm::ConstantInt *Index = Builder.getInt32(Dest.getDestIndex()); createStoreInstBefore(Index, getNormalCleanupDestSlot(), BI); // Adjust BI to point to the first cleanup block. @@ -1282,11 +1268,9 @@ void CodeGenFunction::DeactivateCleanupBlock(EHScopeStack::stable_iterator C, } Address CodeGenFunction::getNormalCleanupDestSlot() { - // TVM local begin if (!NormalCleanupDest.isValid()) NormalCleanupDest = - CreateDefaultAlignTempAlloca(Builder.getInt257Ty(), "cleanup.dest.slot"); - // TVM local end + CreateDefaultAlignTempAlloca(Builder.getInt32Ty(), "cleanup.dest.slot"); return NormalCleanupDest; } diff --git a/llvm/tools/clang/lib/CodeGen/CGCoroutine.cpp b/llvm/tools/clang/lib/CodeGen/CGCoroutine.cpp index 30257b1a9bd6..08178032c861 100644 --- a/llvm/tools/clang/lib/CodeGen/CGCoroutine.cpp +++ b/llvm/tools/clang/lib/CodeGen/CGCoroutine.cpp @@ -220,10 +220,8 @@ static LValueOrRValue emitSuspendExpression(CodeGenFunction &CGF, CGCoroData &Co // Create a switch capturing three possible continuations. auto *Switch = Builder.CreateSwitch(SuspendResult, Coro.SuspendBB, 2); - // TVM local begin - Switch->addCase(Builder.getInt257(0), ReadyBlock); - Switch->addCase(Builder.getInt257(1), CleanupBlock); - // TVM local end + Switch->addCase(Builder.getInt8(0), ReadyBlock); + Switch->addCase(Builder.getInt8(1), CleanupBlock); // Emit cleanup for this suspend point. CGF.EmitBlock(CleanupBlock); @@ -563,18 +561,14 @@ void CodeGenFunction::EmitCoroutineBody(const CoroutineBodyStmt &S) { auto *FinalBB = createBasicBlock("coro.final"); auto *RetBB = createBasicBlock("coro.ret"); - // TVM local begin auto *CoroId = Builder.CreateCall( CGM.getIntrinsic(llvm::Intrinsic::coro_id), - {Builder.getInt257(NewAlign), NullPtr, NullPtr, NullPtr}); - // TVM local end + {Builder.getInt32(NewAlign), NullPtr, NullPtr, NullPtr}); createCoroData(*this, CurCoro, CoroId); CurCoro.Data->SuspendBB = RetBB; - // TVM local begin // Backend is allowed to elide memory allocations, to help it, emit - // auto mem = coro.alloc() ? ... allocation code ... : 0; - // TVM local end + // auto mem = coro.alloc() ? 0 : ... allocation code ...; auto *CoroAlloc = Builder.CreateCall( CGM.getIntrinsic(llvm::Intrinsic::coro_alloc), {CoroId});