aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp46
-rw-r--r--clang/lib/CodeGen/CGOpenMPRuntime.cpp214
-rw-r--r--clang/lib/CodeGen/CGOpenMPRuntime.h10
-rw-r--r--clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp61
-rw-r--r--clang/lib/CodeGen/CodeGenTypes.cpp51
5 files changed, 165 insertions, 217 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 6965c4a1209c2..703f5087370af 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -719,23 +719,39 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) {
case BuiltinType::Id: \
return getOrCreateStructPtrType("opencl_" #ExtType, Id##Ty);
#include "clang/Basic/OpenCLExtensionTypes.def"
- // TODO: real support for SVE types requires more infrastructure
- // to be added first. The types have a variable length and are
- // represented in debug info as types whose length depends on a
- // target-specific pseudo register.
-#define SVE_TYPE(Name, Id, SingletonId) \
- case BuiltinType::Id:
+
+#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
#include "clang/Basic/AArch64SVEACLETypes.def"
- {
- unsigned DiagID = CGM.getDiags().getCustomDiagID(
- DiagnosticsEngine::Error,
- "cannot yet generate debug info for SVE type '%0'");
- auto Name = BT->getName(CGM.getContext().getPrintingPolicy());
- CGM.getDiags().Report(DiagID) << Name;
- // Return something safe.
- return CreateType(cast<const BuiltinType>(CGM.getContext().IntTy));
- }
+ {
+ ASTContext::BuiltinVectorTypeInfo Info =
+ CGM.getContext().getBuiltinVectorTypeInfo(BT);
+ unsigned NumElemsPerVG = (Info.EC.Min * Info.NumVectors) / 2;
+
+ // Debuggers can't extract 1bit from a vector, so will display a
+ // bitpattern for svbool_t instead.
+ if (Info.ElementType == CGM.getContext().BoolTy) {
+ NumElemsPerVG /= 8;
+ Info.ElementType = CGM.getContext().UnsignedCharTy;
+ }
+
+ auto *LowerBound =
+ llvm::ConstantAsMetadata::get(llvm::ConstantInt::getSigned(
+ llvm::Type::getInt64Ty(CGM.getLLVMContext()), 0));
+ SmallVector<int64_t, 9> Expr(
+ {llvm::dwarf::DW_OP_constu, NumElemsPerVG, llvm::dwarf::DW_OP_bregx,
+ /* AArch64::VG */ 46, 0, llvm::dwarf::DW_OP_mul,
+ llvm::dwarf::DW_OP_constu, 1, llvm::dwarf::DW_OP_minus});
+ auto *UpperBound = DBuilder.createExpression(Expr);
+ llvm::Metadata *Subscript = DBuilder.getOrCreateSubrange(
+ /*count*/ nullptr, LowerBound, UpperBound, /*stride*/ nullptr);
+ llvm::DINodeArray SubscriptArray = DBuilder.getOrCreateArray(Subscript);
+ llvm::DIType *ElemTy =
+ getOrCreateType(Info.ElementType, TheCU->getFile());
+ auto Align = getTypeAlignIfRequired(BT, CGM.getContext());
+ return DBuilder.createVectorType(/*Size*/ 0, Align, ElemTy,
+ SubscriptArray);
+ }
case BuiltinType::UChar:
case BuiltinType::Char_U:
Encoding = llvm::dwarf::DW_ATE_unsigned_char;
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index a7e1fe8560b6e..14e0cba62b237 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -29,7 +29,6 @@
#include "llvm/ADT/SetOperations.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/Bitcode/BitcodeReader.h"
-#include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/GlobalValue.h"
@@ -1064,23 +1063,6 @@ CGOpenMPRuntime::CGOpenMPRuntime(CodeGenModule &CGM, StringRef FirstSeparator,
StringRef Separator)
: CGM(CGM), FirstSeparator(FirstSeparator), Separator(Separator),
OMPBuilder(CGM.getModule()), OffloadEntriesInfoManager(CGM) {
- ASTContext &C = CGM.getContext();
- RecordDecl *RD = C.buildImplicitRecord("ident_t");
- QualType KmpInt32Ty = C.getIntTypeForBitwidth(/*DestWidth=*/32, /*Signed=*/1);
- RD->startDefinition();
- // reserved_1
- addFieldToRecordDecl(C, RD, KmpInt32Ty);
- // flags
- addFieldToRecordDecl(C, RD, KmpInt32Ty);
- // reserved_2
- addFieldToRecordDecl(C, RD, KmpInt32Ty);
- // reserved_3
- addFieldToRecordDecl(C, RD, KmpInt32Ty);
- // psource
- addFieldToRecordDecl(C, RD, C.VoidPtrTy);
- RD->completeDefinition();
- IdentQTy = C.getRecordType(RD);
- IdentTy = CGM.getTypes().ConvertRecordDeclType(RD);
KmpCriticalNameTy = llvm::ArrayType::get(CGM.Int32Ty, /*NumElements*/ 8);
// Initialize Types used in OpenMPIRBuilder from OMPKinds.def
@@ -1397,39 +1379,6 @@ createConstantGlobalStructAndAddToParent(CodeGenModule &CGM, QualType Ty,
Fields.finishAndAddTo(Parent);
}
-Address CGOpenMPRuntime::getOrCreateDefaultLocation(unsigned Flags) {
- CharUnits Align = CGM.getContext().getTypeAlignInChars(IdentQTy);
- unsigned Reserved2Flags = getDefaultLocationReserved2Flags();
- FlagsTy FlagsKey(Flags, Reserved2Flags);
- llvm::Value *Entry = OpenMPDefaultLocMap.lookup(FlagsKey);
- if (!Entry) {
- if (!DefaultOpenMPPSource) {
- // Initialize default location for psource field of ident_t structure of
- // all ident_t objects. Format is ";file;function;line;column;;".
- // Taken from
- // https://github.com/llvm/llvm-project/blob/master/openmp/runtime/src/kmp_str.cpp
- DefaultOpenMPPSource =
- CGM.GetAddrOfConstantCString(";unknown;unknown;0;0;;").getPointer();
- DefaultOpenMPPSource =
- llvm::ConstantExpr::getBitCast(DefaultOpenMPPSource, CGM.Int8PtrTy);
- }
-
- llvm::Constant *Data[] = {
- llvm::ConstantInt::getNullValue(CGM.Int32Ty),
- llvm::ConstantInt::get(CGM.Int32Ty, Flags),
- llvm::ConstantInt::get(CGM.Int32Ty, Reserved2Flags),
- llvm::ConstantInt::getNullValue(CGM.Int32Ty), DefaultOpenMPPSource};
- llvm::GlobalValue *DefaultOpenMPLocation =
- createGlobalStruct(CGM, IdentQTy, isDefaultLocationConstant(), Data, "",
- llvm::GlobalValue::PrivateLinkage);
- DefaultOpenMPLocation->setUnnamedAddr(
- llvm::GlobalValue::UnnamedAddr::Global);
-
- OpenMPDefaultLocMap[FlagsKey] = Entry = DefaultOpenMPLocation;
- }
- return Address(Entry, Align);
-}
-
void CGOpenMPRuntime::setLocThreadIdInsertPt(CodeGenFunction &CGF,
bool AtCurrentPoint) {
auto &Elem = OpenMPLocThreadIDMap.FindAndConstruct(CGF.CurFn);
@@ -1458,62 +1407,24 @@ void CGOpenMPRuntime::clearLocThreadIdInsertPt(CodeGenFunction &CGF) {
llvm::Value *CGOpenMPRuntime::emitUpdateLocation(CodeGenFunction &CGF,
SourceLocation Loc,
unsigned Flags) {
- Flags |= OMP_IDENT_KMPC;
- // If no debug info is generated - return global default location.
+ llvm::Constant *SrcLocStr;
if (CGM.getCodeGenOpts().getDebugInfo() == codegenoptions::NoDebugInfo ||
- Loc.isInvalid())
- return getOrCreateDefaultLocation(Flags).getPointer();
-
- assert(CGF.CurFn && "No function in current CodeGenFunction.");
-
- CharUnits Align = CGM.getContext().getTypeAlignInChars(IdentQTy);
- Address LocValue = Address::invalid();
- auto I = OpenMPLocThreadIDMap.find(CGF.CurFn);
- if (I != OpenMPLocThreadIDMap.end())
- LocValue = Address(I->second.DebugLoc, Align);
-
- // OpenMPLocThreadIDMap may have null DebugLoc and non-null ThreadID, if
- // GetOpenMPThreadID was called before this routine.
- if (!LocValue.isValid()) {
- // Generate "ident_t .kmpc_loc.addr;"
- Address AI = CGF.CreateMemTemp(IdentQTy, ".kmpc_loc.addr");
- auto &Elem = OpenMPLocThreadIDMap.FindAndConstruct(CGF.CurFn);
- Elem.second.DebugLoc = AI.getPointer();
- LocValue = AI;
-
- if (!Elem.second.ServiceInsertPt)
- setLocThreadIdInsertPt(CGF);
- CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
- CGF.Builder.SetInsertPoint(Elem.second.ServiceInsertPt);
- CGF.Builder.CreateMemCpy(LocValue, getOrCreateDefaultLocation(Flags),
- CGF.getTypeSize(IdentQTy));
- }
-
- // char **psource = &.kmpc_loc_<flags>.addr.psource;
- LValue Base = CGF.MakeAddrLValue(LocValue, IdentQTy);
- auto Fields = cast<RecordDecl>(IdentQTy->getAsTagDecl())->field_begin();
- LValue PSource =
- CGF.EmitLValueForField(Base, *std::next(Fields, IdentField_PSource));
-
- llvm::Value *OMPDebugLoc = OpenMPDebugLocMap.lookup(Loc.getRawEncoding());
- if (OMPDebugLoc == nullptr) {
- SmallString<128> Buffer2;
- llvm::raw_svector_ostream OS2(Buffer2);
- // Build debug location
- PresumedLoc PLoc = CGF.getContext().getSourceManager().getPresumedLoc(Loc);
- OS2 << ";" << PLoc.getFilename() << ";";
+ Loc.isInvalid()) {
+ SrcLocStr = OMPBuilder.getOrCreateDefaultSrcLocStr();
+ } else {
+ std::string FunctionName = "";
if (const auto *FD = dyn_cast_or_null<FunctionDecl>(CGF.CurFuncDecl))
- OS2 << FD->getQualifiedNameAsString();
- OS2 << ";" << PLoc.getLine() << ";" << PLoc.getColumn() << ";;";
- OMPDebugLoc = CGF.Builder.CreateGlobalStringPtr(OS2.str());
- OpenMPDebugLocMap[Loc.getRawEncoding()] = OMPDebugLoc;
+ FunctionName = FD->getQualifiedNameAsString();
+ PresumedLoc PLoc = CGF.getContext().getSourceManager().getPresumedLoc(Loc);
+ const char *FileName = PLoc.getFilename();
+ unsigned Line = PLoc.getLine();
+ unsigned Column = PLoc.getColumn();
+ SrcLocStr = OMPBuilder.getOrCreateSrcLocStr(FunctionName.c_str(), FileName,
+ Line, Column);
}
- // *psource = ";<File>;<Function>;<Line>;<Column>;;";
- CGF.EmitStoreOfScalar(OMPDebugLoc, PSource);
-
- // Our callers always pass this to a runtime function, so for
- // convenience, go ahead and return a naked pointer.
- return LocValue.getPointer();
+ unsigned Reserved2Flags = getDefaultLocationReserved2Flags();
+ return OMPBuilder.getOrCreateIdent(SrcLocStr, llvm::omp::IdentFlag(Flags),
+ Reserved2Flags);
}
llvm::Value *CGOpenMPRuntime::getThreadID(CodeGenFunction &CGF,
@@ -1595,7 +1506,7 @@ void CGOpenMPRuntime::functionFinished(CodeGenFunction &CGF) {
}
llvm::Type *CGOpenMPRuntime::getIdentTyPointerTy() {
- return IdentTy->getPointerTo();
+ return OMPBuilder.IdentPtr;
}
llvm::Type *CGOpenMPRuntime::getKmpc_MicroPointerTy() {
@@ -7354,6 +7265,8 @@ private:
// &p, &p, sizeof(float*), TARGET_PARAM | TO | FROM
//
// map(p[1:24])
+ // &p, &p[1], 24*sizeof(float), TARGET_PARAM | TO | FROM | PTR_AND_OBJ
+ // in unified shared memory mode or for local pointers
// p, &p[1], 24*sizeof(float), TARGET_PARAM | TO | FROM
//
// map(s)
@@ -7489,6 +7402,7 @@ private:
// Track if the map information being generated is the first for a list of
// components.
bool IsExpressionFirstInfo = true;
+ bool FirstPointerInComplexData = false;
Address BP = Address::invalid();
const Expr *AssocExpr = I->getAssociatedExpression();
const auto *AE = dyn_cast<ArraySubscriptExpr>(AssocExpr);
@@ -7531,10 +7445,15 @@ private:
QualType Ty =
I->getAssociatedDeclaration()->getType().getNonReferenceType();
if (Ty->isAnyPointerType() && std::next(I) != CE) {
- BP = CGF.EmitLoadOfPointer(BP, Ty->castAs<PointerType>());
-
- // We do not need to generate individual map information for the
- // pointer, it can be associated with the combined storage.
+ // No need to generate individual map information for the pointer, it
+ // can be associated with the combined storage if shared memory mode is
+ // active or the base declaration is not global variable.
+ const auto *VD = dyn_cast<VarDecl>(I->getAssociatedDeclaration());
+ if (CGF.CGM.getOpenMPRuntime().hasRequiresUnifiedSharedMemory() ||
+ !VD || VD->hasLocalStorage())
+ BP = CGF.EmitLoadOfPointer(BP, Ty->castAs<PointerType>());
+ else
+ FirstPointerInComplexData = IsCaptureFirstInfo;
++I;
}
}
@@ -7570,8 +7489,19 @@ private:
EncounteredME = dyn_cast<MemberExpr>(I->getAssociatedExpression());
// If we encounter a PTR_AND_OBJ entry from now on it should be marked
// as MEMBER_OF the parent struct.
- if (EncounteredME)
+ if (EncounteredME) {
ShouldBeMemberOf = true;
+ // Do not emit as complex pointer if this is actually not array-like
+ // expression.
+ if (FirstPointerInComplexData) {
+ QualType Ty = std::prev(I)
+ ->getAssociatedDeclaration()
+ ->getType()
+ .getNonReferenceType();
+ BP = CGF.EmitLoadOfPointer(BP, Ty->castAs<PointerType>());
+ FirstPointerInComplexData = false;
+ }
+ }
}
auto Next = std::next(I);
@@ -7704,10 +7634,11 @@ private:
// same expression except for the first one. We also need to signal
// this map is the first one that relates with the current capture
// (there is a set of entries for each capture).
- OpenMPOffloadMappingFlags Flags = getMapTypeBits(
- MapType, MapModifiers, IsImplicit,
- !IsExpressionFirstInfo || RequiresReference,
- IsCaptureFirstInfo && !RequiresReference);
+ OpenMPOffloadMappingFlags Flags =
+ getMapTypeBits(MapType, MapModifiers, IsImplicit,
+ !IsExpressionFirstInfo || RequiresReference ||
+ FirstPointerInComplexData,
+ IsCaptureFirstInfo && !RequiresReference);
if (!IsExpressionFirstInfo) {
// If we have a PTR_AND_OBJ pair where the OBJ is a pointer as well,
@@ -7765,6 +7696,7 @@ private:
IsExpressionFirstInfo = false;
IsCaptureFirstInfo = false;
+ FirstPointerInComplexData = false;
}
}
}
@@ -7995,6 +7927,10 @@ public:
// emission of that entry until the whole struct has been processed.
llvm::MapVector<const ValueDecl *, SmallVector<DeferredDevicePtrEntryTy, 4>>
DeferredInfo;
+ MapBaseValuesArrayTy UseDevicePtrBasePointers;
+ MapValuesArrayTy UseDevicePtrPointers;
+ MapValuesArrayTy UseDevicePtrSizes;
+ MapFlagsArrayTy UseDevicePtrTypes;
for (const auto *C :
CurExecDir->getClausesOfKind<OMPUseDevicePtrClause>()) {
@@ -8011,15 +7947,27 @@ public:
// We potentially have map information for this declaration already.
// Look for the first set of components that refer to it.
if (It != Info.end()) {
- auto CI = std::find_if(
- It->second.begin(), It->second.end(), [VD](const MapInfo &MI) {
- return MI.Components.back().getAssociatedDeclaration() == VD;
- });
+ auto *CI = llvm::find_if(It->second, [VD](const MapInfo &MI) {
+ return MI.Components.back().getAssociatedDeclaration() == VD;
+ });
// If we found a map entry, signal that the pointer has to be returned
// and move on to the next declaration.
+ // Exclude cases where the base pointer is mapped as array subscript,
+ // array section or array shaping. The base address is passed as a
+ // pointer to base in this case and cannot be used as a base for
+ // use_device_ptr list item.
if (CI != It->second.end()) {
- CI->ReturnDevicePointer = true;
- continue;
+ auto PrevCI = std::next(CI->Components.rbegin());
+ const auto *VarD = dyn_cast<VarDecl>(VD);
+ if (CGF.CGM.getOpenMPRuntime().hasRequiresUnifiedSharedMemory() ||
+ isa<MemberExpr>(IE) ||
+ !VD->getType().getNonReferenceType()->isPointerType() ||
+ PrevCI == CI->Components.rend() ||
+ isa<MemberExpr>(PrevCI->getAssociatedExpression()) || !VarD ||
+ VarD->hasLocalStorage()) {
+ CI->ReturnDevicePointer = true;
+ continue;
+ }
}
}
@@ -8040,10 +7988,12 @@ public:
} else {
llvm::Value *Ptr =
CGF.EmitLoadOfScalar(CGF.EmitLValue(IE), IE->getExprLoc());
- BasePointers.emplace_back(Ptr, VD);
- Pointers.push_back(Ptr);
- Sizes.push_back(llvm::Constant::getNullValue(CGF.Int64Ty));
- Types.push_back(OMP_MAP_RETURN_PARAM | OMP_MAP_TARGET_PARAM);
+ UseDevicePtrBasePointers.emplace_back(Ptr, VD);
+ UseDevicePtrPointers.push_back(Ptr);
+ UseDevicePtrSizes.push_back(
+ llvm::Constant::getNullValue(CGF.Int64Ty));
+ UseDevicePtrTypes.push_back(OMP_MAP_RETURN_PARAM |
+ OMP_MAP_TARGET_PARAM);
}
}
}
@@ -8104,10 +8054,12 @@ public:
Ptr = CGF.EmitLValue(IE).getPointer(CGF);
else
Ptr = CGF.EmitScalarExpr(IE);
- BasePointers.emplace_back(Ptr, VD);
- Pointers.push_back(Ptr);
- Sizes.push_back(llvm::Constant::getNullValue(CGF.Int64Ty));
- Types.push_back(OMP_MAP_RETURN_PARAM | OMP_MAP_TARGET_PARAM);
+ UseDevicePtrBasePointers.emplace_back(Ptr, VD);
+ UseDevicePtrPointers.push_back(Ptr);
+ UseDevicePtrSizes.push_back(
+ llvm::Constant::getNullValue(CGF.Int64Ty));
+ UseDevicePtrTypes.push_back(OMP_MAP_RETURN_PARAM |
+ OMP_MAP_TARGET_PARAM);
}
}
}
@@ -8197,6 +8149,12 @@ public:
Sizes.append(CurSizes.begin(), CurSizes.end());
Types.append(CurTypes.begin(), CurTypes.end());
}
+ // Append data for use_device_ptr clauses.
+ BasePointers.append(UseDevicePtrBasePointers.begin(),
+ UseDevicePtrBasePointers.end());
+ Pointers.append(UseDevicePtrPointers.begin(), UseDevicePtrPointers.end());
+ Sizes.append(UseDevicePtrSizes.begin(), UseDevicePtrSizes.end());
+ Types.append(UseDevicePtrTypes.begin(), UseDevicePtrTypes.end());
}
/// Generate all the base pointers, section pointers, sizes and map types for
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.h b/clang/lib/CodeGen/CGOpenMPRuntime.h
index eb22f155f5ef4..cf3dbf59634d7 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.h
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.h
@@ -374,17 +374,7 @@ protected:
private:
/// An OpenMP-IR-Builder instance.
llvm::OpenMPIRBuilder OMPBuilder;
- /// Default const ident_t object used for initialization of all other
- /// ident_t objects.
- llvm::Constant *DefaultOpenMPPSource = nullptr;
- using FlagsTy = std::pair<unsigned, unsigned>;
- /// Map of flags and corresponding default locations.
- using OpenMPDefaultLocMapTy = llvm::DenseMap<FlagsTy, llvm::Value *>;
- OpenMPDefaultLocMapTy OpenMPDefaultLocMap;
- Address getOrCreateDefaultLocation(unsigned Flags);
- QualType IdentQTy;
- llvm::StructType *IdentTy = nullptr;
/// Map for SourceLocation and OpenMP runtime library debug locations.
typedef llvm::DenseMap<unsigned, llvm::Value *> OpenMPDebugLocMapTy;
OpenMPDebugLocMapTy OpenMPDebugLocMap;
diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
index 1f79b33772f38..de78926755df5 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp
@@ -2857,8 +2857,12 @@ static llvm::Value *castValueToType(CodeGenFunction &CGF, llvm::Value *Val,
Address CastItem = CGF.CreateMemTemp(CastTy);
Address ValCastItem = CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
CastItem, Val->getType()->getPointerTo(CastItem.getAddressSpace()));
- CGF.EmitStoreOfScalar(Val, ValCastItem, /*Volatile=*/false, ValTy);
- return CGF.EmitLoadOfScalar(CastItem, /*Volatile=*/false, CastTy, Loc);
+ CGF.EmitStoreOfScalar(Val, ValCastItem, /*Volatile=*/false, ValTy,
+ LValueBaseInfo(AlignmentSource::Type),
+ TBAAAccessInfo());
+ return CGF.EmitLoadOfScalar(CastItem, /*Volatile=*/false, CastTy, Loc,
+ LValueBaseInfo(AlignmentSource::Type),
+ TBAAAccessInfo());
}
/// This function creates calls to one of two shuffle functions to copy
@@ -2945,9 +2949,14 @@ static void shuffleAndStore(CodeGenFunction &CGF, Address SrcAddr,
ThenBB, ExitBB);
CGF.EmitBlock(ThenBB);
llvm::Value *Res = createRuntimeShuffleFunction(
- CGF, CGF.EmitLoadOfScalar(Ptr, /*Volatile=*/false, IntType, Loc),
+ CGF,
+ CGF.EmitLoadOfScalar(Ptr, /*Volatile=*/false, IntType, Loc,
+ LValueBaseInfo(AlignmentSource::Type),
+ TBAAAccessInfo()),
IntType, Offset, Loc);
- CGF.EmitStoreOfScalar(Res, ElemPtr, /*Volatile=*/false, IntType);
+ CGF.EmitStoreOfScalar(Res, ElemPtr, /*Volatile=*/false, IntType,
+ LValueBaseInfo(AlignmentSource::Type),
+ TBAAAccessInfo());
Address LocalPtr = Bld.CreateConstGEP(Ptr, 1);
Address LocalElemPtr = Bld.CreateConstGEP(ElemPtr, 1);
PhiSrc->addIncoming(LocalPtr.getPointer(), ThenBB);
@@ -2956,9 +2965,14 @@ static void shuffleAndStore(CodeGenFunction &CGF, Address SrcAddr,
CGF.EmitBlock(ExitBB);
} else {
llvm::Value *Res = createRuntimeShuffleFunction(
- CGF, CGF.EmitLoadOfScalar(Ptr, /*Volatile=*/false, IntType, Loc),
+ CGF,
+ CGF.EmitLoadOfScalar(Ptr, /*Volatile=*/false, IntType, Loc,
+ LValueBaseInfo(AlignmentSource::Type),
+ TBAAAccessInfo()),
IntType, Offset, Loc);
- CGF.EmitStoreOfScalar(Res, ElemPtr, /*Volatile=*/false, IntType);
+ CGF.EmitStoreOfScalar(Res, ElemPtr, /*Volatile=*/false, IntType,
+ LValueBaseInfo(AlignmentSource::Type),
+ TBAAAccessInfo());
Ptr = Bld.CreateConstGEP(Ptr, 1);
ElemPtr = Bld.CreateConstGEP(ElemPtr, 1);
}
@@ -3112,12 +3126,14 @@ static void emitReductionListCopy(
} else {
switch (CGF.getEvaluationKind(Private->getType())) {
case TEK_Scalar: {
- llvm::Value *Elem =
- CGF.EmitLoadOfScalar(SrcElementAddr, /*Volatile=*/false,
- Private->getType(), Private->getExprLoc());
+ llvm::Value *Elem = CGF.EmitLoadOfScalar(
+ SrcElementAddr, /*Volatile=*/false, Private->getType(),
+ Private->getExprLoc(), LValueBaseInfo(AlignmentSource::Type),
+ TBAAAccessInfo());
// Store the source element value to the dest element address.
- CGF.EmitStoreOfScalar(Elem, DestElementAddr, /*Volatile=*/false,
- Private->getType());
+ CGF.EmitStoreOfScalar(
+ Elem, DestElementAddr, /*Volatile=*/false, Private->getType(),
+ LValueBaseInfo(AlignmentSource::Type), TBAAAccessInfo());
break;
}
case TEK_Complex: {
@@ -3260,8 +3276,9 @@ static llvm::Value *emitInterWarpCopyFunction(CodeGenModule &CGM,
Address AddrReduceListArg = CGF.GetAddrOfLocalVar(&ReduceListArg);
Address LocalReduceList(
Bld.CreatePointerBitCastOrAddrSpaceCast(
- CGF.EmitLoadOfScalar(AddrReduceListArg, /*Volatile=*/false,
- C.VoidPtrTy, Loc),
+ CGF.EmitLoadOfScalar(
+ AddrReduceListArg, /*Volatile=*/false, C.VoidPtrTy, Loc,
+ LValueBaseInfo(AlignmentSource::Type), TBAAAccessInfo()),
CGF.ConvertTypeForMem(ReductionArrayTy)->getPointerTo()),
CGF.getPointerAlign());
@@ -3339,10 +3356,13 @@ static llvm::Value *emitInterWarpCopyFunction(CodeGenModule &CGM,
// elem = *elemptr
//*MediumPtr = elem
- llvm::Value *Elem =
- CGF.EmitLoadOfScalar(ElemPtr, /*Volatile=*/false, CType, Loc);
+ llvm::Value *Elem = CGF.EmitLoadOfScalar(
+ ElemPtr, /*Volatile=*/false, CType, Loc,
+ LValueBaseInfo(AlignmentSource::Type), TBAAAccessInfo());
// Store the source element value to the dest element address.
- CGF.EmitStoreOfScalar(Elem, MediumPtr, /*Volatile=*/true, CType);
+ CGF.EmitStoreOfScalar(Elem, MediumPtr, /*Volatile=*/true, CType,
+ LValueBaseInfo(AlignmentSource::Type),
+ TBAAAccessInfo());
Bld.CreateBr(MergeBB);
@@ -3722,8 +3742,9 @@ static llvm::Value *emitListToGlobalCopyFunction(
GlobLVal.setAddress(Address(BufferPtr, GlobLVal.getAlignment()));
switch (CGF.getEvaluationKind(Private->getType())) {
case TEK_Scalar: {
- llvm::Value *V = CGF.EmitLoadOfScalar(ElemPtr, /*Volatile=*/false,
- Private->getType(), Loc);
+ llvm::Value *V = CGF.EmitLoadOfScalar(
+ ElemPtr, /*Volatile=*/false, Private->getType(), Loc,
+ LValueBaseInfo(AlignmentSource::Type), TBAAAccessInfo());
CGF.EmitStoreOfScalar(V, GlobLVal);
break;
}
@@ -3926,7 +3947,9 @@ static llvm::Value *emitGlobalToListCopyFunction(
switch (CGF.getEvaluationKind(Private->getType())) {
case TEK_Scalar: {
llvm::Value *V = CGF.EmitLoadOfScalar(GlobLVal, Loc);
- CGF.EmitStoreOfScalar(V, ElemPtr, /*Volatile=*/false, Private->getType());
+ CGF.EmitStoreOfScalar(V, ElemPtr, /*Volatile=*/false, Private->getType(),
+ LValueBaseInfo(AlignmentSource::Type),
+ TBAAAccessInfo());
break;
}
case TEK_Complex: {
diff --git a/clang/lib/CodeGen/CodeGenTypes.cpp b/clang/lib/CodeGen/CodeGenTypes.cpp
index d431c0263666e..4792c10ecdaef 100644
--- a/clang/lib/CodeGen/CodeGenTypes.cpp
+++ b/clang/lib/CodeGen/CodeGenTypes.cpp
@@ -533,99 +533,60 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
case BuiltinType::OCLReserveID:
ResultType = CGM.getOpenCLRuntime().convertOpenCLSpecificType(Ty);
break;
-#define GET_SVE_INT_VEC(BITS, ELTS) \
- llvm::ScalableVectorType::get( \
- llvm::IntegerType::get(getLLVMContext(), BITS), ELTS);
case BuiltinType::SveInt8:
case BuiltinType::SveUint8:
- return GET_SVE_INT_VEC(8, 16);
case BuiltinType::SveInt8x2:
case BuiltinType::SveUint8x2:
- return GET_SVE_INT_VEC(8, 32);
case BuiltinType::SveInt8x3:
case BuiltinType::SveUint8x3:
- return GET_SVE_INT_VEC(8, 48);
case BuiltinType::SveInt8x4:
case BuiltinType::SveUint8x4:
- return GET_SVE_INT_VEC(8, 64);
case BuiltinType::SveInt16:
case BuiltinType::SveUint16:
- return GET_SVE_INT_VEC(16, 8);
case BuiltinType::SveInt16x2:
case BuiltinType::SveUint16x2:
- return GET_SVE_INT_VEC(16, 16);
case BuiltinType::SveInt16x3:
case BuiltinType::SveUint16x3:
- return GET_SVE_INT_VEC(16, 24);
case BuiltinType::SveInt16x4:
case BuiltinType::SveUint16x4:
- return GET_SVE_INT_VEC(16, 32);
case BuiltinType::SveInt32:
case BuiltinType::SveUint32:
- return GET_SVE_INT_VEC(32, 4);
case BuiltinType::SveInt32x2:
case BuiltinType::SveUint32x2:
- return GET_SVE_INT_VEC(32, 8);
case BuiltinType::SveInt32x3:
case BuiltinType::SveUint32x3:
- return GET_SVE_INT_VEC(32, 12);
case BuiltinType::SveInt32x4:
case BuiltinType::SveUint32x4:
- return GET_SVE_INT_VEC(32, 16);
case BuiltinType::SveInt64:
case BuiltinType::SveUint64:
- return GET_SVE_INT_VEC(64, 2);
case BuiltinType::SveInt64x2:
case BuiltinType::SveUint64x2:
- return GET_SVE_INT_VEC(64, 4);
case BuiltinType::SveInt64x3:
case BuiltinType::SveUint64x3:
- return GET_SVE_INT_VEC(64, 6);
case BuiltinType::SveInt64x4:
case BuiltinType::SveUint64x4:
- return GET_SVE_INT_VEC(64, 8);
case BuiltinType::SveBool:
- return GET_SVE_INT_VEC(1, 16);
-#undef GET_SVE_INT_VEC
-#define GET_SVE_FP_VEC(TY, ISFP16, ELTS) \
- llvm::ScalableVectorType::get( \
- getTypeForFormat(getLLVMContext(), \
- Context.getFloatTypeSemantics(Context.TY), \
- /* UseNativeHalf = */ ISFP16), \
- ELTS);
case BuiltinType::SveFloat16:
- return GET_SVE_FP_VEC(HalfTy, true, 8);
case BuiltinType::SveFloat16x2:
- return GET_SVE_FP_VEC(HalfTy, true, 16);
case BuiltinType::SveFloat16x3:
- return GET_SVE_FP_VEC(HalfTy, true, 24);
case BuiltinType::SveFloat16x4:
- return GET_SVE_FP_VEC(HalfTy, true, 32);
case BuiltinType::SveFloat32:
- return GET_SVE_FP_VEC(FloatTy, false, 4);
case BuiltinType::SveFloat32x2:
- return GET_SVE_FP_VEC(FloatTy, false, 8);
case BuiltinType::SveFloat32x3:
- return GET_SVE_FP_VEC(FloatTy, false, 12);
case BuiltinType::SveFloat32x4:
- return GET_SVE_FP_VEC(FloatTy, false, 16);
case BuiltinType::SveFloat64:
- return GET_SVE_FP_VEC(DoubleTy, false, 2);
case BuiltinType::SveFloat64x2:
- return GET_SVE_FP_VEC(DoubleTy, false, 4);
case BuiltinType::SveFloat64x3:
- return GET_SVE_FP_VEC(DoubleTy, false, 6);
case BuiltinType::SveFloat64x4:
- return GET_SVE_FP_VEC(DoubleTy, false, 8);
case BuiltinType::SveBFloat16:
- return GET_SVE_FP_VEC(BFloat16Ty, false, 8);
case BuiltinType::SveBFloat16x2:
- return GET_SVE_FP_VEC(BFloat16Ty, false, 16);
case BuiltinType::SveBFloat16x3:
- return GET_SVE_FP_VEC(BFloat16Ty, false, 24);
- case BuiltinType::SveBFloat16x4:
- return GET_SVE_FP_VEC(BFloat16Ty, false, 32);
-#undef GET_SVE_FP_VEC
+ case BuiltinType::SveBFloat16x4: {
+ ASTContext::BuiltinVectorTypeInfo Info =
+ Context.getBuiltinVectorTypeInfo(cast<BuiltinType>(Ty));
+ return llvm::ScalableVectorType::get(ConvertType(Info.ElementType),
+ Info.EC.Min * Info.NumVectors);
+ }
case BuiltinType::Dependent:
#define BUILTIN_TYPE(Id, SingletonId)
#define PLACEHOLDER_TYPE(Id, SingletonId) \