Skip to content

Commit e33ada5

Browse files
committed
Merge from 'main' to 'sycl-web' (59 commits)
CONFLICT (content): Merge conflict in llvm/lib/Transforms/Utils/BuildLibCalls.cpp
2 parents b0f0f8f + f205950 commit e33ada5

File tree

317 files changed

+12062
-6820
lines changed

Some content is hidden

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

317 files changed

+12062
-6820
lines changed

bolt/include/bolt/Rewrite/RewriteInstance.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,6 @@ class RewriteInstance {
400400
/// Manage a pipeline of metadata handlers.
401401
class MetadataManager MetadataManager;
402402

403-
/// Get the contents of the LSDA section for this binary.
404-
ArrayRef<uint8_t> getLSDAData();
405-
406-
/// Get the mapped address of the LSDA section for this binary.
407-
uint64_t getLSDAAddress();
408-
409403
static const char TimerGroupName[];
410404

411405
static const char TimerGroupDesc[];
@@ -550,7 +544,6 @@ class RewriteInstance {
550544
}
551545

552546
/// Exception handling and stack unwinding information in this binary.
553-
ErrorOr<BinarySection &> LSDASection{std::errc::bad_address};
554547
ErrorOr<BinarySection &> EHFrameSection{std::errc::bad_address};
555548

556549
/// .note.gnu.build-id section.

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1784,13 +1784,6 @@ void RewriteInstance::relocateEHFrameSection() {
17841784
check_error(std::move(E), "failed to patch EH frame");
17851785
}
17861786

1787-
ArrayRef<uint8_t> RewriteInstance::getLSDAData() {
1788-
return ArrayRef<uint8_t>(LSDASection->getData(),
1789-
LSDASection->getContents().size());
1790-
}
1791-
1792-
uint64_t RewriteInstance::getLSDAAddress() { return LSDASection->getAddress(); }
1793-
17941787
Error RewriteInstance::readSpecialSections() {
17951788
NamedRegionTimer T("readSpecialSections", "read special sections",
17961789
TimerGroupName, TimerGroupDesc, opts::TimeRewrite);
@@ -1829,7 +1822,6 @@ Error RewriteInstance::readSpecialSections() {
18291822

18301823
HasTextRelocations = (bool)BC->getUniqueSectionByName(".rela.text");
18311824
HasSymbolTable = (bool)BC->getUniqueSectionByName(".symtab");
1832-
LSDASection = BC->getUniqueSectionByName(".gcc_except_table");
18331825
EHFrameSection = BC->getUniqueSectionByName(".eh_frame");
18341826
BuildIDSection = BC->getUniqueSectionByName(".note.gnu.build-id");
18351827

@@ -3200,8 +3192,14 @@ void RewriteInstance::disassembleFunctions() {
32003192

32013193
// Parse LSDA.
32023194
if (Function.getLSDAAddress() != 0 &&
3203-
!BC->getFragmentsToSkip().count(&Function))
3204-
Function.parseLSDA(getLSDAData(), getLSDAAddress());
3195+
!BC->getFragmentsToSkip().count(&Function)) {
3196+
ErrorOr<BinarySection &> LSDASection =
3197+
BC->getSectionForAddress(Function.getLSDAAddress());
3198+
check_error(LSDASection.getError(), "failed to get LSDA section");
3199+
ArrayRef<uint8_t> LSDAData = ArrayRef<uint8_t>(
3200+
LSDASection->getData(), LSDASection->getContents().size());
3201+
Function.parseLSDA(LSDAData, LSDASection->getAddress());
3202+
}
32053203
}
32063204
}
32073205

bolt/test/Inputs/lsda.ldscript

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
SECTIONS {
2+
.text : { *(.text*) }
3+
.gcc_except_table.main : { *(.gcc_except_table*) }
4+
. = 0x20000;
5+
.eh_frame : { *(.eh_frame) }
6+
. = 0x80000;
7+
}

bolt/test/lsda.cpp

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// This test check that LSDA section named by .gcc_except_table.main is
2+
// disassembled by BOLT.
3+
4+
// RUN: %clang++ %cxxflags -O3 -flto=thin -no-pie -c %s -o %t.o
5+
// RUN: %clang++ %cxxflags -flto=thin -no-pie -fuse-ld=lld %t.o -o %t.exe \
6+
// RUN: -Wl,-q -Wl,--script=%S/Inputs/lsda.ldscript
7+
// RUN: llvm-readelf -SW %t.exe | FileCheck %s
8+
// RUN: llvm-bolt %t.exe -o %t.bolt
9+
10+
// CHECK: .gcc_except_table.main
11+
12+
#include <iostream>
13+
14+
class MyException : public std::exception {
15+
public:
16+
const char *what() const throw() {
17+
return "Custom Exception: an error occurred!";
18+
}
19+
};
20+
21+
int divide(int a, int b) {
22+
if (b == 0) {
23+
throw MyException();
24+
}
25+
return a / b;
26+
}
27+
28+
int main() {
29+
try {
30+
int result = divide(10, 2); // normal case
31+
std::cout << "Result: " << result << std::endl;
32+
result = divide(5, 0); // will cause exception
33+
std::cout << "Result: " << result << std::endl;
34+
// this line will not execute
35+
} catch (const MyException &e) {
36+
// catch custom exception
37+
std::cerr << "Caught exception: " << e.what() << std::endl;
38+
} catch (const std::exception &e) {
39+
// catch other C++ exceptions
40+
std::cerr << "Caught exception: " << e.what() << std::endl;
41+
} catch (...) {
42+
// catch all other exceptions
43+
std::cerr << "Caught unknown exception" << std::endl;
44+
}
45+
46+
return 0;
47+
}

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6472,7 +6472,7 @@ def warn_superclass_variable_sized_type_not_at_end : Warning<
64726472
" in superclass %3">, InGroup<ObjCFlexibleArray>;
64736473

64746474
def err_counted_by_attr_not_on_flexible_array_member : Error<
6475-
"'counted_by' only applies to flexible array members">;
6475+
"'counted_by' only applies to C99 flexible array members">;
64766476
def err_counted_by_attr_refers_to_flexible_array : Error<
64776477
"'counted_by' cannot refer to the flexible array %0">;
64786478
def err_counted_by_must_be_in_structure : Error<

clang/include/clang/Driver/Options.td

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7100,9 +7100,6 @@ def vectorize_loops : Flag<["-"], "vectorize-loops">,
71007100
def vectorize_slp : Flag<["-"], "vectorize-slp">,
71017101
HelpText<"Run the SLP vectorization passes">,
71027102
MarshallingInfoFlag<CodeGenOpts<"VectorizeSLP">>;
7103-
def dependent_lib : Joined<["--"], "dependent-lib=">,
7104-
HelpText<"Add dependent library">,
7105-
MarshallingInfoStringVector<CodeGenOpts<"DependentLibraries">>;
71067103
def linker_option : Joined<["--"], "linker-option=">,
71077104
HelpText<"Add linker option">,
71087105
MarshallingInfoStringVector<CodeGenOpts<"LinkerOptions">>;
@@ -7682,6 +7679,11 @@ def pic_is_pie : Flag<["-"], "pic-is-pie">,
76827679
HelpText<"File is for a position independent executable">,
76837680
MarshallingInfoFlag<LangOpts<"PIE">>;
76847681

7682+
7683+
def dependent_lib : Joined<["--"], "dependent-lib=">,
7684+
HelpText<"Add dependent library">,
7685+
MarshallingInfoStringVector<CodeGenOpts<"DependentLibraries">>;
7686+
76857687
} // let Visibility = [CC1Option, FC1Option]
76867688

