Skip to content

Commit

Permalink
Merged master:b6635b5b15c into amd-gfx:5500f455383
Browse files Browse the repository at this point in the history
Local branch amd-gfx 5500f45 Merged master:142d0d3ed8e0 into amd-gfx:4cc47b88ab72
Remote branch master b6635b5 [lldb] Add SBCommandInterpreterRunOptions to LLDB.h
  • Loading branch information
Sw authored and Sw committed Jul 30, 2020
2 parents 5500f45 + b6635b5 commit 5bda552
Show file tree
Hide file tree
Showing 35 changed files with 789 additions and 161 deletions.
6 changes: 3 additions & 3 deletions clang-tools-extra/clangd/index/remote/server/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class RemoteIndexServer final : public SymbolIndex::Service {
}
unsigned Sent = 0;
unsigned FailedToSend = 0;
Index->lookup(*Req, [&](const auto &Item) {
Index->lookup(*Req, [&](const clangd::Symbol &Item) {
auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
if (!SerializedItem) {
++FailedToSend;
Expand Down Expand Up @@ -121,7 +121,7 @@ class RemoteIndexServer final : public SymbolIndex::Service {
}
unsigned Sent = 0;
unsigned FailedToSend = 0;
bool HasMore = Index->fuzzyFind(*Req, [&](const auto &Item) {
bool HasMore = Index->fuzzyFind(*Req, [&](const clangd::Symbol &Item) {
auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
if (!SerializedItem) {
++FailedToSend;
Expand Down Expand Up @@ -150,7 +150,7 @@ class RemoteIndexServer final : public SymbolIndex::Service {
}
unsigned Sent = 0;
unsigned FailedToSend = 0;
bool HasMore = Index->refs(*Req, [&](const auto &Item) {
bool HasMore = Index->refs(*Req, [&](const clangd::Ref &Item) {
auto SerializedItem = ProtobufMarshaller->toProtobuf(Item);
if (!SerializedItem) {
++FailedToSend;
Expand Down
68 changes: 48 additions & 20 deletions clang/lib/CodeGen/CGOpenMPRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1455,6 +1455,19 @@ void CGOpenMPRuntime::clearLocThreadIdInsertPt(CodeGenFunction &CGF) {
}
}

static StringRef getIdentStringFromSourceLocation(CodeGenFunction &CGF,
SourceLocation Loc,
SmallString<128> &Buffer) {
llvm::raw_svector_ostream OS(Buffer);
// Build debug location
PresumedLoc PLoc = CGF.getContext().getSourceManager().getPresumedLoc(Loc);
OS << ";" << PLoc.getFilename() << ";";
if (const auto *FD = dyn_cast_or_null<FunctionDecl>(CGF.CurFuncDecl))
OS << FD->getQualifiedNameAsString();
OS << ";" << PLoc.getLine() << ";" << PLoc.getColumn() << ";;";
return OS.str();
}

llvm::Value *CGOpenMPRuntime::emitUpdateLocation(CodeGenFunction &CGF,
SourceLocation Loc,
unsigned Flags) {
Expand All @@ -1464,6 +1477,16 @@ llvm::Value *CGOpenMPRuntime::emitUpdateLocation(CodeGenFunction &CGF,
Loc.isInvalid())
return getOrCreateDefaultLocation(Flags).getPointer();

// If the OpenMPIRBuilder is used we need to use it for all location handling
// as the clang invariants used below might be broken.
if (CGM.getLangOpts().OpenMPIRBuilder) {
SmallString<128> Buffer;
OMPBuilder.updateToLocation(CGF.Builder.saveIP());
auto *SrcLocStr = OMPBuilder.getOrCreateSrcLocStr(
getIdentStringFromSourceLocation(CGF, Loc, Buffer));
return OMPBuilder.getOrCreateIdent(SrcLocStr, IdentFlag(Flags));
}

assert(CGF.CurFn && "No function in current CodeGenFunction.");

CharUnits Align = CGM.getContext().getTypeAlignInChars(IdentQTy);
Expand Down Expand Up @@ -1497,15 +1520,9 @@ llvm::Value *CGOpenMPRuntime::emitUpdateLocation(CodeGenFunction &CGF,

llvm::Value *OMPDebugLoc = OpenMPDebugLocMap.lookup(Loc.getRawEncoding());
if (OMPDebugLoc == nullptr) {
SmallString<128> Buffer2;
llvm::raw_svector_ostream OS2(Buffer2);
// Build debug location
PresumedLoc PLoc = CGF.getContext().getSourceManager().getPresumedLoc(Loc);
OS2 << ";" << PLoc.getFilename() << ";";
if (const auto *FD = dyn_cast_or_null<FunctionDecl>(CGF.CurFuncDecl))
OS2 << FD->getQualifiedNameAsString();
OS2 << ";" << PLoc.getLine() << ";" << PLoc.getColumn() << ";;";
OMPDebugLoc = CGF.Builder.CreateGlobalStringPtr(OS2.str());
SmallString<128> Buffer;
OMPDebugLoc = CGF.Builder.CreateGlobalStringPtr(
getIdentStringFromSourceLocation(CGF, Loc, Buffer));
OpenMPDebugLocMap[Loc.getRawEncoding()] = OMPDebugLoc;
}
// *psource = ";<File>;<Function>;<Line>;<Column>;;";
Expand All @@ -1519,6 +1536,16 @@ llvm::Value *CGOpenMPRuntime::emitUpdateLocation(CodeGenFunction &CGF,
llvm::Value *CGOpenMPRuntime::getThreadID(CodeGenFunction &CGF,
SourceLocation Loc) {
assert(CGF.CurFn && "No function in current CodeGenFunction.");
// If the OpenMPIRBuilder is used we need to use it for all thread id calls as
// the clang invariants used below might be broken.
if (CGM.getLangOpts().OpenMPIRBuilder) {
SmallString<128> Buffer;
OMPBuilder.updateToLocation(CGF.Builder.saveIP());
auto *SrcLocStr = OMPBuilder.getOrCreateSrcLocStr(
getIdentStringFromSourceLocation(CGF, Loc, Buffer));
return OMPBuilder.getOrCreateThreadID(
OMPBuilder.getOrCreateIdent(SrcLocStr));
}

llvm::Value *ThreadID = nullptr;
// Check whether we've already cached a load of the thread id in this
Expand Down Expand Up @@ -8108,17 +8135,18 @@ class MappableExprsHandler {
// array section or array shaping. The base address is passed as a
// pointer to base in this case and cannot be used as a base for
// use_device_ptr list item.
auto PrevCI = std::next(CI->Components.rbegin());
const auto *VarD = dyn_cast<VarDecl>(VD);
if (CI != It->second.end() &&
(CGF.CGM.getOpenMPRuntime().hasRequiresUnifiedSharedMemory() ||
isa<MemberExpr>(IE) ||
!VD->getType().getNonReferenceType()->isPointerType() ||
PrevCI == CI->Components.rend() ||
isa<MemberExpr>(PrevCI->getAssociatedExpression()) || !VarD ||
VarD->hasLocalStorage())) {
CI->ReturnDevicePointer = true;
continue;
if (CI != It->second.end()) {
auto PrevCI = std::next(CI->Components.rbegin());
const auto *VarD = dyn_cast<VarDecl>(VD);
if (CGF.CGM.getOpenMPRuntime().hasRequiresUnifiedSharedMemory() ||
isa<MemberExpr>(IE) ||
!VD->getType().getNonReferenceType()->isPointerType() ||
PrevCI == CI->Components.rend() ||
isa<MemberExpr>(PrevCI->getAssociatedExpression()) || !VarD ||
VarD->hasLocalStorage()) {
CI->ReturnDevicePointer = true;
continue;
}
}
}

Expand Down
8 changes: 5 additions & 3 deletions clang/lib/CodeGen/CGStmtOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1707,9 +1707,11 @@ void CodeGenFunction::EmitOMPParallelDirective(const OMPParallelDirective &S) {

CGCapturedStmtInfo CGSI(*CS, CR_OpenMP);
CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(*this, &CGSI);
Builder.restoreIP(OMPBuilder.CreateParallel(Builder, BodyGenCB, PrivCB,
FiniCB, IfCond, NumThreads,
ProcBind, S.hasCancel()));
llvm::OpenMPIRBuilder::InsertPointTy AllocaIP(
AllocaInsertPt->getParent(), AllocaInsertPt->getIterator());
Builder.restoreIP(
OMPBuilder.CreateParallel(Builder, AllocaIP, BodyGenCB, PrivCB, FiniCB,
IfCond, NumThreads, ProcBind, S.hasCancel()));
return;
}

Expand Down
9 changes: 4 additions & 5 deletions clang/test/OpenMP/cancel_codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

float flag;
int main (int argc, char **argv) {
// ALL: [[GTID:%.+]] = call i32 @__kmpc_global_thread_num(
#pragma omp parallel
{
#pragma omp cancel parallel if(flag)
Expand All @@ -42,14 +41,14 @@ int main (int argc, char **argv) {
}
}
// ALL: call void @__kmpc_for_static_init_4(
// ALL: [[RES:%.+]] = call i32 @__kmpc_cancel(%struct.ident_t* {{[^,]+}}, i32 [[GTID]], i32 3)
// ALL: [[RES:%.+]] = call i32 @__kmpc_cancel(%struct.ident_t* {{[^,]+}}, i32 [[GTID:%.*]], i32 3)
// ALL: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
// ALL: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
// ALL: [[EXIT]]
// ALL: br label
// ALL: [[CONTINUE]]
// ALL: br label
// ALL: [[RES:%.+]] = call i32 @__kmpc_cancel(%struct.ident_t* {{[^,]+}}, i32 [[GTID]], i32 3)
// ALL: [[RES:%.+]] = call i32 @__kmpc_cancel(%struct.ident_t* {{[^,]+}}, i32 [[GTID:%.*]], i32 3)
// ALL: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
// ALL: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
// ALL: [[EXIT]]
Expand All @@ -66,7 +65,7 @@ for (int i = 0; i < argc; ++i) {
// ALL: [[BOOL:%.+]] = fcmp une float [[FLAG]], 0.000000e+00
// ALL: br i1 [[BOOL]], label %[[THEN:[^,]+]], label %[[ELSE:[^,]+]]
// ALL: [[THEN]]
// ALL: [[RES:%.+]] = call i32 @__kmpc_cancel(%struct.ident_t* {{[^,]+}}, i32 [[GTID]], i32 2)
// ALL: [[RES:%.+]] = call i32 @__kmpc_cancel(%struct.ident_t* {{[^,]+}}, i32 [[GTID:%.*]], i32 2)
// ALL: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
// ALL: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
// ALL: [[EXIT]]
Expand Down Expand Up @@ -148,7 +147,7 @@ for (int i = 0; i < argc; ++i) {
// CHECK: br label
// CHECK: [[CONTINUE]]
// CHECK: br label
// CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%struct.ident_t* {{[^,]+}}, i32 [[GTID]], i32 3)
// CHECK: [[RES:%.+]] = call i32 @__kmpc_cancel(%struct.ident_t* {{[^,]+}}, i32 [[GTID:%.*]], i32 3)
// CHECK: [[CMP:%.+]] = icmp ne i32 [[RES]], 0
// CHECK: br i1 [[CMP]], label %[[EXIT:[^,].+]], label %[[CONTINUE:.+]]
// CHECK: [[EXIT]]
Expand Down
Loading

0 comments on commit 5bda552

Please sign in to comment.