Skip to content

Commit

Permalink
Merge from 'main' to 'sycl-web' (35 commits)
Browse files Browse the repository at this point in the history
  CONFLICT (content): Merge conflict in clang/lib/CodeGen/BackendUtil.cpp
  • Loading branch information
mdfazlay committed Jan 24, 2024
2 parents dbe2a91 + 9d476e1 commit 8017632
Show file tree
Hide file tree
Showing 97 changed files with 2,331 additions and 1,028 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/libcxx-build-and-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ on:
- 'cmake/**'
- '.github/workflows/libcxx-build-and-test.yaml'
schedule:
# Run nightly at 8 AM UTC (or roughly 3 AM eastern)
- cron: '0 3 * * *'
# Run nightly at 08:00 UTC (aka 00:00 Pacific, aka 03:00 Eastern)
- cron: '0 8 * * *'

permissions:
contents: read # Default everything to read-only
Expand Down
73 changes: 57 additions & 16 deletions clang/cmake/caches/Release.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,53 @@

# General Options
set(LLVM_RELEASE_ENABLE_LTO THIN CACHE STRING "")
set(LLVM_RELEASE_ENABLE_PGO ON CACHE BOOL "")

set(CMAKE_BUILD_TYPE RELEASE CACHE STRING "")

# Stage 1 Bootstrap Setup
set(CLANG_ENABLE_BOOTSTRAP ON CACHE BOOL "")
set(CLANG_BOOTSTRAP_TARGETS
clang
check-all
check-llvm
check-clang
test-suite
stage3
stage3-clang
stage3-check-all
stage3-check-llvm
stage3-check-clang
stage3-install
stage3-test-suite CACHE STRING "")
if (LLVM_RELEASE_ENABLE_PGO)
set(CLANG_BOOTSTRAP_TARGETS
generate-profdata
stage2
stage2-clang
stage2-distribution
stage2-install
stage2-install-distribution
stage2-install-distribution-toolchain
stage2-check-all
stage2-check-llvm
stage2-check-clang
stage2-test-suite CACHE STRING "")
else()
set(CLANG_BOOTSTRAP_TARGETS
clang
check-all
check-llvm
check-clang
test-suite
stage3
stage3-clang
stage3-check-all
stage3-check-llvm
stage3-check-clang
stage3-install
stage3-test-suite CACHE STRING "")
endif()

# Stage 1 Options
set(LLVM_ENABLE_PROJECTS "clang" CACHE STRING "")
set(STAGE1_PROJECTS "clang")
set(STAGE1_RUNTIMES "")

if (LLVM_RELEASE_ENABLE_PGO)
list(APPEND STAGE1_PROJECTS "lld")
list(APPEND STAGE1_RUNTIMES "compiler-rt")
endif()

set(LLVM_ENABLE_RUNTIMES ${STAGE1_RUNTIMES} CACHE STRING "")
set(LLVM_ENABLE_PROJECTS ${STAGE1_PROJECTS} CACHE STRING "")

set(LLVM_TARGETS_TO_BUILD Native CACHE STRING "")

