Skip to content

Commit 895bae0

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:93fcef3048b4 into amd-gfx:78b534575bbe
Local branch amd-gfx 78b5345 Merged main:fc3ec135d34c into amd-gfx:5821ef850156 Remote branch main 93fcef3 [mlir][Vector] Add UB conversions to different tests and pipelines (llvm#125145)
2 parents 78b5345 + 93fcef3 commit 895bae0

File tree

91 files changed

+2953
-307
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+2953
-307
lines changed

.github/workflows/build-ci-container.yml

Lines changed: 39 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,31 @@ on:
2020
jobs:
2121
build-ci-container:
2222
if: github.repository_owner == 'llvm'
23-
runs-on: depot-ubuntu-22.04-16
24-
outputs:
25-
container-name: ${{ steps.vars.outputs.container-name }}
26-
container-name-agent: ${{ steps.vars.outputs.container-name-agent }}
27-
container-name-tag: ${{ steps.vars.outputs.container-name-tag }}
28-
container-name-agent-tag: ${{ steps.vars.outputs.container-name-agent-tag }}
29-
container-filename: ${{ steps.vars.outputs.container-filename }}
30-
container-agent-filename: ${{ steps.vars.outputs.container-agent-filename }}
23+
runs-on: ${{ matrix.runs-on }}
24+
strategy:
25+
matrix:
26+
include:
27+
# The arch names should match the names used on dockerhub.
28+
# See https://github.com/docker-library/official-images#architectures-other-than-amd64
29+
- arch: amd64
30+
runs-on: depot-ubuntu-22.04-16
31+
- arch: arm64v8
32+
runs-on: depot-ubuntu-22.04-arm-16
3133
steps:
3234
- name: Checkout LLVM
3335
uses: actions/checkout@v4
3436
with:
3537
sparse-checkout: .github/workflows/containers/github-action-ci/
38+
# podman is not installed by default on the ARM64 images.
39+
- name: Install Podman
40+
if: runner.arch == 'ARM64'
41+
run: |
42+
sudo apt-get install podman
3643
- name: Write Variables
3744
id: vars
3845
run: |
39-
tag=`date +%s`
40-
container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/ci-ubuntu-22.04"
46+
tag=$(git rev-parse --short=12 HEAD)
47+
container_name="ghcr.io/$GITHUB_REPOSITORY_OWNER/${{ matrix.arch }}/ci-ubuntu-22.04"
4148
echo "container-name=$container_name" >> $GITHUB_OUTPUT
4249
echo "container-name-agent=$container_name-agent" >> $GITHUB_OUTPUT
4350
echo "container-name-tag=$container_name:$tag" >> $GITHUB_OUTPUT
@@ -61,7 +68,7 @@ jobs:
6168
- name: Upload container image
6269
uses: actions/upload-artifact@v4
6370
with:
64-
name: container
71+
name: container-${{ matrix.arch }}
6572
path: "*.tar"
6673
retention-days: 14
6774

@@ -84,18 +91,29 @@ jobs:
8491
steps:
8592
- name: Download container
8693
uses: actions/download-artifact@v4
87-
with:
88-
name: container
8994

9095
- name: Push Container
9196
run: |
92-
podman load -i ${{ needs.build-ci-container.outputs.container-filename }}
93-
podman tag ${{ needs.build-ci-container.outputs.container-name-tag }} ${{ needs.build-ci-container.outputs.container-name }}:latest
97+
function push_container {
98+
image_name=$1
99+
latest_name=$(echo $image_name | sed 's/:[.0-9]\+$/:latest/g')
100+
podman tag $image_name $latest_name
101+
echo "Pushing $image_name ..."
102+
podman push $image_name
103+
echo "Pushing $latest_name ..."
104+
podman push $latest_name
105+
}
106+
94107
podman login -u ${{ github.actor }} -p $GITHUB_TOKEN ghcr.io
95-
podman push ${{ needs.build-ci-container.outputs.container-name-tag }}
96-
podman push ${{ needs.build-ci-container.outputs.container-name }}:latest
108+
for f in $(find . -iname *.tar); do
109+
image_name=$(podman load -q -i $f | sed 's/Loaded image: //g')
110+
push_container $image_name
97111
98-
podman load -i ${{ needs.build-ci-container.outputs.container-agent-filename }}
99-
podman tag ${{ needs.build-ci-container.outputs.container-name-agent-tag }} ${{ needs.build-ci-container.outputs.container-name-agent }}:latest
100-
podman push ${{ needs.build-ci-container.outputs.container-name-agent-tag }}
101-
podman push ${{ needs.build-ci-container.outputs.container-name-agent }}:latest
112+
if echo $image_name | grep '/amd64/'; then
113+
# For amd64, create an alias with the arch component removed.
114+
# This matches the convention used on dockerhub.
115+
default_image_name=$(echo $(dirname $(dirname $image_name))/$(basename $image_name))
116+
podman tag $image_name $default_image_name
117+
push_container $default_image_name
118+
fi
119+
done

.github/workflows/premerge.yaml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,15 @@ permissions:
55

66
on:
77
pull_request:
8+
types:
9+
- opened
10+
- synchronize
11+
- reopened
12+
# When a PR is closed, we still start this workflow, but then skip
13+
# all the jobs, which makes it effectively a no-op. The reason to
14+
# do this is that it allows us to take advantage of concurrency groups
15+
# to cancel in progress CI jobs whenever the PR is closed.
16+
- closed
817
paths:
918
- .github/workflows/premerge.yaml
1019
push:
@@ -14,7 +23,9 @@ on:
1423

1524
jobs:
1625
premerge-checks-linux:
17-
if: github.repository_owner == 'llvm'
26+
if: >-
27+
github.repository_owner == 'llvm' &&
28+
(github.event_name != 'pull_request' || github.event.action != 'closed')
1829
runs-on: llvm-premerge-linux-runners
1930
concurrency:
2031
group: ${{ github.workflow }}-linux-${{ github.event.pull_request.number || github.sha }}
@@ -73,7 +84,9 @@ jobs:
7384
./.ci/monolithic-linux.sh "$(echo ${linux_projects} | tr ' ' ';')" "$(echo ${linux_check_targets})" "$(echo ${linux_runtimes} | tr ' ' ';')" "$(echo ${linux_runtime_check_targets})"
7485
7586
premerge-checks-windows:
76-
if: github.repository_owner == 'llvm'
87+
if: >-
88+
github.repository_owner == 'llvm' &&
89+
(github.event_name != 'pull_request' || github.event.action != 'closed')
7790
runs-on: llvm-premerge-windows-runners
7891
concurrency:
7992
group: ${{ github.workflow }}-windows-${{ github.event.pull_request.number || github.sha }}
@@ -141,7 +154,8 @@ jobs:
141154
if: >-
142155
github.repository_owner == 'llvm' &&
143156
(startswith(github.ref_name, 'release/') ||
144-
startswith(github.base_ref, 'release/'))
157+
startswith(github.base_ref, 'release/')) &&
158+
(github.event_name != 'pull_request' || github.event.action != 'closed')
145159
steps:
146160
- name: Checkout LLVM
147161
uses: actions/checkout@v4

