Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoBump] Merge with 9997e039 (5) #252

Merged
merged 96 commits into from
Aug 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
575ca67
[CodeGen] Remove unused MachineRegisterInfo methods
jayfoad Mar 11, 2024
a924da6
[mlir][IR] Add `isInteger()` (without width) (#84467)
marbre Mar 11, 2024
0858c90
[X86] Add missing register qualifier to the VBLENDVPD/VBLENDVPS/VPBLE…
RKSimon Mar 11, 2024
ad8c828
[X86] (V)MPSADBW instructions can run on Port1 or Port5 for one uop s…
RKSimon Mar 11, 2024
2c93bec
[InstallAPI] Collect C++ Decls (#84403)
cyndyishida Mar 11, 2024
34acdb3
Precommit testcase for pr81872 (#84782)
annamthomas Mar 11, 2024
7dc4d5f
[X86] Add AVX512 (x86-64-v4) coverage to generic shift combines tests
RKSimon Mar 11, 2024
6cd68c2
[X86] Add base SSE2 coverage to SRL/SRA combines tests
RKSimon Mar 11, 2024
81e2047
[cmake] Exposes LLVM version number in the runtimes. (#84641)
mordante Mar 11, 2024
9a9aa41
[LLDB][doc] Updates build instructions. (#84630)
mordante Mar 11, 2024
501bc10
[lldb] Save the edited line before clearing it in Editline::PrintAsyn…
karzanWang Mar 11, 2024
07d7b9c
[libc] Fix forward arm32 builtbot (#84794)
gchatelet Mar 11, 2024
bdbad0d
Turn off instruction flow control annotations by default (#84607)
jasonmolenda Mar 11, 2024
36a2752
[bazel] Grab correct version info after 81e20472a0c5a4a8edc5ec38dc345…
d0k Mar 11, 2024
866ac9a
[LV] Address postcommit review for PR84782 (#84797)
annamthomas Mar 11, 2024
8467457
Add new flag -Wreturn-mismatch (#82872)
11happy Mar 11, 2024
034cc2f
[GISEL] Add G_INSERT_SUBVECTOR and G_EXTRACT_SUBVECTOR (#84538)
michaelmaitland Mar 11, 2024
2a3f27c
[AMDGPU][True16] Make NotHasTrue16BitInsts a True16Predicate (#84771)
Sisyph Mar 11, 2024
725a052
[Headers][X86] Add specific results to comparisons (#83316)
pogo59 Mar 11, 2024
2126046
[AMDGPU] Add missing tests for GFX10 (t)buffer format d16 instruction…
jayfoad Mar 11, 2024
23be732
AMDGPU: Add an argument to DS_Real_gfx12 to disable alias, NFC (#84717)
changpeng Mar 11, 2024
5b4c350
[flang][unittests] Fix buffer underrun in LengthWithoutTrailingSpaces…
kparzysz Mar 11, 2024
8846b91
Revert "[CMake][LIT] Add option to run lit testsuites in parallel" (#…
Mar 11, 2024
b4e0890
[NFC] [scudo] move static_assert closer to class it relates to (#84257)
fmayer Mar 11, 2024
a8eb2f0
[Clang][AST] Print attributes of Obj-C interfaces
egorzhdan Mar 11, 2024
337a200
[NFC] [scudo] Move static_assert to class it concerns (#84245)
fmayer Mar 11, 2024
08a9207
[LLDB] ASanLibsanitizers Use `sanitizers_address_on_report` breakpoin…
usama54321 Mar 11, 2024
eaa71a9
[clang] Add optional pass to remove UBSAN traps using PGO (#84214)
vitalybuka Mar 11, 2024
d1d80cc
[HIP] Make the new driver bundle outputs for device-only (#84534)
jhuber6 Mar 11, 2024
6d4aa9d
[BOLT][DWWARF] Fix foreign TU index with local TUs (#84594)
ayermolo Mar 11, 2024
6aef8df
[libcxx] Update 128-bit-atomics feature test (#83841)
amilendra Mar 11, 2024
18f49cf
[libc++] Remove XFAIL for SIMD in optimized build (#84767)
ldionne Mar 11, 2024
d2e57c5
[libc++] Re-enable the clang_modules_include test for Objective-C++ (…
ldionne Mar 11, 2024
42ee286
Fixing test from 8467457afc61d70e881c9817ace26356ef757733
AaronBallman Mar 11, 2024
a70d729
[flang] Avoid left shifts of negative signed values (#84786)
kparzysz Mar 11, 2024
1def98d
[flang] Avoid forming a reference from null pointer (#84787)
kparzysz Mar 11, 2024
a25fa92
[libc][stdbit] Add C tests for stdbit generic macros. (#84670)
lntue Mar 11, 2024
884b051
Recommit "[TypePromotion] Support positive addition amounts in isSafe…
topperc Mar 11, 2024
5feaef6
[TBAA] Generate tbaa.struct single field with char tag for unions. (#…
fhahn Mar 11, 2024
94c988b
[NFC] Remove unused parameter from shouldAssumeDSOLocal()
aeubanks Mar 11, 2024
6462ead
Report back errors in GetNumChildren() (#84265)
adrian-prantl Mar 11, 2024
4628e33
[NFC][docs] Rename duplicate label to something unique
bwendling Mar 11, 2024
4d21e75
[libc][math][c23] Add fmodl and fmodf128 math functions. (#84600)
lntue Mar 11, 2024
f4c1e87
[libc++][hardening] Reclassify string_view(ptr, len)'s size assertion…
davidben Mar 11, 2024
f832bee
[flang][NFC] Use the tablegen definition for FIR dialect (#84822)
clementval Mar 11, 2024
f19d9e1
[KnownBits] Add test for computing more information for `lshr`/`ashr`…
goldsteinn Mar 7, 2024
a9d913e
[KnownBits] Add API support for `exact` in `lshr`/`ashr`; NFC
goldsteinn Mar 6, 2024
d81db0e
[KnownBits] Implement knownbits `lshr`/`ashr` with exact flag
goldsteinn Mar 6, 2024
65fd664
Run pre-merge build with -k 0 to ensure all tests runs (#84828)
joker-eph Mar 11, 2024
31ffdb5
[ArgPromotion] Add test case for #84807.
fhahn Mar 11, 2024
0f0f0ff
[NFC] Remove unused variable after 94c988bc
aeubanks Mar 11, 2024
3707c54
Make ValueObject::Cast work for casts from smaller to larger structs …
jimingham Mar 11, 2024
762cbd8
[libc][NFC] Do not add libc test framework and -fno-rtti to C tests. …
lntue Mar 11, 2024
c93c76b
[LLD] [COFF] Set the right alignment for DelayDirectoryChunk (#84697)
mstorsjo Mar 11, 2024
60e562d
[mlir][linalg] Add unit dim folding pattern for tensor.pad (#84684)
qedawkins Mar 11, 2024
6397f22
[clang] Fix test after #84214
vitalybuka Mar 11, 2024
a950c06
[CI] Run pre-merge build with -k 0 placed after "${BUILD_DIR}" (#84846)
cpsughrue Mar 11, 2024
83c9244
[mlir][sparse] Migrate more tests to use sparse_tensor.print (#84833)
yinying-lisa-li Mar 11, 2024
ad23127
[mlir][inline] avoid inline self-recursive function (#83092)
HerrCai0907 Mar 11, 2024
8d220d1
workflows: Fix incorrect input name in release-binaries.yml (#84604)
tstellar Mar 11, 2024
d125d55
github-automation.py: Set maintainer_can_modify=True for backport PRs…
tstellar Mar 11, 2024
75790dd
[RemoveDIs] Fix nullptr dereference in getFirstNonPHIIt() (#84595)
dsandersllvm Mar 11, 2024
9688a6d
[MLIR] Add missing MLIRFuncDialect dep to MLIRNVVMToLLVM (#84548)
RoboTux Mar 11, 2024
36cf982
[MLIR] Add missing MLIRFuncDialect dep to MLIRAMDGPUTransforms (#84550)
RoboTux Mar 11, 2024
b2ea046
[MLIR] Add missing omp_gen dep to MLIROpenMPDialect (#84552)
RoboTux Mar 11, 2024
8d61f82
[lld][RISCV] Avoid second map lookup in mergeArch. NFC (#84687)
topperc Mar 12, 2024
67ef4ae
[MLIR][Tensor,MemRef] Fold expand_shape and collapse_shape if identit…
newling Mar 12, 2024
672fc89
[NFC] [hwasan] factor out selective instrumentation logic (#84408)
fmayer Mar 12, 2024
41658ba
[libc++][hardening] Add iterator validity checks on unordered contain…
davidben Mar 12, 2024
2a30684
[mlir][Transforms] Use correct listener in dialect conversion (#84861)
matthias-springer Mar 12, 2024
26722f5
[MLIR] Fix incorrect memref::DimOp canonicalization, add tensor::DimO…
sahas3 Mar 12, 2024
e40cabf
[MemProf] Match function's summary and definition strictly (#83665)
lifengxiang1025 Mar 12, 2024
e4a5467
[MLIR][LSP][NFC] Fix a header guard (#84862)
walter-erquinigo Mar 12, 2024
a83f8e0
[libc++][hardening] Check bounds on arithmetic in __bounded_iter (#78…
davidben Mar 12, 2024
d02d8df
[clang][Interp] Implement _Complex negation
tbaederr Mar 11, 2024
71590e7
[X86][test] Add missing enc/dec tests for CTEST
KanRobert Mar 12, 2024
e89b4bc
[X86] Remove SlowDivide tuning from GRTTuning (#84676)
phoebewang Mar 12, 2024
f95710c
[flang] Fixed compiler build on glibc 2.17 systems after 3149c93. (#8…
vzakhari Mar 12, 2024
1d900e2
[AArch64][GlobalISel] Avoid generating inserts for undefs when select…
dc03-work Mar 12, 2024
1dd104d
[clang][Interp] Implement _Complex Not unary operators
tbaederr Mar 12, 2024
103469b
[clang][Interp] Implement more easy _Complex unary operators
tbaederr Mar 12, 2024
85f6669
[flang] implement sizeof lowering for polymorphic entities (#84498)
jeanPerier Mar 12, 2024
8e0f4b9
[NVPTX] Add support for atomic add for f16 type (#84295)
akuegel Mar 12, 2024
36dece0
[AMDGPU] Add missing GFX10 buffer format d16 hi instructions (#84809)
jayfoad Mar 12, 2024
6bbe8a2
[llvm-exegesis] Add thread IDs to subprocess memory names (#84451)
boomanaiden154 Mar 12, 2024
aefad27
Revert "[llvm-exegesis] Add thread IDs to subprocess memory names (#8…
fhahn Mar 12, 2024
b274b23
[ValueTracking] Treat phi as underlying obj when not decomposing furt…
fhahn Mar 12, 2024
939f038
[flang] lower vector subscripted polymorphic designators (#84778)
jeanPerier Mar 12, 2024
9d16e79
[AArch64] Fix COMPILER_RT_HAS_AUXV for builtins. (#84816)
DanielKristofKiss Mar 12, 2024
368db56
[lldb] Fix build break on windows (#84863)
lwmaia Mar 12, 2024
a3b5250
[InstSimpliy] Use range attribute to simplify comparisons (#84627)
andjo403 Mar 12, 2024
bba4a1d
[ArgPromotion] Remove incorrect TranspBlocks set for loads. (#84835)
fhahn Mar 12, 2024
9228859
[CMake] Add tablegen job pool support (#84762)
dstutt Mar 12, 2024
ce1fd92
Update test past bdbad0d07bb600301cb324e87a6be37ca4af591a (#84889)
dklimkin Mar 12, 2024
9997e03
[RemoveDIs] Update DIBuilder to conditionally insert DbgRecords (#84739)
OCHyams Mar 12, 2024
10013b0
[AutoBump] Merge with 9997e039
mgehre-amd Aug 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .ci/monolithic-linux.sh
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@ cmake -S ${MONOREPO_ROOT}/llvm -B ${BUILD_DIR} \

echo "--- ninja"
# Targets are not escaped as they are passed as separate arguments.
ninja -C "${BUILD_DIR}" ${targets}
ninja -C "${BUILD_DIR}" -k 0 ${targets}
2 changes: 1 addition & 1 deletion .ci/monolithic-windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,4 @@ cmake -S ${MONOREPO_ROOT}/llvm -B ${BUILD_DIR} \

echo "--- ninja"
# Targets are not escaped as they are passed as separate arguments.
ninja -C "${BUILD_DIR}" ${targets}
ninja -C "${BUILD_DIR}" -k 0 ${targets}
4 changes: 2 additions & 2 deletions .github/workflows/release-binaries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ jobs:
# | X.Y.Z | -final
run: |
tag="${{ github.ref_name }}"
trimmed=$(echo ${{ inputs.tag }} | xargs)
[[ "$trimmed" != "" ]] && tag="$trimmed"
trimmed=$(echo ${{ inputs.release-version }} | xargs)
[[ "$trimmed" != "" ]] && tag="llvmorg-$trimmed"
if [ "$tag" = "main" ]; then
# If tag is main, then we've been triggered by a scheduled so pass so
# use the head commit as the tag.
Expand Down
7 changes: 6 additions & 1 deletion bolt/lib/Core/DebugNames.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,8 +345,13 @@ void DWARF5AcceleratorTable::finalize() {
std::optional<DWARF5AccelTable::UnitIndexAndEncoding>
DWARF5AcceleratorTable::getIndexForEntry(
const BOLTDWARF5AccelTableData &Value) const {
// The foreign TU list immediately follows the local TU list and they both
// use the same index, so that if there are N local TU entries, the index for
// the first foreign TU is N.
if (Value.isTU())
return {{Value.getUnitID(), {dwarf::DW_IDX_type_unit, TUIndexForm}}};
return {{(Value.getSecondUnitID() ? (unsigned)LocalTUList.size() : 0) +
Value.getUnitID(),
{dwarf::DW_IDX_type_unit, TUIndexForm}}};
if (CUList.size() > 1)
return {{Value.getUnitID(), {dwarf::DW_IDX_compile_unit, CUIndexForm}}};
return std::nullopt;
Expand Down
314 changes: 314 additions & 0 deletions bolt/test/X86/Inputs/dwarf5-debug-names-ftu-ltu-mix-helper.s

Large diffs are not rendered by default.

315 changes: 315 additions & 0 deletions bolt/test/X86/Inputs/dwarf5-debug-names-ftu-ltu-mix-helper1.s

Large diffs are not rendered by default.

505 changes: 505 additions & 0 deletions bolt/test/X86/Inputs/dwarf5-df-debug-names-ftu-ltu-mix-main.s

Large diffs are not rendered by default.

56 changes: 56 additions & 0 deletions bolt/test/X86/dwarf5-df-main-debug-names-ftu-ltu-mix.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
; RUN: rm -rf %t
; RUN: mkdir %t
; RUN: cd %t
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-df-debug-names-ftu-ltu-mix-main.s \
; RUN: -split-dwarf-file=main.dwo -o main.o
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-debug-names-ftu-ltu-mix-helper.s -o helper.o
; RUN: llvm-mc -dwarf-version=5 -filetype=obj -triple x86_64-unknown-linux %p/Inputs/dwarf5-debug-names-ftu-ltu-mix-helper1.s -o helper1.o
; RUN: %clang %cflags -gdwarf-5 -gsplit-dwarf=split main.o helper.o helper1.o -o main.exe -fno-pic -no-pie
; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections --create-debug-names-section=true
; RUN: llvm-dwarfdump --debug-names main.exe.bolt | FileCheck -check-prefix=BOLT %s

;; Tests BOLT correctly sets foreign TU Index when there are local TUs.

; BOLT: Compilation Unit offsets [
; BOLT-NEXT: CU[0]: {{.+}}
; BOLT-NEXT: CU[1]: {{.+}}
; BOLT-NEXT: CU[2]: {{.+}}
; BOLT-NEXT: ]
; BOLT-NEXT: Local Type Unit offsets [
; BOLT-NEXT: LocalTU[0]: {{.+}}
; BOLT-NEXT: LocalTU[1]: {{.+}}
; BOLT-NEXT: ]
; BOLT-NEXT: Foreign Type Unit signatures [
; BOLT-NEXT: ForeignTU[0]: 0x889c84450dac881f
; BOLT-NEXT: ]
; BOLT: Name 3 {
; BOLT-NEXT: Hash: 0x6A05C500
; BOLT-NEXT: String: {{.+}} "globalMono1"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: 0x5
; BOLT-NEXT: Tag: DW_TAG_variable
; BOLT-NEXT: DW_IDX_compile_unit: 0x02
; BOLT-NEXT: DW_IDX_die_offset: 0x0000001e
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT: Name 6 {
; BOLT-NEXT: Hash: 0xF283AF92
; BOLT-NEXT: String: {{.+}} "ASplit"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: 0x7
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_type_unit: 0x02
; BOLT-NEXT: DW_IDX_compile_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000021
; BOLT-NEXT: }
; BOLT-NEXT: }
; BOLT: Name 7 {
; BOLT-NEXT: Hash: 0xF17F51F
; BOLT-NEXT: String: {{.+}} "AMono"
; BOLT-NEXT: Entry @ {{.+}} {
; BOLT-NEXT: Abbrev: 0x4
; BOLT-NEXT: Tag: DW_TAG_structure_type
; BOLT-NEXT: DW_IDX_type_unit: 0x00
; BOLT-NEXT: DW_IDX_die_offset: 0x00000023
; BOLT-NEXT: }
; BOLT-NEXT: }
2 changes: 1 addition & 1 deletion clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,7 +544,7 @@ TEST(DiagnosticTest, RespectsDiagnosticConfig) {
Diag(Main.range("ret"),
"void function 'x' should not return a value")));
Config Cfg;
Cfg.Diagnostics.Suppress.insert("return-type");
Cfg.Diagnostics.Suppress.insert("return-mismatch");
WithContextValue WithCfg(Config::Key, std::move(Cfg));
EXPECT_THAT(TU.build().getDiagnostics(),
ElementsAre(Diag(Main.range(),
Expand Down
3 changes: 3 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,9 @@ Deprecated Compiler Flags

Modified Compiler Flags
-----------------------
- Added a new diagnostic flag ``-Wreturn-mismatch`` which is grouped under
``-Wreturn-type``, and moved some of the diagnostics previously controlled by
``-Wreturn-type`` under this new flag. Fixes #GH72116.

Removed Compiler Flags
-------------------------
Expand Down
4 changes: 3 additions & 1 deletion clang/include/clang/Basic/DiagnosticGroups.td
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,9 @@ def GNURedeclaredEnum : DiagGroup<"gnu-redeclared-enum">;
def RedundantMove : DiagGroup<"redundant-move">;
def Register : DiagGroup<"register", [DeprecatedRegister]>;
def ReturnTypeCLinkage : DiagGroup<"return-type-c-linkage">;
def ReturnType : DiagGroup<"return-type", [ReturnTypeCLinkage]>;
def ReturnMismatch : DiagGroup<"return-mismatch">;
def ReturnType : DiagGroup<"return-type", [ReturnTypeCLinkage, ReturnMismatch]>;

def BindToTemporaryCopy : DiagGroup<"bind-to-temporary-copy",
[CXX98CompatBindToTemporaryCopy]>;
def SelfAssignmentField : DiagGroup<"self-assign-field">;
Expand Down
6 changes: 3 additions & 3 deletions clang/include/clang/Basic/DiagnosticSemaKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -10248,14 +10248,14 @@ def warn_second_parameter_to_va_arg_never_compatible : Warning<

def warn_return_missing_expr : Warning<
"non-void %select{function|method}1 %0 should return a value">, DefaultError,
InGroup<ReturnType>;
InGroup<ReturnMismatch>;
def ext_return_missing_expr : ExtWarn<
"non-void %select{function|method}1 %0 should return a value">, DefaultError,
InGroup<ReturnType>;
InGroup<ReturnMismatch>;
def ext_return_has_expr : ExtWarn<
"%select{void function|void method|constructor|destructor}1 %0 "
"should not return a value">,
DefaultError, InGroup<ReturnType>;
DefaultError, InGroup<ReturnMismatch>;
def ext_return_has_void_expr : Extension<
"void %select{function|method|block}1 %0 should not return void expression">;
def err_return_init_list : Error<
Expand Down
14 changes: 14 additions & 0 deletions clang/include/clang/InstallAPI/Visitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "llvm/ADT/Twine.h"

namespace clang {
struct AvailabilityInfo;
namespace installapi {

/// ASTVisitor for collecting declarations that represent global symbols.
Expand All @@ -33,6 +34,7 @@ class InstallAPIVisitor final : public ASTConsumer,
MC(ItaniumMangleContext::create(ASTCtx, ASTCtx.getDiagnostics())),
Layout(ASTCtx.getTargetInfo().getDataLayoutString()) {}
void HandleTranslationUnit(ASTContext &ASTCtx) override;
bool shouldVisitTemplateInstantiations() const { return true; }

/// Collect global variables.
bool VisitVarDecl(const VarDecl *D);
Expand All @@ -51,16 +53,28 @@ class InstallAPIVisitor final : public ASTConsumer,
/// is therefore itself not collected.
bool VisitObjCCategoryDecl(const ObjCCategoryDecl *D);

/// Collect global c++ declarations.
bool VisitCXXRecordDecl(const CXXRecordDecl *D);

private:
std::string getMangledName(const NamedDecl *D) const;
std::string getBackendMangledName(llvm::Twine Name) const;
std::string getMangledCXXVTableName(const CXXRecordDecl *D) const;
std::string getMangledCXXThunk(const GlobalDecl &D,
const ThunkInfo &Thunk) const;
std::string getMangledCXXRTTI(const CXXRecordDecl *D) const;
std::string getMangledCXXRTTIName(const CXXRecordDecl *D) const;
std::string getMangledCtorDtor(const CXXMethodDecl *D, int Type) const;

std::optional<HeaderType> getAccessForDecl(const NamedDecl *D) const;
void recordObjCInstanceVariables(
const ASTContext &ASTCtx, llvm::MachO::ObjCContainerRecord *Record,
StringRef SuperClass,
const llvm::iterator_range<
DeclContext::specific_decl_iterator<ObjCIvarDecl>>
Ivars);
void emitVTableSymbols(const CXXRecordDecl *D, const AvailabilityInfo &Avail,
const HeaderType Access, bool EmittedVTable = false);

InstallAPIContext &Ctx;
SourceManager &SrcMgr;
Expand Down
5 changes: 5 additions & 0 deletions clang/lib/AST/DeclPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1517,6 +1517,11 @@ void DeclPrinter::VisitObjCInterfaceDecl(ObjCInterfaceDecl *OID) {
return;
}
bool eolnOut = false;
if (OID->hasAttrs()) {
prettyPrintAttributes(OID);
Out << "\n";
}

Out << "@interface " << I;

if (auto TypeParams = OID->getTypeParamListAsWritten()) {
Expand Down
105 changes: 93 additions & 12 deletions clang/lib/AST/Interp/ByteCodeExprGen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2959,6 +2959,8 @@ bool ByteCodeExprGen<Emitter>::VisitCXXThisExpr(const CXXThisExpr *E) {
template <class Emitter>
bool ByteCodeExprGen<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
const Expr *SubExpr = E->getSubExpr();
if (SubExpr->getType()->isAnyComplexType())
return this->VisitComplexUnaryOperator(E);
std::optional<PrimType> T = classify(SubExpr->getType());

switch (E->getOpcode()) {
Expand Down Expand Up @@ -3109,16 +3111,97 @@ bool ByteCodeExprGen<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
return false;
return DiscardResult ? this->emitPop(*T, E) : this->emitComp(*T, E);
case UO_Real: // __real x
if (T)
return this->delegate(SubExpr);
return this->emitComplexReal(SubExpr);
assert(T);
return this->delegate(SubExpr);
case UO_Imag: { // __imag x
if (T) {
if (!this->discard(SubExpr))
assert(T);
if (!this->discard(SubExpr))
return false;
return this->visitZeroInitializer(*T, SubExpr->getType(), SubExpr);
}
case UO_Extension:
return this->delegate(SubExpr);
case UO_Coawait:
assert(false && "Unhandled opcode");
}

return false;
}

template <class Emitter>
bool ByteCodeExprGen<Emitter>::VisitComplexUnaryOperator(
const UnaryOperator *E) {
const Expr *SubExpr = E->getSubExpr();
assert(SubExpr->getType()->isAnyComplexType());

if (DiscardResult)
return this->discard(SubExpr);

std::optional<PrimType> ResT = classify(E);
auto prepareResult = [=]() -> bool {
if (!ResT && !Initializing) {
std::optional<unsigned> LocalIndex =
allocateLocal(SubExpr, /*IsExtended=*/false);
if (!LocalIndex)
return false;
return this->emitGetPtrLocal(*LocalIndex, E);
}

return true;
};

// The offset of the temporary, if we created one.
unsigned SubExprOffset = ~0u;
auto createTemp = [=, &SubExprOffset]() -> bool {
SubExprOffset = this->allocateLocalPrimitive(SubExpr, PT_Ptr, true, false);
if (!this->visit(SubExpr))
return false;
return this->emitSetLocal(PT_Ptr, SubExprOffset, E);
};

PrimType ElemT = classifyComplexElementType(SubExpr->getType());
auto getElem = [=](unsigned Offset, unsigned Index) -> bool {
if (!this->emitGetLocal(PT_Ptr, Offset, E))
return false;
return this->emitArrayElemPop(ElemT, Index, E);
};

switch (E->getOpcode()) {
case UO_Minus:
if (!prepareResult())
return false;
if (!createTemp())
return false;
for (unsigned I = 0; I != 2; ++I) {
if (!getElem(SubExprOffset, I))
return false;
if (!this->emitNeg(ElemT, E))
return false;
if (!this->emitInitElem(ElemT, I, E))
return false;
return this->visitZeroInitializer(*T, SubExpr->getType(), SubExpr);
}
break;

case UO_Plus: // +x
case UO_AddrOf: // &x
case UO_Deref: // *x
return this->delegate(SubExpr);

case UO_LNot:
if (!this->visit(SubExpr))
return false;
if (!this->emitComplexBoolCast(SubExpr))
return false;
if (!this->emitInvBool(E))
return false;
if (PrimType ET = classifyPrim(E->getType()); ET != PT_Bool)
return this->emitCast(PT_Bool, ET, E);
return true;

case UO_Real:
return this->emitComplexReal(SubExpr);

case UO_Imag:
if (!this->visit(SubExpr))
return false;

Expand All @@ -3131,14 +3214,12 @@ bool ByteCodeExprGen<Emitter>::VisitUnaryOperator(const UnaryOperator *E) {
// Since our _Complex implementation does not map to a primitive type,
// we sometimes have to do the lvalue-to-rvalue conversion here manually.
return this->emitArrayElemPop(classifyPrim(E->getType()), 1, E);
}
case UO_Extension:
return this->delegate(SubExpr);
case UO_Coawait:
assert(false && "Unhandled opcode");

default:
return this->emitInvalid(E);
}

return false;
return true;
}

template <class Emitter>
Expand Down
1 change: 1 addition & 0 deletions clang/lib/AST/Interp/ByteCodeExprGen.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class ByteCodeExprGen : public ConstStmtVisitor<ByteCodeExprGen<Emitter>, bool>,
bool VisitGNUNullExpr(const GNUNullExpr *E);
bool VisitCXXThisExpr(const CXXThisExpr *E);
bool VisitUnaryOperator(const UnaryOperator *E);
bool VisitComplexUnaryOperator(const UnaryOperator *E);
bool VisitDeclRefExpr(const DeclRefExpr *E);
bool VisitImplicitValueInitExpr(const ImplicitValueInitExpr *E);
bool VisitSubstNonTypeTemplateParmExpr(const SubstNonTypeTemplateParmExpr *E);
Expand Down
21 changes: 21 additions & 0 deletions clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,15 @@
#include "llvm/Transforms/Instrumentation/MemProfiler.h"
#include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
#include "llvm/Transforms/Instrumentation/PGOInstrumentation.h"
#include "llvm/Transforms/Instrumentation/RemoveTrapsPass.h"
#include "llvm/Transforms/Instrumentation/SanitizerBinaryMetadata.h"
#include "llvm/Transforms/Instrumentation/SanitizerCoverage.h"
#include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
#include "llvm/Transforms/ObjCARC.h"
#include "llvm/Transforms/Scalar/EarlyCSE.h"
#include "llvm/Transforms/Scalar/GVN.h"
#include "llvm/Transforms/Scalar/JumpThreading.h"
#include "llvm/Transforms/Scalar/SimplifyCFG.h"
#include "llvm/Transforms/Utils/Debugify.h"
#include "llvm/Transforms/Utils/EntryExitInstrumenter.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
Expand All @@ -98,6 +100,10 @@ using namespace llvm;
namespace llvm {
extern cl::opt<bool> PrintPipelinePasses;

cl::opt<bool> ClRemoveTraps("clang-remove-traps", cl::Optional,
cl::desc("Insert remove-traps pass."),
cl::init(false));

// Experiment to move sanitizers earlier.
static cl::opt<bool> ClSanitizeOnOptimizerEarlyEP(
"sanitizer-early-opt-ep", cl::Optional,
Expand Down Expand Up @@ -744,6 +750,21 @@ static void addSanitizers(const Triple &TargetTriple,
// LastEP does not need GlobalsAA.
PB.registerOptimizerLastEPCallback(SanitizersCallback);
}

if (ClRemoveTraps) {
// We can optimize after inliner, and PGO profile matching. The hook below
// is called at the end `buildFunctionSimplificationPipeline`, which called
// from `buildInlinerPipeline`, which called after profile matching.
PB.registerScalarOptimizerLateEPCallback(
[](FunctionPassManager &FPM, OptimizationLevel Level) {
// RemoveTrapsPass expects trap blocks preceded by conditional
// branches, which usually is not the case without SimplifyCFG.
// TODO: Remove `SimplifyCFGPass` after switching to dedicated
// intrinsic.
FPM.addPass(SimplifyCFGPass());
FPM.addPass(RemoveTrapsPass());
});
}
}

void EmitAssemblyHelper::RunOptimizationPipeline(
Expand Down
Loading