# Stage 2 Bootstrap Setup
Expand All @@ -37,11 +63,26 @@ set(BOOTSTRAP_CLANG_BOOTSTRAP_TARGETS

# Stage 2 Options
set(STAGE2_PROJECTS "clang")
if (LLVM_RELEASE_ENABLE_LTO)
set(STAGE2_RUNTIMES "")

if (LLVM_RELEASE_ENABLE_LTO OR LLVM_RELEASE_ENABLE_PGO)
list(APPEND STAGE2_PROJECTS "lld")
endif()

if (LLVM_RELEASE_ENABLE_PGO)
set(BOOTSTRAP_LLVM_BUILD_INSTRUMENTED IR CACHE STRING "")
list(APPEND STAGE2_RUNTIMES "compiler-rt")
set(BOOTSTRAP_LLVM_ENABLE_LTO ${LLVM_RELEASE_ENABLE_LTO})
if (LLVM_RELEASE_ENABLE_LTO)
set(BOOTSTRAP_LLVM_ENABLE_LLD ON CACHE BOOL "")
endif()
endif()

set(BOOTSTRAP_LLVM_ENABLE_PROJECTS ${STAGE2_PROJECTS} CACHE STRING "")
set(BOOTSTRAP_LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
set(BOOTSTRAP_LLVM_ENABLE_RUNTIMES ${STAGE2_RUNTIMES} CACHE STRING "")
if (NOT LLVM_RELEASE_ENABLE_PGO)
set(BOOTSTRAP_LLVM_TARGETS_TO_BUILD Native CACHE STRING "")
endif()

# Stage 3 Options
set(BOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_RUNTIMES "compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "")
Expand Down
10 changes: 5 additions & 5 deletions clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1067,8 +1067,9 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
MPM.addPass(PB.buildO0DefaultPipeline(OptimizationLevel::O0,
PrepareForLTO || PrepareForThinLTO));
} else if (CodeGenOpts.FatLTO) {
assert(CodeGenOpts.UnifiedLTO && "FatLTO requires UnifiedLTO");
MPM.addPass(PB.buildFatLTODefaultPipeline(Level));
MPM.addPass(PB.buildFatLTODefaultPipeline(
Level, PrepareForThinLTO,
PrepareForThinLTO || shouldEmitRegularLTOSummary()));
} else if (PrepareForThinLTO) {
MPM.addPass(PB.buildThinLTOPreLinkDefaultPipeline(Level));
} else if (PrepareForLTO) {
Expand Down Expand Up @@ -1172,9 +1173,8 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
if (!TheModule->getModuleFlag("EnableSplitLTOUnit"))
TheModule->addModuleFlag(Module::Error, "EnableSplitLTOUnit",
uint32_t(CodeGenOpts.EnableSplitLTOUnit));
// FatLTO always means UnifiedLTO
if (!TheModule->getModuleFlag("UnifiedLTO"))
TheModule->addModuleFlag(Module::Error, "UnifiedLTO", uint32_t(1));
if (CodeGenOpts.UnifiedLTO && !TheModule->getModuleFlag("UnifiedLTO"))
TheModule->addModuleFlag(llvm::Module::Error, "UnifiedLTO", uint32_t(1));
}

// Print a textual, '-passes=' compatible, representation of pipeline if
Expand Down
4 changes: 1 addition & 3 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5546,9 +5546,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
bool UnifiedLTO = false;
if (IsUsingLTO) {
UnifiedLTO = Args.hasFlag(options::OPT_funified_lto,
options::OPT_fno_unified_lto, Triple.isPS()) ||
Args.hasFlag(options::OPT_ffat_lto_objects,
options::OPT_fno_fat_lto_objects, false);
options::OPT_fno_unified_lto, Triple.isPS());
if (UnifiedLTO)
CmdArgs.push_back("-funified-lto");
}
Expand Down
8 changes: 4 additions & 4 deletions clang/lib/Driver/ToolChains/Darwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -985,12 +985,12 @@ bool Darwin::hasBlocksRuntime() const {

void Darwin::AddCudaIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
CudaInstallation->AddCudaIncludeArgs(DriverArgs, CC1Args);
}

void Darwin::AddHIPIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
RocmInstallation.AddHIPIncludeArgs(DriverArgs, CC1Args);
RocmInstallation->AddHIPIncludeArgs(DriverArgs, CC1Args);
}

// This is just a MachO name translation routine and there's no
Expand Down Expand Up @@ -3436,6 +3436,6 @@ SanitizerMask Darwin::getSupportedSanitizers() const {
}

void Darwin::printVerboseInfo(raw_ostream &OS) const {
CudaInstallation.print(OS);
RocmInstallation.print(OS);
CudaInstallation->print(OS);
RocmInstallation->print(OS);
}
5 changes: 3 additions & 2 deletions clang/lib/Driver/ToolChains/Darwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_DARWIN_H

