Skip to content

Commit fa92cae

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:1a7776abe6ca01996e8050dcdc8350d686a5749f into amd-gfx:f9257e604e76
Local branch amd-gfx f9257e6 Merged main:15d9d0fa8f55936625882a28759f0ec0033cb6de into amd-gfx:df9c746d9591 Remote branch main 1a7776a Reland "[scudo] Store more blocks in each TransferBatch" (llvm#83078) (llvm#83081)
2 parents f9257e6 + 1a7776a commit fa92cae

File tree

204 files changed

+4343
-1598
lines changed

Some content is hidden

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

204 files changed

+4343
-1598
lines changed

clang/include/clang/InstallAPI/Context.h

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
#ifndef LLVM_CLANG_INSTALLAPI_CONTEXT_H
1010
#define LLVM_CLANG_INSTALLAPI_CONTEXT_H
1111

12+
#include "clang/Basic/Diagnostic.h"
13+
#include "clang/Basic/FileManager.h"
14+
#include "clang/InstallAPI/HeaderFile.h"
1215
#include "llvm/TextAPI/InterfaceFile.h"
1316
#include "llvm/TextAPI/RecordVisitor.h"
1417
#include "llvm/TextAPI/RecordsSlice.h"
@@ -24,8 +27,23 @@ struct InstallAPIContext {
2427
/// Library attributes that are typically passed as linker inputs.
2528
llvm::MachO::RecordsSlice::BinaryAttrs BA;
2629

27-
/// Active target triple to parse.
28-
llvm::Triple TargetTriple{};
30+
/// All headers that represent a library.
31+
HeaderSeq InputHeaders;
32+
33+
/// Active language mode to parse in.
34+
Language LangMode = Language::ObjC;
35+
36+
/// Active header access type.
37+
HeaderType Type = HeaderType::Unknown;
38+
39+
/// Active TargetSlice for symbol record collection.
40+
std::shared_ptr<llvm::MachO::RecordsSlice> Slice;
41+
42+
/// FileManager for all I/O operations.
43+
FileManager *FM = nullptr;
44+
45+
/// DiagnosticsEngine for all error reporting.
46+
DiagnosticsEngine *Diags = nullptr;
2947

3048
/// File Path of output location.
3149
llvm::StringRef OutputLoc{};
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
//===- InstallAPI/Frontend.h -----------------------------------*- 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+
/// Top level wrappers for InstallAPI frontend operations.
10+
///
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef LLVM_CLANG_INSTALLAPI_FRONTEND_H
14+
#define LLVM_CLANG_INSTALLAPI_FRONTEND_H
15+
16+
#include "clang/AST/ASTConsumer.h"
17+
#include "clang/Frontend/CompilerInstance.h"
18+
#include "clang/Frontend/FrontendActions.h"
19+
#include "clang/InstallAPI/Context.h"
20+
#include "clang/InstallAPI/Visitor.h"
21+
#include "llvm/ADT/Twine.h"
22+
#include "llvm/Support/MemoryBuffer.h"
23+
24+
namespace clang {
25+
namespace installapi {
26+
27+
/// Create a buffer that contains all headers to scan
28+
/// for global symbols with.
29+
std::unique_ptr<llvm::MemoryBuffer>
30+
createInputBuffer(const InstallAPIContext &Ctx);
31+
32+
class InstallAPIAction : public ASTFrontendAction {
33+
public:
34+
explicit InstallAPIAction(llvm::MachO::RecordsSlice &Records)
35+
: Records(Records) {}
36+
37+
std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
38+
StringRef InFile) override {
39+
return std::make_unique<InstallAPIVisitor>(CI.getASTContext(), Records);
40+
}
41+
42+
private:
43+
llvm::MachO::RecordsSlice &Records;
44+
};
45+
} // namespace installapi
46+
} // namespace clang
47+
48+
#endif // LLVM_CLANG_INSTALLAPI_FRONTEND_H

clang/include/clang/InstallAPI/HeaderFile.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
#include "clang/Basic/LangStandard.h"
1717
#include "llvm/ADT/StringRef.h"
18+
#include "llvm/Support/ErrorHandling.h"
1819
#include "llvm/Support/Regex.h"
1920
#include <optional>
2021
#include <string>
@@ -32,6 +33,20 @@ enum class HeaderType {
3233
Project,
3334
};
3435

36+
inline StringRef getName(const HeaderType T) {
37+
switch (T) {
38+
case HeaderType::Public:
39+
return "Public";
40+
case HeaderType::Private:
41+
return "Private";
42+
case HeaderType::Project:
43+
return "Project";
44+
case HeaderType::Unknown:
45+
return "Unknown";
46+
}
47+
llvm_unreachable("unexpected header type");
48+
}
49+
3550
class HeaderFile {
3651
/// Full input path to header.
3752
std::string FullPath;
@@ -52,6 +67,14 @@ class HeaderFile {
5267

5368
static llvm::Regex getFrameworkIncludeRule();
5469

70+
HeaderType getType() const { return Type; }
71+
StringRef getIncludeName() const { return IncludeName; }
72+
StringRef getPath() const { return FullPath; }
73+
74+
bool useIncludeName() const {
75+
return Type != HeaderType::Project && !IncludeName.empty();
76+
}
77+
5578
bool operator==(const HeaderFile &Other) const {
5679
return std::tie(Type, FullPath, IncludeName, Language) ==
5780
std::tie(Other.Type, Other.FullPath, Other.IncludeName,
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
//===- InstallAPI/Visitor.h -----------------------------------*- 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+
/// ASTVisitor Interface for InstallAPI frontend operations.
10+
///
11+
//===----------------------------------------------------------------------===//
12+
13+
#ifndef LLVM_CLANG_INSTALLAPI_VISITOR_H
14+
#define LLVM_CLANG_INSTALLAPI_VISITOR_H
15+
16+
#include "clang/AST/Mangle.h"
17+
#include "clang/AST/RecursiveASTVisitor.h"
18+
#include "clang/Basic/TargetInfo.h"
19+
#include "clang/Frontend/FrontendActions.h"
20+
#include "llvm/ADT/Twine.h"
21+
#include "llvm/TextAPI/RecordsSlice.h"
22+
23+
namespace clang {
24+
namespace installapi {
25+
26+
/// ASTVisitor for collecting declarations that represent global symbols.
27+
class InstallAPIVisitor final : public ASTConsumer,
28+
public RecursiveASTVisitor<InstallAPIVisitor> {
29+
public:
30+
InstallAPIVisitor(ASTContext &ASTCtx, llvm::MachO::RecordsSlice &Slice)
31+
: Slice(Slice),
32+
MC(ItaniumMangleContext::create(ASTCtx, ASTCtx.getDiagnostics())),
33+
Layout(ASTCtx.getTargetInfo().getDataLayoutString()) {}
34+
void HandleTranslationUnit(ASTContext &ASTCtx) override;
35+
36+
/// Collect global variables.
37+
bool VisitVarDecl(const VarDecl *D);
38+
39+
private:
40+
std::string getMangledName(const NamedDecl *D) const;
41+
std::string getBackendMangledName(llvm::Twine Name) const;
42+
43+
llvm::MachO::RecordsSlice &Slice;
44+
std::unique_ptr<clang::ItaniumMangleContext> MC;
45+
StringRef Layout;
46+
};
47+
48+
} // namespace installapi
49+
} // namespace clang
50+
51+
#endif // LLVM_CLANG_INSTALLAPI_VISITOR_H

clang/lib/AST/Interp/Interp.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1680,7 +1680,7 @@ bool CastFloatingIntegral(InterpState &S, CodePtr OpPC) {
16801680
auto Status = F.convertToInteger(Result);
16811681

16821682
// Float-to-Integral overflow check.
1683-
if ((Status & APFloat::opStatus::opInvalidOp) && F.isFinite()) {
1683+
if ((Status & APFloat::opStatus::opInvalidOp)) {
16841684
const Expr *E = S.Current->getExpr(OpPC);
16851685
QualType Type = E->getType();
16861686

@@ -1933,7 +1933,7 @@ inline bool ArrayElemPop(InterpState &S, CodePtr OpPC, uint32_t Index) {
19331933
inline bool ArrayDecay(InterpState &S, CodePtr OpPC) {
19341934
const Pointer &Ptr = S.Stk.pop<Pointer>();
19351935

1936-
if (Ptr.isDummy()) {
1936+
if (Ptr.isZero() || Ptr.isDummy()) {
19371937
S.Stk.push<Pointer>(Ptr);
19381938
return true;
19391939
}

clang/lib/AST/Interp/Pointer.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ class Pointer {
215215
assert(Offset == PastEndMark && "cannot get base of a block");
216216
return Pointer(Pointee, Base, 0);
217217
}
218-
assert(Offset == Base && "not an inner field");
219218
unsigned NewBase = Base - getInlineDesc()->Offset;
220219
return Pointer(Pointee, NewBase, NewBase);
221220
}

clang/lib/CodeGen/ABIInfo.cpp

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,58 @@ ABIArgInfo ABIInfo::getNaturalAlignIndirectInReg(QualType Ty,
184184
/*ByVal*/ false, Realign);
185185
}
186186

187+
void ABIInfo::appendAttributeMangling(TargetAttr *Attr,
188+
raw_ostream &Out) const {
189+
if (Attr->isDefaultVersion())
190+
return;
191+
appendAttributeMangling(Attr->getFeaturesStr(), Out);
192+
}
193+
194+
void ABIInfo::appendAttributeMangling(TargetVersionAttr *Attr,
195+
raw_ostream &Out) const {
196+
appendAttributeMangling(Attr->getNamesStr(), Out);
197+
}
198+
199+
void ABIInfo::appendAttributeMangling(TargetClonesAttr *Attr, unsigned Index,
200+
raw_ostream &Out) const {
201+
appendAttributeMangling(Attr->getFeatureStr(Index), Out);
202+
Out << '.' << Attr->getMangledIndex(Index);
203+
}
204+
205+
void ABIInfo::appendAttributeMangling(StringRef AttrStr,
206+
raw_ostream &Out) const {
207+
if (AttrStr == "default") {
208+
Out << ".default";
209+
return;
210+
}
211+
212+
Out << '.';
213+
const TargetInfo &TI = CGT.getTarget();
214+
ParsedTargetAttr Info = TI.parseTargetAttr(AttrStr);
215+
216+
llvm::sort(Info.Features, [&TI](StringRef LHS, StringRef RHS) {
217+
// Multiversioning doesn't allow "no-${feature}", so we can
218+
// only have "+" prefixes here.
219+
assert(LHS.starts_with("+") && RHS.starts_with("+") &&
220+
"Features should always have a prefix.");
221+
return TI.multiVersionSortPriority(LHS.substr(1)) >
222+
TI.multiVersionSortPriority(RHS.substr(1));
223+
});
224+
225+
bool IsFirst = true;
226+
if (!Info.CPU.empty()) {
227+
IsFirst = false;
228+
Out << "arch_" << Info.CPU;
229+
}
230+
231+
for (StringRef Feat : Info.Features) {
232+
if (!IsFirst)
233+
Out << '_';
234+
IsFirst = false;
235+
Out << Feat.substr(1);
236+
}
237+
}
238+
187239
// Pin the vtable to this file.
188240
SwiftABIInfo::~SwiftABIInfo() = default;
189241

clang/lib/CodeGen/ABIInfo.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#ifndef LLVM_CLANG_LIB_CODEGEN_ABIINFO_H
1010
#define LLVM_CLANG_LIB_CODEGEN_ABIINFO_H
1111

12+
#include "clang/AST/Attr.h"
1213
#include "clang/AST/CharUnits.h"
1314
#include "clang/AST/Type.h"
1415
#include "llvm/IR/CallingConv.h"
@@ -111,6 +112,15 @@ class ABIInfo {
111112

112113
CodeGen::ABIArgInfo getNaturalAlignIndirectInReg(QualType Ty,
113114
bool Realign = false) const;
115+
116+
virtual void appendAttributeMangling(TargetAttr *Attr,
117+
raw_ostream &Out) const;
118+
virtual void appendAttributeMangling(TargetVersionAttr *Attr,
119+
raw_ostream &Out) const;
120+
virtual void appendAttributeMangling(TargetClonesAttr *Attr, unsigned Index,
121+
raw_ostream &Out) const;
122+
virtual void appendAttributeMangling(StringRef AttrStr,
123+
raw_ostream &Out) const;
114124
};
115125

116126
/// Target specific hooks for defining how a type should be passed or returned

0 commit comments

Comments
 (0)