Skip to content

Commit fde824f

Browse files
committed
Merge remote-tracking branch 'upstream/main' into constantfolding-roundeven
2 parents 72bb022 + f290bf9 commit fde824f

File tree

160 files changed

+22484
-23279
lines changed

Some content is hidden

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

160 files changed

+22484
-23279
lines changed

.github/workflows/issue-write.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,4 +162,4 @@ jobs:
162162
if: >-
163163
always() &&
164164
steps.download-artifact.outputs.artifact-ids != ''
165-
run: cat comments
165+
run: cat comments*

bolt/include/bolt/Passes/IdenticalCodeFolding.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,19 @@ class IdenticalCodeFolding : public BinaryFunctionPass {
3737
Error runOnFunctions(BinaryContext &BC) override;
3838

3939
private:
40+
static constexpr uint64_t VTableAddressGranularity = 4;
41+
4042
/// Bit vector of memory addresses of vtables.
4143
llvm::SparseBitVector<> VTableBitVector;
4244

4345
/// Return true if the memory address is in a vtable.
4446
bool isAddressInVTable(uint64_t Address) const {
45-
return VTableBitVector.test(Address / 8);
47+
return VTableBitVector.test(Address / VTableAddressGranularity);
4648
}
4749

4850
/// Mark memory address of a vtable as used.
4951
void setAddressUsedInVTable(uint64_t Address) {
50-
VTableBitVector.set(Address / 8);
52+
VTableBitVector.set(Address / VTableAddressGranularity);
5153
}
5254

5355
/// Scan symbol table and mark memory addresses of

bolt/lib/Passes/IdenticalCodeFolding.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,8 @@ void IdenticalCodeFolding::initVTableReferences(const BinaryContext &BC) {
380380
if (!Data->getName().starts_with("_ZTV") && // vtable
381381
!Data->getName().starts_with("_ZTCN")) // construction vtable
382382
continue;
383-
for (uint64_t I = Address, End = I + Data->getSize(); I < End; I += 8)
383+
for (uint64_t I = Address, End = I + Data->getSize(); I < End;
384+
I += VTableAddressGranularity)
384385
setAddressUsedInVTable(I);
385386
}
386387
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// Test safe ICF works with binaries that contain relative vtable.
2+
3+
// REQUIRES: system-linux,asserts
4+
5+
// RUN: %clang %cxxflags -o %t.so %s -Wl,-q -fno-rtti
6+
// RUN: llvm-bolt %t.so -o %t.bolt --no-threads --icf=safe \
7+
// RUN: --debug-only=bolt-icf 2>&1 | FileCheck %s
8+
9+
// RUN: %clang %cxxflags -o %t.so %s -Wl,-q -fno-rtti \
10+
// RUN: -fexperimental-relative-c++-abi-vtables
11+
// RUN: llvm-bolt %t.so -o %t.bolt --no-threads --icf=safe \
12+
// RUN: --debug-only=bolt-icf 2>&1 | FileCheck %s
13+
14+
// CHECK: folding {{.*bar.*}} into {{.*foo.*}}
15+
// CHECK-NOT: skipping function with reference taken {{.*bar.*}}
16+
17+
class TT {
18+
public:
19+
virtual int foo(int a) { return ++a; }
20+
virtual int bar(int a) { return ++a; }
21+
};
22+
23+
int main() {
24+
TT T;
25+
return T.foo(0) + T.bar(1);
26+
}

clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "RedundantCastingCheck.h"
1010
#include "../utils/FixItHintUtils.h"
1111
#include "clang/AST/ASTContext.h"
12+
#include "clang/AST/TypeBase.h"
1213
#include "clang/ASTMatchers/ASTMatchFinder.h"
1314
#include "clang/Lex/Lexer.h"
1415

@@ -29,7 +30,7 @@ static bool areTypesEqual(QualType S, QualType D) {
2930
const QualType PtrD = D->getPointeeType();
3031

3132
if (!PtrS.isNull() && !PtrD.isNull())
32-
return areTypesEqual(PtrS, PtrD);
33+
return areTypesEqual(PtrS.IgnoreParens(), PtrD.IgnoreParens());
3334

3435
const DeducedType *DT = S->getContainedDeducedType();
3536
if (DT && DT->isDeduced())

clang-tools-extra/clangd/test/lit.cfg.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
1+
import os
2+
13
import lit.llvm
24
import lit.util
35

46
lit.llvm.initialize(lit_config, config)
57
lit.llvm.llvm_config.clang_setup()
68
lit.llvm.llvm_config.use_default_substitutions()
79

10+
# TODO: Consolidate the logic for turning on the internal shell by default for all LLVM test suites.
11+
# See https://github.com/llvm/llvm-project/issues/106636 for more details.
12+
#
13+
# We prefer the lit internal shell which provides a better user experience on failures
14+
# and is faster unless the user explicitly disables it with LIT_USE_INTERNAL_SHELL=0
15+
# env var.
16+
use_lit_shell = True
17+
lit_shell_env = os.environ.get("LIT_USE_INTERNAL_SHELL")
18+
if lit_shell_env:
19+
use_lit_shell = lit.util.pythonize_bool(lit_shell_env)
20+
821
config.name = "Clangd"
922
config.suffixes = [".test"]
1023
config.excludes = ["Inputs"]
11-
config.test_format = lit.formats.ShTest(not lit.llvm.llvm_config.use_lit_shell)
24+
config.test_format = lit.formats.ShTest(not use_lit_shell)
1225
config.test_source_root = config.clangd_source_dir + "/test"
1326
config.test_exec_root = config.clangd_binary_dir + "/test"
1427

clang-tools-extra/clangd/test/system-include-extractor.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
# Create a bin directory to store the mock-driver and add it to the path
77
# RUN: mkdir -p %t.dir/bin
8-
# RUN: %python -c "print(__import__('os').environ['PATH'])" > %t.path
8+
# RUN: %python -c "print(__import__('os').environ['PATH'])" | tr -d '\n' > %t.path
99
# RUN: export PATH=%t.dir/bin:%{readfile:%t.path}
1010
# Generate a mock-driver that will print %temp_dir%/my/dir and
1111
# %temp_dir%/my/dir2 as include search paths.

clang-tools-extra/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,10 @@ Changes in existing checks
567567
<clang-tidy/checks/readability/qualified-auto>` check by adding the option
568568
`IgnoreAliasing`, that allows not looking at underlying types of type aliases.
569569

570+
- Improved :doc:`readability-redundant-casting
571+
<clang-tidy/checks/readability/redundant-casting>` check by fixing false
572+
negatives when explicitly cast from function pointer.
573+
570574
- Improved :doc:`readability-uppercase-literal-suffix
571575
<clang-tidy/checks/readability/uppercase-literal-suffix>` check to recognize
572576
literal suffixes added in C++23 and C23.

clang-tools-extra/docs/clang-tidy/checks/cert/dcl58-cpp.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
cert-dcl58-cpp
44
==============
55

6-
The `cert-dcl58-cpp` is an aliaes, please see
6+
The `cert-dcl58-cpp` is an alias, please see
77
:doc:`bugprone-std-namespace-modification
88
<../bugprone/std-namespace-modification>`
99
for more information.

clang-tools-extra/docs/clang-tidy/checks/cert/mem57-cpp.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
cert-mem57-cpp
44
==============
55

6-
The `cert-mem57-cpp` is an aliaes, please see
6+
The `cert-mem57-cpp` is an alias, please see
77
:doc:`bugprone-default-operator-new-on-overaligned-type
88
<../bugprone/default-operator-new-on-overaligned-type>`
99
for more information.

0 commit comments

Comments
 (0)