Skip to content

Commit

Permalink
Fix errors from merging.
Browse files Browse the repository at this point in the history
  • Loading branch information
swatanabe committed Sep 20, 2017
1 parent 9d46ee7 commit 1d46448
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 31 deletions.
5 changes: 3 additions & 2 deletions lib/CodeGen/CGExpr.cpp
Expand Up @@ -3116,6 +3116,7 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
// it. It needs to be emitted first in case it's what captures
// the VLA bounds.
Addr = EmitPointerWithAlignment(E->getBase(), &AlignSource);
auto *Idx = EmitIdxAfterBase(/*Promote*/true);

// The element count here is the total number of non-VLA elements.
llvm::Value *numElements = getVLASize(E->getType()).first;
Expand All @@ -3131,7 +3132,7 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
}

if (E->getType().getQualifiers().hasShared()) {
Addr = Address(EmitUPCPointerArithmetic(Addr.getPointer(), Idx, getContext().getPointerType(vla->getElementType()), IdxTy, false), getArrayElementAlign(Addr.getAlignment(), Idx, getContext().getTypeSizeInChars(vla->getElementType())));
Addr = Address(EmitUPCPointerArithmetic(Addr.getPointer(), Idx, getContext().getPointerType(vla->getElementType()), E->getIdx()->getType(), false), getArrayElementAlign(Addr.getAlignment(), Idx, getContext().getTypeSizeInChars(vla->getElementType())));
} else {
Addr = emitArraySubscriptGEP(*this, Addr, Idx, vla->getElementType(),
!getLangOpts().isSignedOverflowDefined());
Expand Down Expand Up @@ -3192,7 +3193,7 @@ LValue CodeGenFunction::EmitArraySubscriptExpr(const ArraySubscriptExpr *E,
Addr = EmitPointerWithAlignment(E->getBase(), &AlignSource);
auto *Idx = EmitIdxAfterBase(/*Promote*/true);
if (E->getType().getQualifiers().hasShared()) {
Addr = Address(EmitUPCPointerArithmetic(Addr.getPointer(), Idx, E->getBase()->getType(), IdxTy, false), getArrayElementAlign(Addr.getAlignment(), Idx, getContext().getTypeSizeInChars(E->getType())));
Addr = Address(EmitUPCPointerArithmetic(Addr.getPointer(), Idx, E->getBase()->getType(), E->getIdx()->getType(), false), getArrayElementAlign(Addr.getAlignment(), Idx, getContext().getTypeSizeInChars(E->getType())));
} else {
Addr = emitArraySubscriptGEP(*this, Addr, Idx, E->getType(),
!getLangOpts().isSignedOverflowDefined());
Expand Down
2 changes: 1 addition & 1 deletion lib/CodeGen/CGExprConstant.cpp
Expand Up @@ -1641,7 +1641,7 @@ static llvm::Constant *EmitNullConstantForBase(CodeGenModule &CGM,
}

llvm::Constant *CodeGenModule::EmitNullConstant(QualType T) {
if (T->getAs<PointerType>())
if (T->getAs<PointerType>() && !T->hasPointerToSharedRepresentation())
return getNullPointer(
cast<llvm::PointerType>(getTypes().ConvertTypeForMem(T)), T);

Expand Down
4 changes: 2 additions & 2 deletions lib/CodeGen/CGExprUPC.cpp
Expand Up @@ -60,9 +60,9 @@ RValue CodeGenFunction::EmitUPCCall(
getTypes().arrangeFreeFunctionCall(Args, FuncType->castAs<FunctionType>(), false);
llvm::FunctionType * FTy =
cast<llvm::FunctionType>(ConvertType(FuncType));
llvm::Value * Fn = CGM.CreateRuntimeFunction(FTy, Name);
llvm::Constant * Fn = CGM.CreateRuntimeFunction(FTy, Name);

return EmitCall(Info, Fn, ReturnValueSlot(), Args);
return EmitCall(Info, CGCallee::forDirect(Fn), ReturnValueSlot(), Args);
}

llvm::Value *CodeGenFunction::EmitUPCCastSharedToLocal(llvm::Value *Value,
Expand Down
6 changes: 2 additions & 4 deletions lib/Parse/ParsePragma.cpp
Expand Up @@ -1201,8 +1201,7 @@ void PragmaUPCHandler::HandlePragma(Preprocessor &PP,
}

Sema::PragmaUPCKind *Info =
(Sema::PragmaUPCKind*) PP.getPreprocessorAllocator().Allocate(
sizeof(Sema::PragmaUPCKind), llvm::alignOf<Sema::PragmaUPCKind>());
PP.getPreprocessorAllocator().Allocate<Sema::PragmaUPCKind>();
new (Info) Sema::PragmaUPCKind(Kind);

MutableArrayRef<Token> Toks(PP.getPreprocessorAllocator().Allocate<Token>(1),
Expand Down Expand Up @@ -1249,8 +1248,7 @@ void PragmaPUPCHandler::HandlePragma(Preprocessor &PP,
}

Sema::PragmaPUPCKind *Info =
(Sema::PragmaPUPCKind*) PP.getPreprocessorAllocator().Allocate(
sizeof(Sema::PragmaPUPCKind), llvm::alignOf<Sema::PragmaPUPCKind>());
PP.getPreprocessorAllocator().Allocate<Sema::PragmaPUPCKind>();
new (Info) Sema::PragmaPUPCKind(Kind);

MutableArrayRef<Token> Toks(PP.getPreprocessorAllocator().Allocate<Token>(1),
Expand Down
42 changes: 21 additions & 21 deletions lib/Serialization/ASTReaderStmt.cpp
Expand Up @@ -263,45 +263,45 @@ void ASTStmtReader::VisitReturnStmt(ReturnStmt *S) {

void ASTStmtReader::VisitUPCNotifyStmt(UPCNotifyStmt *S) {
VisitStmt(S);
S->setIdValue(Reader.ReadSubExpr());
S->setNotifyLoc(ReadSourceLocation(Record, Idx));
S->setIdValue(Record.readSubExpr());
S->setNotifyLoc(ReadSourceLocation());
}

void ASTStmtReader::VisitUPCWaitStmt(UPCWaitStmt *S) {
VisitStmt(S);
S->setIdValue(Reader.ReadSubExpr());
S->setWaitLoc(ReadSourceLocation(Record, Idx));
S->setIdValue(Record.readSubExpr());
S->setWaitLoc(ReadSourceLocation());
}

void ASTStmtReader::VisitUPCBarrierStmt(UPCBarrierStmt *S) {
VisitStmt(S);
S->setIdValue(Reader.ReadSubExpr());
S->setBarrierLoc(ReadSourceLocation(Record, Idx));
S->setIdValue(Record.readSubExpr());
S->setBarrierLoc(ReadSourceLocation());
}

void ASTStmtReader::VisitUPCFenceStmt(UPCFenceStmt *S) {
VisitStmt(S);
S->setFenceLoc(ReadSourceLocation(Record, Idx));
S->setFenceLoc(ReadSourceLocation());
}

void ASTStmtReader::VisitUPCPragmaStmt(UPCPragmaStmt *S) {
VisitStmt(S);
S->setStrict(Record[Idx++] != 0);
S->setPragmaLoc(ReadSourceLocation(Record, Idx));
S->setStrict(Record.readInt() != 0);
S->setPragmaLoc(ReadSourceLocation());
}

void ASTStmtReader::VisitUPCForAllStmt(UPCForAllStmt *S) {
VisitStmt(S);
S->setInit(Reader.ReadSubStmt());
S->setCond(Reader.ReadSubExpr());
S->setConditionVariable(Reader.getContext(),
ReadDeclAs<VarDecl>(Record, Idx));
S->setInc(Reader.ReadSubExpr());
S->setAfnty(Reader.ReadSubExpr());
S->setBody(Reader.ReadSubStmt());
S->setForLoc(ReadSourceLocation(Record, Idx));
S->setLParenLoc(ReadSourceLocation(Record, Idx));
S->setRParenLoc(ReadSourceLocation(Record, Idx));
S->setInit(Record.readSubStmt());
S->setCond(Record.readSubExpr());
S->setConditionVariable(Record.getContext(),
ReadDeclAs<VarDecl>());
S->setInc(Record.readSubExpr());
S->setAfnty(Record.readSubExpr());
S->setBody(Record.readSubStmt());
S->setForLoc(ReadSourceLocation());
S->setLParenLoc(ReadSourceLocation());
S->setRParenLoc(ReadSourceLocation());
}

void ASTStmtReader::VisitDeclStmt(DeclStmt *S) {
Expand Down Expand Up @@ -553,12 +553,12 @@ void ASTStmtReader::VisitCharacterLiteral(CharacterLiteral *E) {

void ASTStmtReader::VisitUPCThreadExpr(UPCThreadExpr *E) {
VisitExpr(E);
E->setLocation(ReadSourceLocation(Record, Idx));
E->setLocation(ReadSourceLocation());
}

void ASTStmtReader::VisitUPCMyThreadExpr(UPCMyThreadExpr *E) {
VisitExpr(E);
E->setLocation(ReadSourceLocation(Record, Idx));
E->setLocation(ReadSourceLocation());
}

void ASTStmtReader::VisitParenExpr(ParenExpr *E) {
Expand Down
2 changes: 1 addition & 1 deletion tools/ast-test/ast-test.cpp
Expand Up @@ -220,7 +220,7 @@ namespace {

template<typename Type>
class DirectiveMatchBase : public Directive,
public llvm::RefCountedBaseVPTR {
public llvm::RefCountedBase<DirectiveMatchBase<Type> > {
virtual bool MatchImpl(Type const * T, std::string & OutGot) const = 0;

static void Dumper(void const * V) {
Expand Down

0 comments on commit 1d46448

Please sign in to comment.