Skip to content

Commit

Permalink
merge main into amd-staging
Browse files Browse the repository at this point in the history
Change-Id: I99bcb1456baa1b5efd3ffdfcb9fe57d1923359f7
  • Loading branch information
Jenkins committed Feb 21, 2024
2 parents c915d19 + f40ee6e commit 6dfd4ed
Show file tree
Hide file tree
Showing 143 changed files with 2,216 additions and 677 deletions.
5 changes: 1 addition & 4 deletions .ci/generate-buildkite-pipeline-premerge
Original file line number Diff line number Diff line change
Expand Up @@ -233,10 +233,7 @@ linux_projects=$(add-dependencies ${linux_projects_to_test} | sort | uniq)

windows_projects_to_test=$(exclude-windows $(compute-projects-to-test ${modified_projects}))
windows_check_targets=$(check-targets ${windows_projects_to_test} | sort | uniq)
# Temporary disable the windows job.
# See https://discourse.llvm.org/t/rfc-future-of-windows-pre-commit-ci/76840
#windows_projects=$(add-dependencies ${windows_projects_to_test} | sort | uniq)
windows_projects=""
windows_projects=$(add-dependencies ${windows_projects_to_test} | sort | uniq)

# Generate the appropriate pipeline
if [[ "${linux_projects}" != "" ]]; then
Expand Down
11 changes: 10 additions & 1 deletion .ci/monolithic-windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ targets="${2}"

echo "--- cmake"
pip install -q -r ${MONOREPO_ROOT}/mlir/python/requirements.txt

# The CMAKE_*_LINKER_FLAGS to disable the manifest come from research
# on fixing a build reliability issue on the build server, please
# see https://github.com/llvm/llvm-project/pull/82393 and
# https://discourse.llvm.org/t/rfc-future-of-windows-pre-commit-ci/76840/40
# for further information.
cmake -S ${MONOREPO_ROOT}/llvm -B ${BUILD_DIR} \
-D LLVM_ENABLE_PROJECTS="${projects}" \
-G Ninja \
Expand All @@ -49,7 +55,10 @@ cmake -S ${MONOREPO_ROOT}/llvm -B ${BUILD_DIR} \
-D COMPILER_RT_BUILD_ORC=OFF \
-D CMAKE_C_COMPILER_LAUNCHER=sccache \
-D CMAKE_CXX_COMPILER_LAUNCHER=sccache \
-D MLIR_ENABLE_BINDINGS_PYTHON=ON
-D MLIR_ENABLE_BINDINGS_PYTHON=ON \
-D CMAKE_EXE_LINKER_FLAGS="/MANIFEST:NO" \
-D CMAKE_MODULE_LINKER_FLAGS="/MANIFEST:NO" \
-D CMAKE_SHARED_LINKER_FLAGS="/MANIFEST:NO"

echo "--- ninja"
# Targets are not escaped as they are passed as separate arguments.
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/release-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
name: Create a New Release
runs-on: ubuntu-latest
needs: validate-tag

