diff --git a/lib/Reader/readerir.cpp b/lib/Reader/readerir.cpp index 5ce39f5bc30..4e88e7084ad 100644 --- a/lib/Reader/readerir.cpp +++ b/lib/Reader/readerir.cpp @@ -2611,17 +2611,21 @@ void GenIR::storePrimitiveType(IRNode *Value, IRNode *Addr, IRNode *TypedAddr = Addr; // We need to cast the address when types are mismatched. - Type *ExpectedTy = Value->getType(); + Type *ExpectedTy = this->getType(CorInfoType, NULL); if (ReferentTy != ExpectedTy) { Type *PtrToExpectedTy = getUnmanagedPointerType(ExpectedTy); TypedAddr = (IRNode *)LLVMBuilder->CreatePointerCast(Addr, PtrToExpectedTy); } + // Convert the value as necessary. + IRNode *ValueToStore = convertFromStackType(Value, CorInfoType, ExpectedTy); + uint32_t Align = (Alignment == Reader_AlignNatural) ? TargetPointerSizeInBits / 8 : Alignment; - StoreInst *StoreInst = LLVMBuilder->CreateStore(Value, TypedAddr, IsVolatile); + StoreInst *StoreInst = LLVMBuilder->CreateStore(ValueToStore, TypedAddr, + IsVolatile); StoreInst->setAlignment(Align); } @@ -2902,7 +2906,11 @@ IRNode *GenIR::genCall(ReaderCallTargetData *CallTargetInfo, GCLayout *GCInfo = nullptr; if (CallTargetInfo->isTailCall()) { - throw NotYetImplementedException("Tail call"); + // If there's no explicit tail prefix, we can generate + // a normal call and all will be well. + if (!CallTargetInfo->isUnmarkedTailCall()) { + throw NotYetImplementedException("Tail call"); + } } if (SigInfo->hasTypeArg()) { diff --git a/test/BaseLine/JIT/CodeGenBringUpTests/Add1.error.txt b/test/BaseLine/JIT/CodeGenBringUpTests/Add1.error.txt index 0b322d3c4b6..499fd619fb9 100644 --- a/test/BaseLine/JIT/CodeGenBringUpTests/Add1.error.txt +++ b/test/BaseLine/JIT/CodeGenBringUpTests/Add1.error.txt @@ -73,7 +73,31 @@ ThrowNullRef: ; preds = %7 } INFO: jitting method Monitor::Enter using LLILCJit -Failed to read Monitor.Enter[Tail call] +Successfully read Monitor.Enter + +define void @Monitor.Enter(%System.Object addrspace(1)* %param0, i8 addrspace(1)* %param1) { +entry: + %arg0 = alloca %System.Object addrspace(1)* + %arg1 = alloca i8 addrspace(1)* + store %System.Object addrspace(1)* %param0, %System.Object addrspace(1)** %arg0 + store i8 addrspace(1)* %param1, i8 addrspace(1)** %arg1 + %0 = load i8 addrspace(1)*, i8 addrspace(1)** %arg1 + %1 = load i8, i8 addrspace(1)* %0, align 8 + %2 = sext i8 %1 to i32 + %3 = icmp eq i32 %2, 0 + br i1 %3, label %5, label %4 + +;