Skip to content

Commit d8b8d84

Browse files
committed
[LLVMABI] Refactor
1 parent 2454dcf commit d8b8d84

29 files changed

+524
-94843
lines changed

APFloat.o

-197 KB
Binary file not shown.

clang/include/clang/CodeGen/QualTypeMapper.h

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,9 @@ class QualTypeMapper {
3333
clang::ASTContext &ASTCtx;
3434
llvm::abi::TypeBuilder Builder;
3535

36-
llvm::DenseMap<clang::QualType, const llvm::abi::Type *> TypeCache;
36+
llvm::DenseMap<QualType, const llvm::abi::Type *> TypeCache;
3737

38-
const llvm::abi::Type *convertBuiltinType(const clang::BuiltinType *BT,
39-
bool InMemory = false);
38+
const llvm::abi::Type *convertBuiltinType(const clang::BuiltinType *BT);
4039
const llvm::abi::Type *convertPointerType(const clang::PointerType *PT);
4140
const llvm::abi::Type *convertArrayType(const clang::ArrayType *AT);
4241
const llvm::abi::Type *convertVectorType(const clang::VectorType *VT);
@@ -48,12 +47,12 @@ class QualTypeMapper {
4847
convertMemberPointerType(const clang::MemberPointerType *MPT);
4948
const llvm::abi::Type *convertMatrixType(const ConstantMatrixType *MT);
5049

51-
const llvm::abi::StructType *convertStructType(const clang::RecordDecl *RD);
52-
const llvm::abi::StructType *convertUnionType(const clang::RecordDecl *RD,
53-
bool isTransparent = false);
50+
const llvm::abi::RecordType *convertStructType(const clang::RecordDecl *RD);
51+
const llvm::abi::RecordType *convertUnionType(const clang::RecordDecl *RD,
52+
bool IsTransparent = false);
5453
const llvm::abi::Type *createPointerTypeForPointee(QualType PointeeType);
55-
const llvm::abi::StructType *convertCXXRecordType(const CXXRecordDecl *RD,
56-
bool canPassInRegs);
54+
const llvm::abi::RecordType *convertCXXRecordType(const CXXRecordDecl *RD,
55+
bool CanPassInRegs);
5756

5857
void computeFieldInfo(const clang::RecordDecl *RD,
5958
SmallVectorImpl<llvm::abi::FieldInfo> &Fields,
@@ -69,7 +68,7 @@ class QualTypeMapper {
6968
explicit QualTypeMapper(clang::ASTContext &Ctx, llvm::BumpPtrAllocator &Alloc)
7069
: ASTCtx(Ctx), Builder(Alloc) {}
7170

72-
const llvm::abi::Type *convertType(clang::QualType QT, bool InMemory = false);
71+
const llvm::abi::Type *convertType(clang::QualType QT);
7372

7473
void clearCache() { TypeCache.clear(); }
7574

clang/lib/CodeGen/CGCall.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@
4646
#include "llvm/IR/IntrinsicInst.h"
4747
#include "llvm/IR/Intrinsics.h"
4848
#include "llvm/IR/Type.h"
49-
#include "llvm/Support/Allocator.h"
50-
#include "llvm/Support/raw_ostream.h"
5149
#include "llvm/TargetParser/Triple.h"
5250
#include "llvm/Transforms/Utils/Local.h"
5351
#include <optional>
@@ -1055,13 +1053,13 @@ const CGFunctionInfo &CodeGenTypes::arrangeLLVMFunctionInfo(
10551053
FI = CGFunctionInfo::create(CC, isInstanceMethod, isChainCall, isDelegateCall,
10561054
info, paramInfos, resultType, argTypes, required);
10571055

1056+
FunctionInfos.InsertNode(FI, insertPos);
10581057
std::unique_ptr<llvm::abi::ABIFunctionInfo> tempFI;
10591058

10601059
bool inserted = FunctionsBeingProcessed.insert(FI).second;
10611060
(void)inserted;
10621061
assert(inserted && "Recursively being processed?");
10631062

1064-
10651063
// Compute ABI information.
10661064
if (CC == llvm::CallingConv::SPIR_KERNEL) {
10671065
// Force target independent argument handling for the host visible
@@ -1070,24 +1068,25 @@ const CGFunctionInfo &CodeGenTypes::arrangeLLVMFunctionInfo(
10701068
} else if (info.getCC() == CC_Swift || info.getCC() == CC_SwiftAsync) {
10711069
swiftcall::computeABIInfo(CGM, *FI);
10721070
} else {
1073-
if (CGM.shouldUseLLVMABI()) {
1071+
if (CGM.shouldUseLLVMABI() &&
1072+
(CC == llvm::CallingConv::X86_64_SysV || CC == llvm::CallingConv::C)) {
10741073
SmallVector<const llvm::abi::Type *, 8> MappedArgTypes;
10751074
for (CanQualType ArgType : argTypes)
10761075
MappedArgTypes.push_back(Mapper.convertType(ArgType));
10771076
tempFI.reset(llvm::abi::ABIFunctionInfo::create(
10781077
CC, Mapper.convertType(resultType), MappedArgTypes));
1079-
FunctionInfos.InsertNode(FI, insertPos);
10801078

10811079
CGM.fetchABIInfo(TB).computeInfo(*tempFI);
1082-
} else
1080+
} else
10831081
CGM.getABIInfo().computeInfo(*FI);
10841082
}
10851083

1086-
10871084
// Loop over all of the computed argument and return value info. If any of
10881085
// them are direct or extend without a specified coerce type, specify the
10891086
// default now.
1090-
if (CGM.shouldUseLLVMABI() && tempFI) {
1087+
if (CGM.shouldUseLLVMABI() &&
1088+
(CC == llvm::CallingConv::X86_64_SysV || CC == llvm::CallingConv::C) &&
1089+
tempFI) {
10911090

10921091
const auto &abiRetInfo = tempFI->getReturnInfo();
10931092
ABIArgInfo &cgRetInfo = FI->getReturnInfo();

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -470,12 +470,11 @@ CodeGenModule::CodeGenModule(ASTContext &C,
470470
SanitizerMD(new SanitizerMetadata(*this)),
471471
AtomicOpts(Target.getAtomicOpts()) {
472472

473-
474473
// Flag to use the new LLVM ABI Library :)
475474
const llvm::Triple &Triple = Target.getTriple();
476-
ShouldUseLLVMABI = Triple.isBPF() ||
477-
(Triple.getArch() == llvm::Triple::x86_64 &&
478-
Triple.isOSLinux());
475+
ShouldUseLLVMABI =
476+
Triple.isBPF() ||
477+
(Triple.getArch() == llvm::Triple::x86_64 && Triple.isOSLinux());
479478
// Initialize the type cache.
480479
Types.reset(new CodeGenTypes(*this));
481480
llvm::LLVMContext &LLVMContext = M.getContext();

clang/lib/CodeGen/CodeGenTypes.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include "llvm/IR/DataLayout.h"
2828
#include "llvm/IR/DerivedTypes.h"
2929
#include "llvm/IR/Module.h"
30-
#include "llvm/Support/Error.h"
3130

3231
using namespace clang;
3332
using namespace CodeGen;

clang/lib/CodeGen/CodeGenTypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class CodeGenTypes {
9999
mutable llvm::BumpPtrAllocator Alloc;
100100
mutable llvm::abi::TypeBuilder TB;
101101
mutable QualTypeMapper Mapper;
102-
llvm::ABITypeMapper ReverseMapper;
102+
llvm::abi::ABITypeMapper ReverseMapper;
103103

104104
public:
105105
CodeGenTypes(CodeGenModule &cgm);

0 commit comments

Comments
 (0)