Skip to content

Commit

Permalink
Merge from 'master' to 'sycl-web' (intel#44)
Browse files Browse the repository at this point in the history
  CONFLICT (add/add): Merge conflict in clang/tools/clang-offload-wrapper/ClangOffloadWrapper.cpp
  CONFLICT (add/add): Merge conflict in clang/tools/clang-offload-wrapper/CMakeLists.txt
  CONFLICT (add/add): Merge conflict in clang/test/Driver/clang-offload-wrapper.c
  CONFLICT (content): Merge conflict in clang/lib/Driver/ToolChains/Clang.h
  CONFLICT (content): Merge conflict in clang/lib/Driver/ToolChains/Clang.cpp
  CONFLICT (content): Merge conflict in clang/lib/Driver/ToolChain.cpp
  CONFLICT (content): Merge conflict in clang/lib/Driver/Driver.cpp
  CONFLICT (content): Merge conflict in clang/lib/Driver/Action.cpp
  CONFLICT (content): Merge conflict in clang/include/clang/Driver/ToolChain.h
  CONFLICT (content): Merge conflict in clang/include/clang/Driver/Action.h
  • Loading branch information
sndmitriev committed Oct 10, 2019
2 parents f75c5a6 + a0d8376 commit b5f1d79
Show file tree
Hide file tree
Showing 598 changed files with 4,302 additions and 1,710 deletions.
23 changes: 13 additions & 10 deletions clang-tools-extra/clangd/ClangdLSPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,16 +371,6 @@ class ClangdLSPServer::MessageHandler : public Transport::MessageHandler {

llvm::StringMap<std::function<void(llvm::json::Value)>> Notifications;
llvm::StringMap<std::function<void(llvm::json::Value, ReplyOnce)>> Calls;
// The maximum number of callbacks held in clangd.
//
// We bound the maximum size to the pending map to prevent memory leakage
// for cases where LSP clients don't reply for the request.
static constexpr int MaxReplayCallbacks = 100;
mutable std::mutex CallMutex;
int NextCallID = 0; /* GUARDED_BY(CallMutex) */
std::deque<std::pair</*RequestID*/ int,
/*ReplyHandler*/ Callback<llvm::json::Value>>>
ReplyCallbacks; /* GUARDED_BY(CallMutex) */

// Method calls may be cancelled by ID, so keep track of their state.
// This needs a mutex: handlers may finish on a different thread, and that's
Expand Down Expand Up @@ -432,6 +422,19 @@ class ClangdLSPServer::MessageHandler : public Transport::MessageHandler {
}));
}

// The maximum number of callbacks held in clangd.
//
// We bound the maximum size to the pending map to prevent memory leakage
// for cases where LSP clients don't reply for the request.
// This has to go after RequestCancellers and RequestCancellersMutex since it
// can contain a callback that has a cancelable context.
static constexpr int MaxReplayCallbacks = 100;
mutable std::mutex CallMutex;
int NextCallID = 0; /* GUARDED_BY(CallMutex) */
std::deque<std::pair</*RequestID*/ int,
/*ReplyHandler*/ Callback<llvm::json::Value>>>
ReplyCallbacks; /* GUARDED_BY(CallMutex) */

