Skip to content

Commit

Permalink
WIP: Merge with LLVM 18.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Tarun Prabhu committed Aug 1, 2024
1 parent 6de8a17 commit 640c85d
Show file tree
Hide file tree
Showing 107 changed files with 1,630 additions and 2,064 deletions.
12 changes: 8 additions & 4 deletions clang/include/clang-c/Index.h
Original file line number Diff line number Diff line change
Expand Up @@ -2136,21 +2136,25 @@ enum CXCursorKind {
*/
CXCursor_OMPErrorDirective = 305,

/** OpenMP scope directive.
*/
CXCursor_OMPScopeDirective = 306,

/** Kitsune forall statement.
*/
CXCursor_ForallStmt = 306,
CXCursor_ForallStmt = 307,

/** Kitsune range-based forall statement.
*/
CXCursor_CXXForallRangeStmt = 307,
CXCursor_CXXForallRangeStmt = 308,

/** Kitsune spawn statement.
*/
CXCursor_SpawnStmt = 308,
CXCursor_SpawnStmt = 309,

/** Kitsune sync statement.
*/
CXCursor_SyncStmt = 309,
CXCursor_SyncStmt = 310,

CXCursor_LastStmt = CXCursor_SyncStmt,

Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Basic/Attr.td
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.td - attribute definitions -----------------------------------===//
//==--- Attr.td - attribute definitions -----------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
Expand Down
4 changes: 0 additions & 4 deletions clang/include/clang/Basic/DiagnosticDriverKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -808,10 +808,6 @@ def err_drv_kitsune_unsupported: Error<
// give opencilk any special treatment here.
def err_drv_opencilk_missing_abi_bitcode: Error<
"Cannot find OpenCilk runtime ABI bitcode file: %0">;
def err_drv_opencilk_resource_dir_missing_include: Error<
"No include directory in OpenCilk resource directory: %0">;
def err_drv_opencilk_resource_dir_missing_lib: Error<
"No lib directory in OpenCilk resource directory: %0">;

def err_drv_mix_tapir_cuda_hip : Error<
"Mixed Tapir and Cuda/HIP compilation is currently not supported.">;
Expand Down
25 changes: 9 additions & 16 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -3163,34 +3163,31 @@ def fno_knr_functions : Flag<["-"], "fno-knr-functions">, Group<f_Group>,
Visibility<[ClangOption, CC1Option, CLOption]>;

def config_kitsune_dir_EQ : Joined<["--"], "config-kitsune-dir=">,
Flags<[NoXarchOption, CoreOption, HelpHidden]>,
Flags<[NoXarchOption, HelpHidden]>,
Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
HelpText<"Kitsune directory for configuration files">;
def fkokkos : Flag<["-"], "fkokkos">, Group<f_Group>,
Flags<[CC1Option, NoArgumentUnused]>,
Flags<[NoArgumentUnused]>,
Visibility<[ClangOption, CC1Option]>,
HelpText<"Enable Kokkos extensions: recognition and custom code generation">;
def fkokkos_no_init : Flag<["-"], "fkokkos-no-init">, Group<f_Group>,
Flags<[CC1Option, NoArgumentUnused]>,
Flags<[NoArgumentUnused]>,
Visibility<[ClangOption, CC1Option]>,
HelpText<"Skip code gen of Kokkos initialization (and finalize) calls.">;
def ftapir_EQ : Joined<["-"], "ftapir=">, Group<f_Group>,
Flags<[CC1Option]>,
Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
MetaVarName<"<target>">,
HelpText<"Choose the backend parallel runtime for Tapir instructions">,
Values<"none,serial,cuda,hip,opencilk,openmp,qthreads,realm">;
def ftapir_nvarch_EQ : Joined<["-"], "ftapir-nvarch=">, Group<f_Group>,
Flags<[CC1Option]>,
Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
HelpText<"Choose the target nvida gpu architecture (e.g., sm_80) for gpu and cuda backend runtimes">,
Values<"sm_50,sm_52,sm_53,sm_60,sm_61,sm_62,sm_70,sm_72,sm_75,sm_80,sm_86,sm_90">;
def fstripmine : Flag<["-"], "fstripmine">, Group<f_Group>,
HelpText<"Enable the Tapir loop stripmining passes">;
def fno_stripmine : Flag<["-"], "fno-stripmine">, Group<f_Group>;

// KITSUNE FIXME: Should remove this because we don't want to support
// customizing the OpenCilk paths.
def opencilk_resource_dir_EQ : Joined<["--"], "opencilk-resource-dir=">,
Flags<[NoXarchOption]>,
HelpText<"The directory that holds OpenCilk resource files">;
def opencilk_abi_bitcode_EQ : Joined<["--"], "opencilk-abi-bitcode=">,
Flags<[CC1Option]>, HelpText<"Path to OpenCilk ABI bitcode file">,
Visibility<[CC1Option]>, HelpText<"Path to OpenCilk ABI bitcode file">,
MarshallingInfoString<CodeGenOpts<"OpenCilkABIBitcodeFile">>;

def fmudflapth : Flag<["-"], "fmudflapth">, Group<f_Group>;
Expand Down Expand Up @@ -6200,7 +6197,6 @@ defm caller_saves : BooleanFFlag<"caller-saves">, Group<clang_ignored_gcc_optimi
defm reorder_blocks : BooleanFFlag<"reorder-blocks">, Group<clang_ignored_gcc_optimization_f_Group>;
defm branch_count_reg : BooleanFFlag<"branch-count-reg">, Group<clang_ignored_gcc_optimization_f_Group>;
defm default_inline : BooleanFFlag<"default-inline">, Group<clang_ignored_gcc_optimization_f_Group>;
defm fat_lto_objects : BooleanFFlag<"fat-lto-objects">, Group<clang_ignored_gcc_optimization_f_Group>;
defm float_store : BooleanFFlag<"float-store">, Group<clang_ignored_gcc_optimization_f_Group>;
defm friend_injection : BooleanFFlag<"friend-injection">, Group<clang_ignored_f_Group>;
defm function_attribute_list : BooleanFFlag<"function-attribute-list">, Group<clang_ignored_f_Group>;
Expand Down Expand Up @@ -6963,9 +6959,6 @@ def vectorize_slp : Flag<["-"], "vectorize-slp">,
def stripmine_loops : Flag<["-"], "stripmine-loops">,
HelpText<"Run the Tapir Loop stripmining passes">,
MarshallingInfoFlag<CodeGenOpts<"StripmineLoop">>;
def dependent_lib : Joined<["--"], "dependent-lib=">,
HelpText<"Add dependent library">,
MarshallingInfoStringVector<CodeGenOpts<"DependentLibraries">>;
def linker_option : Joined<["--"], "linker-option=">,
HelpText<"Add linker option">,
MarshallingInfoStringVector<CodeGenOpts<"LinkerOptions">>;
Expand Down
13 changes: 2 additions & 11 deletions clang/include/clang/Driver/ToolChain.h
Original file line number Diff line number Diff line change
Expand Up @@ -824,13 +824,9 @@ class ToolChain {
virtual void AddKitsuneLinkerArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const;

/// Check the specified OpenCilk resource directory is valid.
virtual void AddOpenCilkIncludeDir(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const;

/// Get the OpenCilk library path if it exists.
virtual path_list
getOpenCilkRuntimePaths(const llvm::opt::ArgList &Args) const;
virtual std::optional<std::string>
getOpenCilkRuntimePath(const llvm::opt::ArgList &Args) const;

virtual std::string getOpenCilkBCBasename(const llvm::opt::ArgList &Args,
StringRef Component,
Expand All @@ -851,11 +847,6 @@ class ToolChain {
virtual void AddOpenCilkABIBitcode(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs,
bool IsLTO = false) const;

/// AddTapirRuntimeLibArgs - Add the specific linker arguments to use for the
/// given Tapir runtime library type.
virtual void AddTapirRuntimeLibArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const;
};

/// Set a ToolChain's effective triple. Reset it when the registration object
Expand Down
3 changes: 0 additions & 3 deletions clang/lib/AST/ExprConstant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11654,7 +11654,6 @@ GCCTypeClass EvaluateBuiltinClassifyType(QualType T,
return EvaluateBuiltinClassifyType(
CanTy->castAs<AtomicType>()->getValueType(), LangOpts);

case Type::BlockPointer:
case Type::Vector:
case Type::ExtVector:
return GCCTypeClass::Vector;
Expand Down Expand Up @@ -15800,8 +15799,6 @@ bool Expr::EvaluateAsInitializer(APValue &Value, const ASTContext &Ctx,
llvm_unreachable("Unhandled cleanup; missing full expression marker?");
}

SourceLocation DeclLoc = VD->getLocation();
QualType DeclTy = VD->getType();
return CheckConstantExpression(Info, DeclLoc, DeclTy, Value,
ConstantExprKind::Normal) &&
CheckMemoryLeaks(Info);
Expand Down
59 changes: 14 additions & 45 deletions clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,43 +280,11 @@ static bool asanUseGlobalsGC(const Triple &T, const CodeGenOptions &CGOpts) {
return false;
}

static TargetLibraryInfoImpl *createTLII(llvm::Triple &TargetTriple,
const CodeGenOptions &CodeGenOpts,
const LangOptions &LangOpts) {
TargetLibraryInfoImpl *TLII = new TargetLibraryInfoImpl(TargetTriple);

switch (CodeGenOpts.getVecLib()) {
case CodeGenOptions::Accelerate:
TLII->addVectorizableFunctionsFromVecLib(TargetLibraryInfoImpl::Accelerate,
TargetTriple);
break;
case CodeGenOptions::LIBMVEC:
TLII->addVectorizableFunctionsFromVecLib(TargetLibraryInfoImpl::LIBMVEC_X86,
TargetTriple);
break;
case CodeGenOptions::MASSV:
TLII->addVectorizableFunctionsFromVecLib(TargetLibraryInfoImpl::MASSV,
TargetTriple);
break;
case CodeGenOptions::SVML:
TLII->addVectorizableFunctionsFromVecLib(TargetLibraryInfoImpl::SVML,
TargetTriple);
break;
case CodeGenOptions::SLEEF:
TLII->addVectorizableFunctionsFromVecLib(TargetLibraryInfoImpl::SLEEFGNUABI,
TargetTriple);
break;
case CodeGenOptions::Darwin_libsystem_m:
TLII->addVectorizableFunctionsFromVecLib(
TargetLibraryInfoImpl::DarwinLibSystemM, TargetTriple);
break;
case CodeGenOptions::ArmPL:
TLII->addVectorizableFunctionsFromVecLib(TargetLibraryInfoImpl::ArmPL,
TargetTriple);
break;
default:
break;
}
static std::unique_ptr<TargetLibraryInfoImpl>
createTLII(llvm::Triple &TargetTriple, const CodeGenOptions &CodeGenOpts,
const LangOptions &LangOpts) {
std::unique_ptr<TargetLibraryInfoImpl> TLII(
llvm::driver::createTLII(TargetTriple, CodeGenOpts.getVecLib()));

TLII->setTapirTarget(LangOpts.KitsuneOpts.getTapirTargetOrInvalid());
TLII->setTapirTargetOptions(
Expand Down Expand Up @@ -614,7 +582,7 @@ bool EmitAssemblyHelper::AddEmitPasses(legacy::PassManager &CodeGenPasses,
raw_pwrite_stream *DwoOS) {
// Add LibraryInfo.
std::unique_ptr<TargetLibraryInfoImpl> TLII(
llvm::driver::createTLII(TargetTriple, CodeGenOpts.getVecLib()));
createTLII(TargetTriple, CodeGenOpts, LangOpts));
CodeGenPasses.add(new TargetLibraryInfoWrapperPass(*TLII));

// Normal mode, emit a .s or .o file by running the code generator. Note,
Expand Down Expand Up @@ -948,7 +916,7 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
// Register the target library analysis directly and give it a customized
// preset TLI.
std::unique_ptr<TargetLibraryInfoImpl> TLII(
llvm::driver::createTLII(TargetTriple, CodeGenOpts.getVecLib()));
createTLII(TargetTriple, CodeGenOpts, LangOpts));
FAM.registerPass([&] { return TargetLibraryAnalysis(*TLII); });

// Register all the basic analyses with the managers.
Expand Down Expand Up @@ -1070,20 +1038,21 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
});
#endif // 0

if (CodeGenOpts.OptimizationLevel == 0) {
MPM.addPass(PB.buildO0DefaultPipeline(Level, IsLTO || IsThinLTO,
TLII->hasTapirTarget()));
} else if (CodeGenOpts.FatLTO) {
if (CodeGenOpts.FatLTO) {
MPM.addPass(PB.buildFatLTODefaultPipeline(
Level, PrepareForThinLTO,
PrepareForThinLTO || shouldEmitRegularLTOSummary()));
} else if (CodeGenOpts.OptimizationLevel == 0) {
MPM.addPass(PB.buildO0DefaultPipeline(
Level, PrepareForLTO || PrepareForThinLTO, TLII->hasTapirTarget()));
} else if (PrepareForThinLTO) {
MPM.addPass(PB.buildThinLTOPreLinkDefaultPipeline(Level));
} else if (PrepareForLTO) {
MPM.addPass(PB.buildLTOPreLinkDefaultPipeline(Level));
} else {
MPM.addPass(PB.buildPerModuleDefaultPipeline(Level),
/* LTOPreLink */ false, TLII->hasTapirTarget());
MPM.addPass(PB.buildPerModuleDefaultPipeline(Level,
/* LTOPreLink */ false,
TLII->hasTapirTarget()));
}
}

Expand Down
1 change: 1 addition & 0 deletions clang/lib/CodeGen/CGBuiltin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5190,6 +5190,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
}
MaybeDetach(this, SpawnedScp);


llvm::Value *Carry;
llvm::Value *Sum = EmitOverflowIntrinsic(*this, IntrinsicId, X, Y, Carry);
Builder.CreateStore(Sum, SumOutPtr);
Expand Down
6 changes: 1 addition & 5 deletions clang/lib/CodeGen/CGCleanup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1107,17 +1107,13 @@ bool CodeGenFunction::isObviouslyBranchWithoutCleanups(JumpDest Dest) const {
/// be known, in which case this will require a fixup.
///
/// As a side-effect, this method clears the insertion point.
void CodeGenFunction::EmitBranchThroughCleanup(JumpDest Dest, bool AfterSync) {
void CodeGenFunction::EmitBranchThroughCleanup(JumpDest Dest) {
assert(Dest.getScopeDepth().encloses(EHStack.stable_begin())
&& "stale jump destination");

if (!HaveInsertPoint())
return;

// If needed, insert an implicit _Cilk_sync before the cleanups.
if (AfterSync)
EmitImplicitSyncCleanup();

// Create the branch.
llvm::BranchInst *BI = Builder.CreateBr(Dest.getBlock());

Expand Down
31 changes: 10 additions & 21 deletions clang/lib/CodeGen/CGException.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -620,27 +620,16 @@ void CodeGenFunction::EmitEndEHSpec(const Decl *D) {
}

void CodeGenFunction::EmitCXXTryStmt(const CXXTryStmt &S) {
TaskFrameScope TFScope(*this);
EnterCXXTryStmt(S);
{
// If compiling Cilk code, create a nested sync region, with an implicit
// sync, for the try-catch.
// FIXME KITSUNE: Since we know that we will not be compiling Cilk, can we
// clean this up.
bool CompilingCilk = false;
SyncedScopeRAII SyncedScp(*this);
if (CompilingCilk) {
PushSyncRegion();
if (isa<CompoundStmt>(S.getTryBlock()))
ScopeIsSynced = true;
}
EmitStmt(S.getTryBlock());

// Pop the nested sync region after the try block.
if (CompilingCilk)
PopSyncRegion();
}
ExitCXXTryStmt(S);
const llvm::Triple &T = Target.getTriple();
// If we encounter a try statement on in an OpenMP target region offloaded to
// a GPU, we treat it as a basic block.
const bool IsTargetDevice =
(CGM.getLangOpts().OpenMPIsTargetDevice && (T.isNVPTX() || T.isAMDGCN()));
if (!IsTargetDevice)
EnterCXXTryStmt(S);
EmitStmt(S.getTryBlock());
if (!IsTargetDevice)
ExitCXXTryStmt(S);
}

void CodeGenFunction::EnterCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock) {
Expand Down
6 changes: 1 addition & 5 deletions clang/lib/CodeGen/CGStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,6 @@ CodeGenFunction::EmitCompoundStmtWithoutScope(const CompoundStmt &S,
} else if (const auto *AS = dyn_cast<AttributedStmt>(ExprResult)) {
// FIXME: Update this if we ever have attributes that affect the
// semantics of an expression.
llvm::errs() << "we are here with an attributed expression...\n";
ExprResult = AS->getSubStmt();
} else {
llvm_unreachable("unknown value statement");
Expand Down Expand Up @@ -1432,10 +1431,7 @@ void CodeGenFunction::EmitReturnStmt(const ReturnStmt &S) {
PopDetachScope();
}

// FIXME KITSUNE: Can we clean up this API since we know that we will never be
// compiling Cilk?
bool CompilingCilk = false;
EmitBranchThroughCleanup(ReturnBlock, CompilingCilk);
EmitBranchThroughCleanup(ReturnBlock);
}

void CodeGenFunction::EmitDeclStmt(const DeclStmt &S) {
Expand Down
Loading

0 comments on commit 640c85d

Please sign in to comment.