#include "Cuda.h"
#include "LazyDetector.h"
#include "ROCm.h"
#include "clang/Basic/DarwinSDKInfo.h"
#include "clang/Basic/LangOptions.h"
Expand Down Expand Up @@ -321,8 +322,8 @@ class LLVM_LIBRARY_VISIBILITY Darwin : public MachO {
/// The target variant triple that was specified (if any).
mutable std::optional<llvm::Triple> TargetVariantTriple;

CudaInstallationDetector CudaInstallation;
RocmInstallationDetector RocmInstallation;
LazyDetector<CudaInstallationDetector> CudaInstallation;
LazyDetector<RocmInstallationDetector> RocmInstallation;

private:
void AddDeploymentTarget(llvm::opt::DerivedArgList &Args) const;
Expand Down
10 changes: 5 additions & 5 deletions clang/lib/Driver/ToolChains/MSVC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -582,24 +582,24 @@ bool MSVCToolChain::isPICDefaultForced() const {

void MSVCToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
CudaInstallation->AddCudaIncludeArgs(DriverArgs, CC1Args);
}

void MSVCToolChain::AddHIPIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
RocmInstallation.AddHIPIncludeArgs(DriverArgs, CC1Args);
RocmInstallation->AddHIPIncludeArgs(DriverArgs, CC1Args);
}

void MSVCToolChain::AddHIPRuntimeLibArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
CmdArgs.append({Args.MakeArgString(StringRef("-libpath:") +
RocmInstallation.getLibPath()),
RocmInstallation->getLibPath()),
"amdhip64.lib"});
}

void MSVCToolChain::printVerboseInfo(raw_ostream &OS) const {
CudaInstallation.print(OS);
RocmInstallation.print(OS);
CudaInstallation->print(OS);
RocmInstallation->print(OS);
}

std::string
Expand Down
5 changes: 3 additions & 2 deletions clang/lib/Driver/ToolChains/MSVC.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "AMDGPU.h"
#include "Cuda.h"
#include "LazyDetector.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Tool.h"
#include "clang/Driver/ToolChain.h"
Expand Down Expand Up @@ -142,8 +143,8 @@ class LLVM_LIBRARY_VISIBILITY MSVCToolChain : public ToolChain {
std::optional<llvm::StringRef> WinSdkDir, WinSdkVersion, WinSysRoot;
std::string VCToolChainPath;
llvm::ToolsetLayout VSLayout = llvm::ToolsetLayout::OlderVS;
CudaInstallationDetector CudaInstallation;
RocmInstallationDetector RocmInstallation;
LazyDetector<CudaInstallationDetector> CudaInstallation;
LazyDetector<RocmInstallationDetector> RocmInstallation;
};

} // end namespace toolchains
Expand Down
8 changes: 4 additions & 4 deletions clang/lib/Driver/ToolChains/MinGW.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,17 +614,17 @@ SanitizerMask toolchains::MinGW::getSupportedSanitizers() const {

void toolchains::MinGW::AddCudaIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
CudaInstallation.AddCudaIncludeArgs(DriverArgs, CC1Args);
CudaInstallation->AddCudaIncludeArgs(DriverArgs, CC1Args);
}

void toolchains::MinGW::AddHIPIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
RocmInstallation.AddHIPIncludeArgs(DriverArgs, CC1Args);
RocmInstallation->AddHIPIncludeArgs(DriverArgs, CC1Args);
}

void toolchains::MinGW::printVerboseInfo(raw_ostream &OS) const {
CudaInstallation.print(OS);
RocmInstallation.print(OS);
CudaInstallation->print(OS);
RocmInstallation->print(OS);
}

// Include directories for various hosts:
Expand Down
5 changes: 3 additions & 2 deletions clang/lib/Driver/ToolChains/MinGW.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "Cuda.h"
#include "Gnu.h"
#include "LazyDetector.h"
#include "ROCm.h"
#include "clang/Driver/Tool.h"
#include "clang/Driver/ToolChain.h"
Expand Down Expand Up @@ -102,8 +103,8 @@ class LLVM_LIBRARY_VISIBILITY MinGW : public ToolChain {
Tool *buildAssembler() const override;

private:
CudaInstallationDetector CudaInstallation;
RocmInstallationDetector RocmInstallation;
LazyDetector<CudaInstallationDetector> CudaInstallation;
LazyDetector<RocmInstallationDetector> RocmInstallation;

std::string Base;
std::string GccLibDir;
Expand Down
14 changes: 0 additions & 14 deletions clang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1868,20 +1868,6 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args,
if (Args.hasArg(OPT_funified_lto))
Opts.PrepareForThinLTO = true;
}
if (Arg *A = Args.getLastArg(options::OPT_ffat_lto_objects,
options::OPT_fno_fat_lto_objects)) {
if (A->getOption().matches(options::OPT_ffat_lto_objects)) {
if (Arg *Uni = Args.getLastArg(options::OPT_funified_lto,
options::OPT_fno_unified_lto)) {
if (Uni->getOption().matches(options::OPT_fno_unified_lto))
Diags.Report(diag::err_drv_incompatible_options)
<< A->getAsString(Args) << "-fno-unified-lto";
} else
Diags.Report(diag::err_drv_argument_only_allowed_with)
<< A->getAsString(Args) << "-funified-lto";
}
}