.github/workflows/release-tasks.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -89,20 +89,10 @@ jobs:
8989
needs:
9090
- validate-tag
9191
- release-create
92-
strategy:
93-
fail-fast: false
94-
matrix:
95-
runs-on:
96-
- ubuntu-22.04
97-
- windows-2022
98-
- macos-13
99-
- macos-14
100-
101-
uses: ./.github/workflows/release-binaries.yml
92+
uses: ./.github/workflows/release-binaries-all.yml
10293
with:
10394
release-version: ${{ needs.validate-tag.outputs.release-version }}
10495
upload: true
105-
runs-on: ${{ matrix.runs-on }}
10696
# Called workflows don't have access to secrets by default, so we need to explicitly pass secrets that we use.
10797
secrets:
10898
RELEASE_TASKS_USER_TOKEN: ${{ secrets.RELEASE_TASKS_USER_TOKEN }}

clang/docs/ReleaseNotes.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ Improvements to Clang's diagnostics
116116
- Improve the diagnostics for deleted default constructor errors for C++ class
117117
initializer lists that don't explicitly list a class member and thus attempt
118118
to implicitly default construct that member.
119+
- The ``-Wunique-object-duplication`` warning has been added to warn about objects
120+
which are supposed to only exist once per program, but may get duplicated when
121+
built into a shared library.
119122

120123
Improvements to Clang's time-trace
121124
----------------------------------
@@ -158,6 +161,11 @@ AMDGPU Support
158161
NVPTX Support
159162
^^^^^^^^^^^^^^
160163