76877689
let Visibility = [CC1Option] in {

clang/lib/AST/DeclBase.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,6 @@ bool Decl::isFlexibleArrayMemberLike(
421421
using FAMKind = LangOptions::StrictFlexArraysLevelKind;
422422

423423
llvm::APInt Size = CAT->getSize();
424-
FAMKind StrictFlexArraysLevel =
425-
Ctx.getLangOpts().getStrictFlexArraysLevel();
426-
427424
if (StrictFlexArraysLevel == FAMKind::IncompleteOnly)
428425
return false;
429426

clang/lib/AST/Interp/Pointer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ class Pointer {
279279
return getFieldDesc()->isUnknownSizeArray();
280280
}
281281
/// Checks if the pointer points to an array.
282-
bool isArrayElement() const { return Base != Offset; }
282+
bool isArrayElement() const { return inArray() && Base != Offset; }
283283
/// Pointer points directly to a block.
284284
bool isRoot() const {
285285
return (Base == 0 || Base == RootPtrMark) && Offset == 0;

clang/lib/CodeGen/CGDebugInfo.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1732,10 +1732,13 @@ CGDebugInfo::CreateRecordStaticField(const VarDecl *Var, llvm::DIType *RecordTy,
17321732
StringRef VName = Var->getName();
17331733

17341734
llvm::DINode::DIFlags Flags = getAccessFlag(Var->getAccess(), RD);
1735+
auto Tag = CGM.getCodeGenOpts().DwarfVersion >= 5
1736+
? llvm::dwarf::DW_TAG_variable
1737+
: llvm::dwarf::DW_TAG_member;
17351738
auto Align = getDeclAlignIfRequired(Var, CGM.getContext());
1736-
llvm::DIDerivedType *GV = DBuilder.createStaticMemberType(
1737-
RecordTy, VName, VUnit, LineNumber, VTy, Flags, /* Val */ nullptr,
1738-
llvm::dwarf::DW_TAG_member, Align);
1739+
llvm::DIDerivedType *GV =
1740+
DBuilder.createStaticMemberType(RecordTy, VName, VUnit, LineNumber, VTy,
1741+
Flags, /* Val */ nullptr, Tag, Align);
17391742
StaticDataMemberCache[Var->getCanonicalDecl()].reset(GV);
17401743
StaticDataMemberDefinitionsToEmit.push_back(Var->getCanonicalDecl());
17411744
return GV;
@@ -5883,8 +5886,13 @@ void CGDebugInfo::setDwoId(uint64_t Signature) {
58835886
}
58845887

58855888
void CGDebugInfo::finalize() {
5886-
for (auto const *VD : StaticDataMemberDefinitionsToEmit) {
5887-
assert(VD->isStaticDataMember());
5889+
// We can't use a for-each here because `EmitGlobalVariable`
5890+
// may push new decls into `StaticDataMemberDefinitionsToEmit`,
5891+
// which would invalidate any iterator.
5892+
for (size_t i = 0; i < StaticDataMemberDefinitionsToEmit.size(); ++i) {
5893+
auto const *VD = StaticDataMemberDefinitionsToEmit[i];
5894+
5895+
assert(VD && VD->isStaticDataMember());
58885896

58895897
if (DeclCache.contains(VD))
58905898
continue;

clang/lib/Driver/ToolChains/NetBSD.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ void netbsd::Linker::ConstructJob(Compilation &C, const JobAction &JA,
269269

270270
Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
271271
options::OPT_s, options::OPT_t, options::OPT_r});
272+
ToolChain.AddFilePathLibArgs(Args, CmdArgs);
272273

273274
bool NeedsSanitizerDeps = addSanitizerRuntimes(ToolChain, Args, CmdArgs);
274275
bool NeedsXRayDeps = addXRayRuntime(ToolChain, Args, CmdArgs);

0 commit comments

Comments
 (0)