if (Arg *A = Args.getLastArg(OPT_fthinlto_index_EQ)) {
if (IK.getLanguage() != Language::LLVM_IR)
Diags.Report(diag::err_drv_argument_only_allowed_with)
Expand Down
6 changes: 3 additions & 3 deletions clang/test/Analysis/malloc.mm
Original file line number Diff line number Diff line change
Expand Up @@ -116,17 +116,17 @@ void testUseAfterFree() {
}

void testNoCopy() {
char *p = (char *)calloc(sizeof(int), 1);
char *p = (char *)calloc(1, sizeof(int));
CustomData *w = [CustomData somethingNoCopy:p]; // no-warning
}

void testFreeWhenDone() {
char *p = (char *)calloc(sizeof(int), 1);
char *p = (char *)calloc(1, sizeof(int));
CustomData *w = [CustomData something:p freeWhenDone:1]; // no-warning
}

void testFreeWhenDonePositive() {
char *p = (char *)calloc(sizeof(int), 1);
char *p = (char *)calloc(1, sizeof(int));
CustomData *w = [CustomData something:p freeWhenDone:0]; // expected-warning{{leak}}
}

Expand Down
6 changes: 3 additions & 3 deletions clang/test/Analysis/uninit-vals.m
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ Point makePoint(float x, float y) {
}

void PR14765_test(void) {
Circle *testObj = calloc(sizeof(Circle), 1);
Circle *testObj = calloc(1, sizeof(Circle));

clang_analyzer_eval(testObj->size == 0); // expected-warning{{TRUE}}
// expected-note@-1{{TRUE}}
Expand Down Expand Up @@ -207,7 +207,7 @@ IntPoint makeIntPoint(int x, int y) {
}

void PR14765_test_int(void) {
IntCircle *testObj = calloc(sizeof(IntCircle), 1);
IntCircle *testObj = calloc(1, sizeof(IntCircle));

clang_analyzer_eval(testObj->size == 0); // expected-warning{{TRUE}}
// expected-note@-1{{TRUE}}
Expand Down Expand Up @@ -311,7 +311,7 @@ void testLargeStructsNotCopiedPerField(void) {
}

void testSmallStructInLargerStruct(void) {
IntCircle2D *testObj = calloc(sizeof(IntCircle2D), 1);
IntCircle2D *testObj = calloc(1, sizeof(IntCircle2D));

clang_analyzer_eval(testObj->size == 0); // expected-warning{{TRUE}}
// expected-note@-1{{TRUE}}
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CodeGen/alloc-size.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ void test5(void) {
// CHECK: store i32 36
gi = OBJECT_SIZE_BUILTIN(&data->t[1], 3);

struct Data *const arr = my_calloc(sizeof(*data), 2);
struct Data *const arr = my_calloc(2, sizeof(*data));
// CHECK: store i32 96
gi = OBJECT_SIZE_BUILTIN(arr, 0);
// CHECK: store i32 96
Expand Down Expand Up @@ -171,7 +171,7 @@ void test6(void) {
// CHECK: store i32 11
gi = OBJECT_SIZE_BUILTIN(data->end, 3);

struct Data *const arr = my_calloc(sizeof(*arr) + 5, 3);
struct Data *const arr = my_calloc(3, sizeof(*arr) + 5);
// AFAICT, GCC treats malloc and calloc identically. So, we should do the
// same.
//
Expand Down
Loading

0 comments on commit 8017632

Please sign in to comment.