164+
Hexagon Support
165+
^^^^^^^^^^^^^^^
166+
167+
- The default compilation target has been changed from V60 to V68.
168+
161169
X86 Support
162170
^^^^^^^^^^^
163171

clang/include/clang/Basic/BuiltinsX86.td

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,10 @@ let Attributes = [Const, NoThrow, RequiredVectorWidth<128>] in {
130130
}
131131
}
132132

133+
let Features = "sse", Header = "xmmintrin.h", Attributes = [NoThrow, Const] in {
134+
def _mm_prefetch : X86LibBuiltin<"void(void const *, int)">;
135+
}
136+
133137
// AVX
134138
let Attributes = [Const, NoThrow, RequiredVectorWidth<256>], Features = "avx" in {
135139
foreach Op = ["addsub", "hadd", "hsub", "max", "min"] in {
@@ -138,6 +142,12 @@ let Attributes = [Const, NoThrow, RequiredVectorWidth<256>], Features = "avx" in
138142
}
139143
}
140144

145+
// PRFCHW
146+
let Features = "prfchw", Header = "intrin.h", Attributes = [NoThrow, Const] in {
147+
def _m_prefetch : X86LibBuiltin<"void(void *)">;
148+
def _m_prefetchw : X86LibBuiltin<"void(void volatile const *)">;
149+
}
150+
141151

142152
// Mechanically ported builtins from the original `.def` file.
143153
//
@@ -146,10 +156,6 @@ let Attributes = [Const, NoThrow, RequiredVectorWidth<256>], Features = "avx" in
146156
// current formulation is based on what was easiest to recognize from the
147157
// pre-TableGen version.
148158

149-
let Features = "mmx", Attributes = [NoThrow, Const] in {
150-
def _mm_prefetch : X86NoPrefixBuiltin<"void(char const *, int)">;
151-
}
152-
153159
let Features = "sse", Attributes = [NoThrow] in {
154160
def ldmxcsr : X86Builtin<"void(unsigned int)">;
155161
}