steps:
- name: Install Dependencies
run: |
Expand All @@ -40,8 +41,9 @@ jobs:
- name: Create Release
env:
GITHUB_TOKEN: ${{ github.token }}
USER_TOKEN: ${{ secrets.RELEASE_TASKS_USER_TOKEN }}
run: |
./llvm/utils/release/./github-upload-release.py --token "$GITHUB_TOKEN" --release ${{ needs.validate-tag.outputs.release-version }} --user ${{ github.actor }} create
./llvm/utils/release/./github-upload-release.py --token "$GITHUB_TOKEN" --release ${{ needs.validate-tag.outputs.release-version }} --user ${{ github.actor }} --user-token "$USER_TOKEN" create
release-documentation:
name: Build and Upload Release Documentation
needs:
Expand Down
1 change: 1 addition & 0 deletions clang/docs/LanguageExtensions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,7 @@ to ``float``; see below for more information on this emulation.
* 32-bit ARM (natively on some architecture versions)
* 64-bit ARM (AArch64) (natively on ARMv8.2a and above)
* AMDGPU (natively)
* NVPTX (natively)
* SPIR (natively)
* X86 (if SSE2 is available; natively if AVX512-FP16 is also available)
* RISC-V (natively if Zfh or Zhinx is available)
Expand Down
10 changes: 10 additions & 0 deletions clang/include/clang/Driver/Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,11 @@ class Driver {
/// from non-system headers are emitted.
HeaderIncludeFilteringKind CCPrintHeadersFiltering = HIFIL_None;

/// Name of the library that provides implementations of
/// IEEE-754 128-bit float math functions used by Fortran F128
/// runtime library. It should be linked as needed by the linker job.
std::string FlangF128MathLibrary;

/// Set CC_LOG_DIAGNOSTICS mode, which causes the frontend to log diagnostics
/// to CCLogDiagnosticsFilename or to stderr, in a stable machine readable
/// format.
Expand Down Expand Up @@ -446,6 +451,11 @@ class Driver {
bool offloadHostOnly() const { return Offload == OffloadHost; }
bool offloadDeviceOnly() const { return Offload == OffloadDevice; }

void setFlangF128MathLibrary(std::string name) {
FlangF128MathLibrary = std::move(name);
}
StringRef getFlangF128MathLibrary() const { return FlangF128MathLibrary; }

/// Compute the desired OpenMP runtime from the flags provided.
OpenMPRuntimeKind getOpenMPRuntime(const llvm::opt::ArgList &Args) const;

Expand Down
4 changes: 4 additions & 0 deletions clang/lib/Basic/Targets/NVPTX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ NVPTXTargetInfo::NVPTXTargetInfo(const llvm::Triple &Triple,
NoAsmVariants = true;
GPU = CudaArch::UNUSED;

// PTX supports f16 as a fundamental type.
HasLegalHalfType = true;
HasFloat16 = true;

if (TargetPointerWidth == 32)
resetDataLayout("e-p:32:32-i64:64-i128:128-v16:16-v32:32-n16:32:64");
else if (Opts.NVPTXUseShortPointers)
Expand Down
11 changes: 1 addition & 10 deletions clang/lib/Driver/ToolChains/BareMetal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,11 +368,7 @@ void BareMetal::AddLinkRuntimeLib(const ArgList &Args,
ToolChain::RuntimeLibType RLT = GetRuntimeLibType(Args);
switch (RLT) {
case ToolChain::RLT_CompilerRT: {
const std::string FileName = getCompilerRT(Args, "builtins");
llvm::StringRef BaseName = llvm::sys::path::filename(FileName);
BaseName.consume_front("lib");
BaseName.consume_back(".a");
CmdArgs.push_back(Args.MakeArgString("-l" + BaseName));
CmdArgs.push_back(getCompilerRTArgString(Args, "builtins"));
return;
}
case ToolChain::RLT_Libgcc:
Expand Down Expand Up @@ -462,11 +458,6 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA,
for (const auto &LibPath : TC.getLibraryPaths())
CmdArgs.push_back(Args.MakeArgString(llvm::Twine("-L", LibPath)));

const std::string FileName = TC.getCompilerRT(Args, "builtins");
llvm::SmallString<128> PathBuf{FileName};
llvm::sys::path::remove_filename(PathBuf);
CmdArgs.push_back(Args.MakeArgString("-L" + PathBuf));

if (TC.ShouldLinkCXXStdlib(Args))
TC.AddCXXStdlibLibArgs(Args, CmdArgs);

Expand Down
8 changes: 8 additions & 0 deletions clang/lib/Driver/ToolChains/CommonArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1396,6 +1396,14 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
// add the correct libraries to link against as dependents in the object
// file.
if (!TC.getTriple().isKnownWindowsMSVCEnvironment()) {
StringRef f128LibName = TC.getDriver().getFlangF128MathLibrary();
f128LibName.consume_front_insensitive("lib");
if (!f128LibName.empty()) {
CmdArgs.push_back("-lFortranFloat128Math");
addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/true);
CmdArgs.push_back(Args.MakeArgString("-l" + f128LibName));
addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false);
}
CmdArgs.push_back("-lFortranRuntime");
CmdArgs.push_back("-lFortranDecimal");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ class UncountedCallArgsChecker
if (!Callee)
return false;

if (isMethodOnWTFContainerType(Callee))
return true;

auto overloadedOperatorType = Callee->getOverloadedOperator();
if (overloadedOperatorType == OO_EqualEqual ||
overloadedOperatorType == OO_ExclaimEqual ||
Expand Down Expand Up @@ -198,6 +201,31 @@ class UncountedCallArgsChecker
return false;
}

bool isMethodOnWTFContainerType(const FunctionDecl *Decl) const {
if (!isa<CXXMethodDecl>(Decl))
return false;
auto *ClassDecl = Decl->getParent();
if (!ClassDecl || !isa<CXXRecordDecl>(ClassDecl))
return false;

auto *NsDecl = ClassDecl->getParent();
if (!NsDecl || !isa<NamespaceDecl>(NsDecl))
return false;

auto MethodName = safeGetName(Decl);
auto ClsNameStr = safeGetName(ClassDecl);
StringRef ClsName = ClsNameStr; // FIXME: Make safeGetName return StringRef.
auto NamespaceName = safeGetName(NsDecl);
// FIXME: These should be implemented via attributes.
return NamespaceName == "WTF" &&
(MethodName == "find" || MethodName == "findIf" ||
MethodName == "reverseFind" || MethodName == "reverseFindIf" ||
MethodName == "get" || MethodName == "inlineGet" ||
MethodName == "contains" || MethodName == "containsIf") &&
(ClsName.ends_with("Vector") || ClsName.ends_with("Set") ||
ClsName.ends_with("Map"));
}

void reportBug(const Expr *CallArg, const ParmVarDecl *Param) const {
assert(CallArg);

Expand Down
146 changes: 146 additions & 0 deletions clang/test/Analysis/Checkers/WebKit/call-args-wtf-containers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
// RUN: %clang_analyze_cc1 -analyzer-checker=alpha.webkit.UncountedCallArgsChecker -verify %s

#include "mock-types.h"

namespace WTF {

template <typename T>
class HashSet {
public:
template <typename U> T* find(U&) const;
template <typename U> bool contains(U&) const;
unsigned size() { return m_size; }
template <typename U> void add(U&) const;
template <typename U> void remove(U&) const;

private:
T* m_table { nullptr };
unsigned m_size { 0 };
};

template <typename T, typename S>
class HashMap {
public:
struct Item {
T key;
S value;
};

template <typename U> Item* find(U&) const;
template <typename U> bool contains(U&) const;
template <typename U> S* get(U&) const;
template <typename U> S* inlineGet(U&) const;
template <typename U> void add(U&) const;
template <typename U> void remove(U&) const;

private:
Item* m_table { nullptr };
};

template <typename T>
class WeakHashSet {
public:
template <typename U> T* find(U&) const;
template <typename U> bool contains(U&) const;
template <typename U> void add(U&) const;
template <typename U> void remove(U&) const;
};

template <typename T>
class Vector {
public:
unsigned size() { return m_size; }
T& at(unsigned i) { return m_buffer[i]; }
T& operator[](unsigned i) { return m_buffer[i]; }
template <typename U> unsigned find(U&);
template <typename U> unsigned reverseFind(U&);
template <typename U> bool contains(U&);
template <typename MatchFunction> unsigned findIf(const MatchFunction& match)
{
for (unsigned i = 0; i < m_size; ++i) {
if (match(at(i)))
return i;
}
return static_cast<unsigned>(-1);
}
template <typename MatchFunction> unsigned reverseFindIf(const MatchFunction& match)
{
for (unsigned i = 0; i < m_size; ++i) {
if (match(at(m_size - i)))
return i;
}
return static_cast<unsigned>(-1);
}
template <typename MatchFunction> bool containsIf(const MatchFunction& match)
{
for (unsigned i = 0; i < m_size; ++i) {
if (match(at(m_size - i)))
return true;
}
return false;
}
template <typename U> void append(U&) const;
template <typename U> void remove(U&) const;

private:
T* m_buffer { nullptr };
unsigned m_size { 0 };
};

}

using WTF::HashSet;
using WTF::HashMap;
using WTF::WeakHashSet;
using WTF::Vector;

class RefCounted {
public:
void ref() const;
void deref() const;
};

RefCounted* object();

void test() {
HashSet<RefPtr<RefCounted>> set;
set.find(*object());
set.contains(*object());
set.add(*object());
// expected-warning@-1{{Call argument is uncounted and unsafe}}
set.remove(*object());
// expected-warning@-1{{Call argument is uncounted and unsafe}}

HashMap<Ref<RefCounted>, unsigned> map;
map.find(*object());
map.contains(*object());
map.inlineGet(*object());
map.add(*object());
// expected-warning@-1{{Call argument is uncounted and unsafe}}
map.remove(*object());
// expected-warning@-1{{Call argument is uncounted and unsafe}}

WeakHashSet<Ref<RefCounted>> weakSet;
weakSet.find(*object());
weakSet.contains(*object());
weakSet.add(*object());
// expected-warning@-1{{Call argument is uncounted and unsafe}}
weakSet.remove(*object());
// expected-warning@-1{{Call argument is uncounted and unsafe}}

Vector<Ref<RefCounted>> vector;
vector.at(0);
vector[0];
vector.find(*object());
vector.reverseFind(*object());
vector.contains(*object());
vector.append(*object());
// expected-warning@-1{{Call argument is uncounted and unsafe}}
vector.remove(*object());
// expected-warning@-1{{Call argument is uncounted and unsafe}}

auto* obj = object();
vector.findIf([&](Ref<RefCounted> key) { return key.ptr() == obj; });
vector.reverseFindIf([&](Ref<RefCounted> key) { return key.ptr() == obj; });
vector.containsIf([&](Ref<RefCounted> key) { return key.ptr() == obj; });
}
2 changes: 1 addition & 1 deletion clang/test/Driver/arm-compiler-rt.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
// RUN: -rtlib=compiler-rt -### %s 2>&1 \
// RUN: | FileCheck %s -check-prefix ARM-EABI
// ARM-EABI: "-lclang_rt.builtins-arm"
// ARM-EABI: "{{[^"]*}}libclang_rt.builtins-arm.a"

// RUN: %clang -target arm-linux-gnueabi \
// RUN: --sysroot=%S/Inputs/resource_dir_with_arch_subdir \
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Driver/baremetal-multilib.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# CHECK-SAME: "-x" "c++" "{{.*}}baremetal-multilib.yaml"
# CHECK-NEXT: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic"
# CHECK-SAME: "-L[[SYSROOT]]/bin/../lib/clang-runtimes/arm-none-eabi/thumb/v8-m.main/fp/lib"
# CHECK-SAME: "-lc" "-lm" "-lclang_rt.builtins"
# CHECK-SAME: "-lc" "-lm" "{{[^"]*}}libclang_rt.builtins.a"
# CHECK-SAME: "-o" "{{.*}}.tmp.out"

# RUN: %T/baremetal_multilib/bin/clang -no-canonical-prefixes -x c++ %s -### -o %t.out 2>&1 \
Expand Down
2 changes: 1 addition & 1 deletion clang/test/Driver/baremetal-sysroot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
// CHECK-V6M-C-SAME: "-x" "c++" "{{.*}}baremetal-sysroot.cpp"
// CHECK-V6M-C-NEXT: "{{[^"]*}}ld{{(\.(lld|bfd|gold))?}}{{(\.exe)?}}" "{{.*}}.o" "-Bstatic"
// CHECK-V6M-C-SAME: "-L{{.*}}/baremetal_default_sysroot{{[/\\]+}}bin{{[/\\]+}}..{{[/\\]+}}lib{{[/\\]+}}clang-runtimes{{[/\\]+}}armv6m-none-eabi{{[/\\]+}}lib"
// CHECK-V6M-C-SAME: "-lc" "-lm" "-lclang_rt.builtins-armv6m"
// CHECK-V6M-C-SAME: "-lc" "-lm" "{{[^"]*}}libclang_rt.builtins-armv6m.a"
// CHECK-V6M-C-SAME: "-o" "{{.*}}.o"
Loading

0 comments on commit 6dfd4ed

Please sign in to comment.