ClangdLSPServer &Server;
};
constexpr int ClangdLSPServer::MessageHandler::MaxReplayCallbacks;
Expand Down
5 changes: 5 additions & 0 deletions clang/include/clang/AST/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,8 @@ class ASTContext : public RefCountedBase<ASTContext> {
/// need to be consistently numbered for the mangler).
llvm::DenseMap<const DeclContext *, std::unique_ptr<MangleNumberingContext>>
MangleNumberingContexts;
llvm::DenseMap<const Decl *, std::unique_ptr<MangleNumberingContext>>
ExtraMangleNumberingContexts;

/// Side-table of mangling numbers for declarations which rarely
/// need them (like static local vars).
Expand Down Expand Up @@ -2812,6 +2814,9 @@ class ASTContext : public RefCountedBase<ASTContext> {
/// Retrieve the context for computing mangling numbers in the given
/// DeclContext.
MangleNumberingContext &getManglingNumberContext(const DeclContext *DC);
enum NeedExtraManglingDecl_t { NeedExtraManglingDecl };
MangleNumberingContext &getManglingNumberContext(NeedExtraManglingDecl_t,
const Decl *D);

std::unique_ptr<MangleNumberingContext> createMangleNumberingContext() const;

Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/AST/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -5577,7 +5577,7 @@ class ObjCTypeParamType : public Type,

public:
bool isSugared() const { return true; }
QualType desugar() const { return getCanonicalTypeInternal(); }
QualType desugar() const;

static bool classof(const Type *T) {
return T->getTypeClass() == ObjCTypeParam;
Expand Down
2 changes: 2 additions & 0 deletions clang/include/clang/Basic/BuiltinsWebAssembly.def
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ TARGET_BUILTIN(__builtin_wasm_trunc_saturate_s_i64_f64, "LLid", "nc", "nontrappi
TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i64_f64, "LLid", "nc", "nontrapping-fptoint")

// SIMD builtins
TARGET_BUILTIN(__builtin_wasm_swizzle_v8x16, "V16cV16cV16c", "nc", "unimplemented-simd128")

TARGET_BUILTIN(__builtin_wasm_extract_lane_s_i8x16, "iV16cIi", "nc", "simd128")
TARGET_BUILTIN(__builtin_wasm_extract_lane_u_i8x16, "iV16cIi", "nc", "unimplemented-simd128")
TARGET_BUILTIN(__builtin_wasm_extract_lane_s_i16x8, "iV8sIi", "nc", "simd128")
Expand Down
14 changes: 1 addition & 13 deletions clang/include/clang/Sema/Sema.h
Original file line number Diff line number Diff line change
Expand Up @@ -1167,13 +1167,6 @@ class Sema {
/// suffice, e.g., in a default function argument.
Decl *ManglingContextDecl;

/// The context information used to mangle lambda expressions
/// and block literals within this context.
///
/// This mangling information is allocated lazily, since most contexts
/// do not have lambda expressions or block literals.
std::unique_ptr<MangleNumberingContext> MangleNumbering;

/// If we are processing a decltype type, a set of call expressions
/// for which we have deferred checking the completeness of the return type.
SmallVector<CallExpr *, 8> DelayedDecltypeCalls;
Expand Down Expand Up @@ -1202,12 +1195,7 @@ class Sema {
ExpressionKind ExprContext)
: Context(Context), ParentCleanup(ParentCleanup),
NumCleanupObjects(NumCleanupObjects), NumTypos(0),
ManglingContextDecl(ManglingContextDecl), MangleNumbering(),
ExprContext(ExprContext) {}

/// Retrieve the mangling numbering context, used to consistently
/// number constructs like lambdas for mangling.
MangleNumberingContext &getMangleNumberingContext(ASTContext &Ctx);
ManglingContextDecl(ManglingContextDecl), ExprContext(ExprContext) {}

bool isUnevaluated() const {
return Context == ExpressionEvaluationContext::Unevaluated ||
Expand Down
10 changes: 10 additions & 0 deletions clang/lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10270,6 +10270,16 @@ ASTContext::getManglingNumberContext(const DeclContext *DC) {
return *MCtx;
}

MangleNumberingContext &
ASTContext::getManglingNumberContext(NeedExtraManglingDecl_t, const Decl *D) {
assert(LangOpts.CPlusPlus); // We don't need mangling numbers for plain C.
std::unique_ptr<MangleNumberingContext> &MCtx =
ExtraMangleNumberingContexts[D];
if (!MCtx)
MCtx = createMangleNumberingContext();
return *MCtx;
}

std::unique_ptr<MangleNumberingContext>
ASTContext::createMangleNumberingContext() const {
return ABI->createMangleNumberingContext();
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/AST/Type.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,10 @@ ObjCTypeParamType::ObjCTypeParamType(const ObjCTypeParamDecl *D,
initialize(protocols);
}

QualType ObjCTypeParamType::desugar() const {
return getDecl()->getUnderlyingType();
}

ObjCObjectType::ObjCObjectType(QualType Canonical, QualType Base,
ArrayRef<QualType> typeArgs,
ArrayRef<ObjCProtocolDecl *> protocols,
Expand Down
6 changes: 6 additions & 0 deletions clang/lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14070,6 +14070,12 @@ Value *CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
ConvertType(E->getType()));
return Builder.CreateCall(Callee, {LHS, RHS});
}
case WebAssembly::BI__builtin_wasm_swizzle_v8x16: {
Value *Src = EmitScalarExpr(E->getArg(0));
Value *Indices = EmitScalarExpr(E->getArg(1));
Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_swizzle);
return Builder.CreateCall(Callee, {Src, Indices});
}
case WebAssembly::BI__builtin_wasm_extract_lane_s_i8x16:
case WebAssembly::BI__builtin_wasm_extract_lane_u_i8x16:
case WebAssembly::BI__builtin_wasm_extract_lane_s_i16x8:
Expand Down
11 changes: 11 additions & 0 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5351,11 +5351,22 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
MakeCLOutputFilename(C.getArgs(), "", BaseName, types::TY_Image);
} else {
SmallString<128> Output(getDefaultImageName());
// HIP image for device compilation with -fno-gpu-rdc is per compilation
// unit.
bool IsHIPNoRDC = JA.getOffloadingDeviceKind() == Action::OFK_HIP &&
!C.getArgs().hasFlag(options::OPT_fgpu_rdc,
options::OPT_fno_gpu_rdc, false);
if (IsHIPNoRDC) {
Output = BaseName;
llvm::sys::path::replace_extension(Output, "");
}
Output += OffloadingPrefix;
if (MultipleArchs && !BoundArch.empty()) {
Output += "-";
Output.append(BoundArch);
}
if (IsHIPNoRDC)
Output += ".out";
NamedOutput = C.getArgs().MakeArgString(Output.c_str());
}
} else if (JA.getType() == types::TY_PCH && IsCLMode()) {
Expand Down
1 change: 0 additions & 1 deletion clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6833,4 +6833,3 @@ void SPIRCheck::ConstructJob(Compilation &C, const JobAction &JA,
TCArgs.MakeArgString(getToolChain().GetProgramPath(getShortName())),
CheckArgs, None));
}

26 changes: 13 additions & 13 deletions clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1395,14 +1395,12 @@ void tools::AddHIPLinkerScript(const ToolChain &TC, Compilation &C,

// Create temporary linker script. Keep it if save-temps is enabled.
const char *LKS;
SmallString<256> Name = llvm::sys::path::filename(Output.getFilename());
std::string Name = llvm::sys::path::filename(Output.getFilename());
if (C.getDriver().isSaveTempsEnabled()) {
llvm::sys::path::replace_extension(Name, "lk");
LKS = C.getArgs().MakeArgString(Name.c_str());
LKS = C.getArgs().MakeArgString(Name + ".lk");
} else {
llvm::sys::path::replace_extension(Name, "");
Name = C.getDriver().GetTemporaryPath(Name, "lk");
LKS = C.addTempFile(C.getArgs().MakeArgString(Name.c_str()));
auto TmpName = C.getDriver().GetTemporaryPath(Name, "lk");
LKS = C.addTempFile(C.getArgs().MakeArgString(TmpName));
}

// Add linker script option to the command.
Expand All @@ -1420,11 +1418,13 @@ void tools::AddHIPLinkerScript(const ToolChain &TC, Compilation &C,
"Wrong platform");
(void)HIPTC;

// The output file name needs to persist through the compilation, therefore
// it needs to be created through MakeArgString.
std::string BundleFileName = C.getDriver().GetTemporaryPath("BUNDLE", "hipfb");
const char *BundleFile =
C.addTempFile(C.getArgs().MakeArgString(BundleFileName.c_str()));
const char *BundleFile;
if (C.getDriver().isSaveTempsEnabled()) {
BundleFile = C.getArgs().MakeArgString(Name + ".hipfb");
} else {
auto TmpName = C.getDriver().GetTemporaryPath(Name, "hipfb");
BundleFile = C.addTempFile(C.getArgs().MakeArgString(TmpName));
}
AMDGCN::constructHIPFatbinCommand(C, JA, BundleFile, DeviceInputs, Args, T);

// Add commands to embed target binaries. We ensure that each section and
Expand All @@ -1436,14 +1436,14 @@ void tools::AddHIPLinkerScript(const ToolChain &TC, Compilation &C,
LksStream << " *** Automatically generated by Clang ***\n";
LksStream << "*/\n";
LksStream << "TARGET(binary)\n";
LksStream << "INPUT(" << BundleFileName << ")\n";
LksStream << "INPUT(" << BundleFile << ")\n";
LksStream << "SECTIONS\n";
LksStream << "{\n";
LksStream << " .hip_fatbin :\n";
LksStream << " ALIGN(0x10)\n";
LksStream << " {\n";
LksStream << " PROVIDE_HIDDEN(__hip_fatbin = .);\n";
LksStream << " " << BundleFileName << "\n";
LksStream << " " << BundleFile << "\n";
LksStream << " }\n";
LksStream << " /DISCARD/ :\n";
LksStream << " {\n";
Expand Down
49 changes: 31 additions & 18 deletions clang/lib/Driver/ToolChains/HIP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,20 @@ static void addBCLib(const Driver &D, const ArgList &Args,
D.Diag(diag::err_drv_no_such_file) << BCName;
}

static const char *getOutputFileName(Compilation &C, StringRef Base,
const char *Postfix,
const char *Extension) {
const char *OutputFileName;
if (C.getDriver().isSaveTempsEnabled()) {
OutputFileName =
C.getArgs().MakeArgString(Base.str() + Postfix + "." + Extension);
} else {
std::string TmpName =
C.getDriver().GetTemporaryPath(Base.str() + Postfix, Extension);
OutputFileName = C.addTempFile(C.getArgs().MakeArgString(TmpName));
}
return OutputFileName;
}
} // namespace

const char *AMDGCN::Linker::constructLLVMLinkCommand(
Expand All @@ -61,10 +75,7 @@ const char *AMDGCN::Linker::constructLLVMLinkCommand(

// Add an intermediate output file.
CmdArgs.push_back("-o");
std::string TmpName =
C.getDriver().GetTemporaryPath(OutputFilePrefix.str() + "-linked", "bc");
const char *OutputFileName =
C.addTempFile(C.getArgs().MakeArgString(TmpName));
auto OutputFileName = getOutputFileName(C, OutputFilePrefix, "-linked", "bc");
CmdArgs.push_back(OutputFileName);
SmallString<128> ExecPath(C.getDriver().Dir);
llvm::sys::path::append(ExecPath, "llvm-link");
Expand Down Expand Up @@ -109,10 +120,8 @@ const char *AMDGCN::Linker::constructOptCommand(
}

OptArgs.push_back("-o");
std::string TmpFileName = C.getDriver().GetTemporaryPath(
OutputFilePrefix.str() + "-optimized", "bc");
const char *OutputFileName =
C.addTempFile(C.getArgs().MakeArgString(TmpFileName));
auto OutputFileName =
getOutputFileName(C, OutputFilePrefix, "-optimized", "bc");
OptArgs.push_back(OutputFileName);
SmallString<128> OptPath(C.getDriver().Dir);
llvm::sys::path::append(OptPath, "opt");
Expand All @@ -124,11 +133,13 @@ const char *AMDGCN::Linker::constructOptCommand(
const char *AMDGCN::Linker::constructLlcCommand(
Compilation &C, const JobAction &JA, const InputInfoList &Inputs,
const llvm::opt::ArgList &Args, llvm::StringRef SubArchName,
llvm::StringRef OutputFilePrefix, const char *InputFileName) const {
llvm::StringRef OutputFilePrefix, const char *InputFileName,
bool OutputIsAsm) const {
// Construct llc command.
ArgStringList LlcArgs{InputFileName, "-mtriple=amdgcn-amd-amdhsa",
"-filetype=obj",
Args.MakeArgString("-mcpu=" + SubArchName)};
ArgStringList LlcArgs{
InputFileName, "-mtriple=amdgcn-amd-amdhsa",
Args.MakeArgString(Twine("-filetype=") + (OutputIsAsm ? "asm" : "obj")),
Args.MakeArgString("-mcpu=" + SubArchName)};

// Extract all the -m options
std::vector<llvm::StringRef> Features;
Expand All @@ -151,10 +162,8 @@ const char *AMDGCN::Linker::constructLlcCommand(

// Add output filename
LlcArgs.push_back("-o");
std::string LlcOutputFileName =
C.getDriver().GetTemporaryPath(OutputFilePrefix, "o");
const char *LlcOutputFile =
C.addTempFile(C.getArgs().MakeArgString(LlcOutputFileName));
auto LlcOutputFile =
getOutputFileName(C, OutputFilePrefix, "", OutputIsAsm ? "s" : "o");
LlcArgs.push_back(LlcOutputFile);
SmallString<128> LlcPath(C.getDriver().Dir);
llvm::sys::path::append(LlcPath, "llc");
Expand Down Expand Up @@ -230,14 +239,18 @@ void AMDGCN::Linker::ConstructJob(Compilation &C, const JobAction &JA,
assert(StringRef(SubArchName).startswith("gfx") && "Unsupported sub arch");

// Prefix for temporary file name.
std::string Prefix =
llvm::sys::path::stem(Inputs[0].getFilename()).str() + "-" + SubArchName;
std::string Prefix = llvm::sys::path::stem(Inputs[0].getFilename()).str();
if (!C.getDriver().isSaveTempsEnabled())
Prefix += "-" + SubArchName;

// Each command outputs different files.
const char *LLVMLinkCommand =
constructLLVMLinkCommand(C, JA, Inputs, Args, SubArchName, Prefix);
const char *OptCommand = constructOptCommand(C, JA, Inputs, Args, SubArchName,
Prefix, LLVMLinkCommand);
if (C.getDriver().isSaveTempsEnabled())
constructLlcCommand(C, JA, Inputs, Args, SubArchName, Prefix, OptCommand,
/*OutputIsAsm=*/true);
const char *LlcCommand =
constructLlcCommand(C, JA, Inputs, Args, SubArchName, Prefix, OptCommand);
constructLldCommand(C, JA, Inputs, Output, Args, LlcCommand);
Expand Down
3 changes: 2 additions & 1 deletion clang/lib/Driver/ToolChains/HIP.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@ class LLVM_LIBRARY_VISIBILITY Linker : public Tool {
const llvm::opt::ArgList &Args,
llvm::StringRef SubArchName,
llvm::StringRef OutputFilePrefix,
const char *InputFileName) const;
const char *InputFileName,
bool OutputIsAsm = false) const;

void constructLldCommand(Compilation &C, const JobAction &JA,
const InputInfoList &Inputs, const InputInfo &Output,
Expand Down
Loading

0 comments on commit b5f1d79

Please sign in to comment.