clang/include/clang/Basic/DiagnosticGroups.td

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -694,6 +694,36 @@ def SuspiciousMemaccess : DiagGroup<"suspicious-memaccess",
694694
NonTrivialMemaccess, MemsetTransposedArgs, SuspiciousBzero]>;
695695
def StaticInInline : DiagGroup<"static-in-inline">;
696696
def StaticLocalInInline : DiagGroup<"static-local-in-inline">;
697+
def UniqueObjectDuplication : DiagGroup<"unique-object-duplication"> {
698+
code Documentation = [{
699+
Warns when objects which are supposed to be globally unique might get duplicated
700+
when built into a shared library.
701+
702+
If an object with hidden visibility is built into a shared library, each instance
703+
of the library will get its own copy. This can cause very subtle bugs if there was
704+
only supposed to be one copy of the object in question: singletons aren't single,
705+
changes to one object won't affect the others, the object's initializer will run
706+
once per copy, etc.
707+
708+
Specifically, this warning fires when it detects an object which:
709+
1. Appears in a header file (so it might get compiled into multiple libaries), and
710+
2. Has external linkage (otherwise it's supposed to be duplicated), and
711+
3. Has hidden visibility.
712+
713+
As well as one of the following:
714+
1. The object is mutable, or
715+
2. The object's initializer definitely has side effects.
716+
717+
The warning is best resolved by making the object ``const`` (if possible), or by explicitly
718+
giving the object non-hidden visibility, e.g. using ``__attribute((visibility("default")))``.
719+
Note that all levels of a pointer variable must be constant; ``const int*`` will
720+
trigger the warning because the pointer itself is mutable.
721+
722+
This warning is currently disabled on Windows since it uses import/export rules
723+
instead of visibility.
724+
}];
725+
}
726+
697727
def GNUStaticFloatInit : DiagGroup<"gnu-static-float-init">;
698728
def StaticFloatInit : DiagGroup<"static-float-init", [GNUStaticFloatInit]>;
699729
// Allow differentiation between GNU statement expressions in a macro versus

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6169,6 +6169,15 @@ def warn_static_local_in_extern_inline : Warning<
61696169
def note_convert_inline_to_static : Note<
61706170
"use 'static' to give inline function %0 internal linkage">;
61716171

6172+
def warn_possible_object_duplication_mutable : Warning<
6173+
"%0 may be duplicated when built into a shared library: "
6174+
"it is mutable, has hidden visibility, and external linkage">,
6175+
InGroup<UniqueObjectDuplication>, DefaultIgnore;
6176+
def warn_possible_object_duplication_init : Warning<
6177+
"initializeation of %0 may run twice when built into a shared library: "
6178+
"it has hidden visibility and external linkage">,
6179+
InGroup<UniqueObjectDuplication>, DefaultIgnore;
6180+
61726181
def ext_redefinition_of_typedef : ExtWarn<
61736182
"redefinition of typedef %0 is a C11 feature">,
61746183
InGroup<DiagGroup<"typedef-redefinition"> >;

clang/include/clang/Basic/OpenACCKinds.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ inline StreamTy &printOpenACCAtomicKind(StreamTy &Out, OpenACCAtomicKind AK) {
188188
case OpenACCAtomicKind::None:
189189
return Out << "<none>";
190190
}
191+
llvm_unreachable("unknown atomic kind");
191192
}
192193
inline const StreamingDiagnostic &operator<<(const StreamingDiagnostic &Out,
193194
OpenACCAtomicKind AK) {

clang/include/clang/CIR/LowerToLLVM.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
#ifndef CLANG_CIR_LOWERTOLLVM_H
1313
#define CLANG_CIR_LOWERTOLLVM_H
1414

15-
#include "mlir/Pass/Pass.h"
16-
1715
#include <memory>
1816

1917
namespace llvm {
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//===---- MissingFeatures.h - Checks for unimplemented features -*- C++ -*-===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
//
9+
// This file introduces some helper classes to guard against features that
10+
// CIR dialect supports that we do not have and also do not have great ways to
11+
// assert against.
12+
//
13+
//===----------------------------------------------------------------------===//
14+
15+
#ifndef CLANG_CIR_MISSINGFEATURES_H
16+
#define CLANG_CIR_MISSINGFEATURES_H
17+
18+
namespace cir {
19+
20+
// As a way to track features that haven't yet been implemented this class
21+
// explicitly contains a list of static fns that will return false that you
22+
// can guard against. If and when a feature becomes implemented simply changing
23+
// this return to true will cause compilation to fail at all the points in which
24+
// we noted that we needed to address. This is a much more explicit way to
25+
// handle "TODO"s.
26+
struct MissingFeatures {
27+
// Address space related
28+
static bool addressSpace() { return false; }
29+
30+
// Unhandled global/linkage information.
31+
static bool opGlobalDSOLocal() { return false; }
32+
static bool opGlobalThreadLocal() { return false; }
33+
static bool opGlobalConstant() { return false; }
34+
static bool opGlobalAlignment() { return false; }
35+
static bool opGlobalLinkage() { return false; }
36+
};
37+
38+
} // namespace cir
39+
40+
#endif // CLANG_CIR_MISSINGFEATURES_H

clang/include/clang/Sema/Sema.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3664,6 +3664,12 @@ class Sema final : public SemaBase {
36643664
NonTrivialCUnionContext UseContext,
36653665
unsigned NonTrivialKind);
36663666

3667+
/// Certain globally-unique variables might be accidentally duplicated if
3668+
/// built into multiple shared libraries with hidden visibility. This can
3669+
/// cause problems if the variable is mutable, its initialization is
3670+
/// effectful, or its address is taken.
3671+
bool GloballyUniqueObjectMightBeAccidentallyDuplicated(const VarDecl *Dcl);
3672+
36673673
/// AddInitializerToDecl - Adds the initializer Init to the
36683674
/// declaration dcl. If DirectInit is true, this is C++ direct
36693675
/// initialization rather than copy initialization.

clang/lib/CIR/Lowering/DirectToLLVM/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,15 @@ set(LLVM_LINK_COMPONENTS
33
Support
44
)
55

6+
get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
7+
68
add_clang_library(clangCIRLoweringDirectToLLVM
79
LowerToLLVM.cpp
810

911
LINK_LIBS
1012
MLIRIR
13+
${dialect_libs}
14+
MLIRCIR
15+
MLIRBuiltinToLLVMIRTranslation
16+
MLIRLLVMToLLVMIRTranslation
1117
)

0 commit comments

Comments
 (0)