Skip to content

Commit

Permalink
Merged master:9936455204fd into amd-gfx:6877e932e322
Browse files Browse the repository at this point in the history
Local branch amd-gfx 6877e93 Merged master:09288bcbf5f1 into amd-gfx:7095da9190c1
Remote branch master 9936455 Reapply D70800: Fix AArch64 AAPCS frame record chain
  • Loading branch information
Sw authored and Sw committed Aug 26, 2020
2 parents 6877e93 + 9936455 commit 88e6671
Show file tree
Hide file tree
Showing 65 changed files with 1,221 additions and 433 deletions.
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGAtomic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ namespace {
ValueTy = lvalue.getType();
ValueSizeInBits = C.getTypeSize(ValueTy);
AtomicTy = ValueTy = CGF.getContext().getExtVectorType(
lvalue.getType(), cast<llvm::VectorType>(
lvalue.getType(), cast<llvm::FixedVectorType>(
lvalue.getExtVectorAddress().getElementType())
->getNumElements());
AtomicSizeInBits = C.getTypeSize(AtomicTy);
Expand Down
150 changes: 79 additions & 71 deletions clang/lib/CodeGen/CGBuiltin.cpp

Large diffs are not rendered by default.

11 changes: 6 additions & 5 deletions clang/lib/CodeGen/CGExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1685,7 +1685,7 @@ llvm::Value *CodeGenFunction::EmitLoadOfScalar(Address Addr, bool Volatile,
if (Ty->isVectorType()) {
const llvm::Type *EltTy = Addr.getElementType();

const auto *VTy = cast<llvm::VectorType>(EltTy);
const auto *VTy = cast<llvm::FixedVectorType>(EltTy);

// Handle vectors of size 3 like size 4 for better performance.
if (VTy->getNumElements() == 3) {
Expand Down Expand Up @@ -1770,8 +1770,9 @@ static Address MaybeConvertMatrixAddress(Address Addr, CodeGenFunction &CGF,
auto *VectorTy = dyn_cast<llvm::VectorType>(
cast<llvm::PointerType>(Addr.getPointer()->getType())->getElementType());
if (VectorTy && !IsVector) {
auto *ArrayTy = llvm::ArrayType::get(VectorTy->getElementType(),
VectorTy->getNumElements());
auto *ArrayTy = llvm::ArrayType::get(
VectorTy->getElementType(),
cast<llvm::FixedVectorType>(VectorTy)->getNumElements());

return Address(CGF.Builder.CreateElementBitCast(Addr, ArrayTy));
}
Expand Down Expand Up @@ -1802,7 +1803,7 @@ void CodeGenFunction::EmitStoreOfScalar(llvm::Value *Value, Address Addr,
llvm::Type *SrcTy = Value->getType();
auto *VecTy = dyn_cast<llvm::VectorType>(SrcTy);
// Handle vec3 special.
if (VecTy && VecTy->getNumElements() == 3) {
if (VecTy && cast<llvm::FixedVectorType>(VecTy)->getNumElements() == 3) {
// Our source is a vec3, do a shuffle vector to make it a vec4.
Value = Builder.CreateShuffleVector(Value, llvm::UndefValue::get(VecTy),
ArrayRef<int>{0, 1, 2, -1},
Expand Down Expand Up @@ -2217,7 +2218,7 @@ void CodeGenFunction::EmitStoreThroughExtVectorComponentLValue(RValue Src,
if (const VectorType *VTy = Dst.getType()->getAs<VectorType>()) {
unsigned NumSrcElts = VTy->getNumElements();
unsigned NumDstElts =
cast<llvm::VectorType>(Vec->getType())->getNumElements();
cast<llvm::FixedVectorType>(Vec->getType())->getNumElements();
if (NumDstElts == NumSrcElts) {
// Use shuffle vector is the src and destination are the same number of
// elements and restore the vector mask since it is on the side it will be
Expand Down
31 changes: 18 additions & 13 deletions clang/lib/CodeGen/CGExprScalar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ Value *ScalarExprEmitter::EmitScalarConversion(Value *Src, QualType SrcType,
"Splatted expr doesn't match with vector element type?");

// Splat the element across to all elements
unsigned NumElements = cast<llvm::VectorType>(DstTy)->getNumElements();
unsigned NumElements = cast<llvm::FixedVectorType>(DstTy)->getNumElements();
return Builder.CreateVectorSplat(NumElements, Src, "splat");
}

Expand Down Expand Up @@ -1553,12 +1553,12 @@ Value *ScalarExprEmitter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
Value *RHS = CGF.EmitScalarExpr(E->getExpr(1));
Value *Mask;

llvm::VectorType *LTy = cast<llvm::VectorType>(LHS->getType());
auto *LTy = cast<llvm::FixedVectorType>(LHS->getType());
unsigned LHSElts = LTy->getNumElements();

Mask = RHS;

llvm::VectorType *MTy = cast<llvm::VectorType>(Mask->getType());
auto *MTy = cast<llvm::FixedVectorType>(Mask->getType());

// Mask off the high bits of each shuffle index.
Value *MaskBits =
Expand Down Expand Up @@ -1763,7 +1763,7 @@ Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr *E) {
return Visit(E->getInit(0));
}

unsigned ResElts = VType->getNumElements();
unsigned ResElts = cast<llvm::FixedVectorType>(VType)->getNumElements();

// Loop over initializers collecting the Value for each, and remembering
// whether the source was swizzle (ExtVectorElementExpr). This will allow
Expand All @@ -1787,7 +1787,8 @@ Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr *E) {
if (isa<ExtVectorElementExpr>(IE)) {
llvm::ExtractElementInst *EI = cast<llvm::ExtractElementInst>(Init);

if (EI->getVectorOperandType()->getNumElements() == ResElts) {
if (cast<llvm::FixedVectorType>(EI->getVectorOperandType())
->getNumElements() == ResElts) {
llvm::ConstantInt *C = cast<llvm::ConstantInt>(EI->getIndexOperand());
Value *LHS = nullptr, *RHS = nullptr;
if (CurIdx == 0) {
Expand Down Expand Up @@ -1825,7 +1826,7 @@ Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr *E) {
continue;
}

unsigned InitElts = VVT->getNumElements();
unsigned InitElts = cast<llvm::FixedVectorType>(VVT)->getNumElements();

// If the initializer is an ExtVecEltExpr (a swizzle), and the swizzle's
// input is the same width as the vector being constructed, generate an
Expand All @@ -1834,7 +1835,7 @@ Value *ScalarExprEmitter::VisitInitListExpr(InitListExpr *E) {
if (isa<ExtVectorElementExpr>(IE)) {
llvm::ShuffleVectorInst *SVI = cast<llvm::ShuffleVectorInst>(Init);
Value *SVOp = SVI->getOperand(0);
llvm::VectorType *OpTy = cast<llvm::VectorType>(SVOp->getType());
auto *OpTy = cast<llvm::FixedVectorType>(SVOp->getType());

if (OpTy->getNumElements() == ResElts) {
for (unsigned j = 0; j != CurIdx; ++j) {
Expand Down Expand Up @@ -2170,7 +2171,7 @@ Value *ScalarExprEmitter::VisitCastExpr(CastExpr *CE) {
llvm::Type *DstTy = ConvertType(DestTy);
Value *Elt = Visit(const_cast<Expr*>(E));
// Splat the element across to all elements
unsigned NumElements = cast<llvm::VectorType>(DstTy)->getNumElements();
unsigned NumElements = cast<llvm::FixedVectorType>(DstTy)->getNumElements();
return Builder.CreateVectorSplat(NumElements, Elt, "splat");
}

Expand Down Expand Up @@ -4331,7 +4332,7 @@ VisitAbstractConditionalOperator(const AbstractConditionalOperator *E) {
llvm::Value *RHS = Visit(rhsExpr);

llvm::Type *condType = ConvertType(condExpr->getType());
llvm::VectorType *vecTy = cast<llvm::VectorType>(condType);
auto *vecTy = cast<llvm::FixedVectorType>(condType);

unsigned numElem = vecTy->getNumElements();
llvm::Type *elemType = vecTy->getElementType();
Expand Down Expand Up @@ -4534,10 +4535,14 @@ Value *ScalarExprEmitter::VisitAsTypeExpr(AsTypeExpr *E) {
llvm::Type *DstTy = ConvertType(E->getType());

llvm::Type *SrcTy = Src->getType();
unsigned NumElementsSrc = isa<llvm::VectorType>(SrcTy) ?
cast<llvm::VectorType>(SrcTy)->getNumElements() : 0;
unsigned NumElementsDst = isa<llvm::VectorType>(DstTy) ?
cast<llvm::VectorType>(DstTy)->getNumElements() : 0;
unsigned NumElementsSrc =
isa<llvm::VectorType>(SrcTy)
? cast<llvm::FixedVectorType>(SrcTy)->getNumElements()
: 0;
unsigned NumElementsDst =
isa<llvm::VectorType>(DstTy)
? cast<llvm::FixedVectorType>(DstTy)->getNumElements()
: 0;

// Going from vec3 to non-vec3 is a special case and requires a shuffle
// vector to get a vec4, then a bitcast if the target type is different.
Expand Down
16 changes: 10 additions & 6 deletions clang/lib/CodeGen/SwiftCallingConv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,9 +320,12 @@ void SwiftAggLowering::addEntry(llvm::Type *type,
// If we have a vector type, split it.
if (auto vecTy = dyn_cast_or_null<llvm::VectorType>(type)) {
auto eltTy = vecTy->getElementType();
CharUnits eltSize = (end - begin) / vecTy->getNumElements();
CharUnits eltSize =
(end - begin) / cast<llvm::FixedVectorType>(vecTy)->getNumElements();
assert(eltSize == getTypeStoreSize(CGM, eltTy));
for (unsigned i = 0, e = vecTy->getNumElements(); i != e; ++i) {
for (unsigned i = 0,
e = cast<llvm::FixedVectorType>(vecTy)->getNumElements();
i != e; ++i) {
addEntry(eltTy, begin, begin + eltSize);
begin += eltSize;
}
Expand Down Expand Up @@ -674,8 +677,9 @@ bool swiftcall::isLegalIntegerType(CodeGenModule &CGM,

bool swiftcall::isLegalVectorType(CodeGenModule &CGM, CharUnits vectorSize,
llvm::VectorType *vectorTy) {
return isLegalVectorType(CGM, vectorSize, vectorTy->getElementType(),
vectorTy->getNumElements());
return isLegalVectorType(
CGM, vectorSize, vectorTy->getElementType(),
cast<llvm::FixedVectorType>(vectorTy)->getNumElements());
}

bool swiftcall::isLegalVectorType(CodeGenModule &CGM, CharUnits vectorSize,
Expand All @@ -688,7 +692,7 @@ bool swiftcall::isLegalVectorType(CodeGenModule &CGM, CharUnits vectorSize,
std::pair<llvm::Type*, unsigned>
swiftcall::splitLegalVectorType(CodeGenModule &CGM, CharUnits vectorSize,
llvm::VectorType *vectorTy) {
auto numElts = vectorTy->getNumElements();
auto numElts = cast<llvm::FixedVectorType>(vectorTy)->getNumElements();
auto eltTy = vectorTy->getElementType();

// Try to split the vector type in half.
Expand All @@ -710,7 +714,7 @@ void swiftcall::legalizeVectorType(CodeGenModule &CGM, CharUnits origVectorSize,
}

// Try to split the vector into legal subvectors.
auto numElts = origVectorTy->getNumElements();
auto numElts = cast<llvm::FixedVectorType>(origVectorTy)->getNumElements();
auto eltTy = origVectorTy->getElementType();
assert(numElts != 1);

Expand Down
18 changes: 13 additions & 5 deletions llvm/include/llvm/IR/Intrinsics.td
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ class NoAlias<AttrIndex idx> : IntrinsicProperty {
int ArgNo = idx.Value;
}

// NoUndef - The specified argument is neither undef nor poison.
class NoUndef<AttrIndex idx> : IntrinsicProperty {
int ArgNo = idx.Value;
}

class Align<AttrIndex idx, int align> : IntrinsicProperty {
int ArgNo = idx.Value;
int Align = align;
Expand Down Expand Up @@ -515,7 +520,8 @@ def int_readcyclecounter : Intrinsic<[llvm_i64_ty]>;

// The assume intrinsic is marked as arbitrarily writing so that proper
// control dependencies will be maintained.
def int_assume : Intrinsic<[], [llvm_i1_ty], [IntrWillReturn]>;
def int_assume : Intrinsic<[], [llvm_i1_ty], [IntrWillReturn,
NoUndef<ArgIndex<0>>]>;

// Stack Protector Intrinsic - The stackprotector intrinsic writes the stack
// guard to the correct place on the stack frame.
Expand Down Expand Up @@ -1347,26 +1353,28 @@ def int_masked_store : Intrinsic<[], [llvm_anyvector_ty,
LLVMAnyPointerType<LLVMMatchType<0>>,
llvm_i32_ty,
LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
[IntrArgMemOnly, IntrWillReturn, ImmArg<ArgIndex<2>>]>;
[IntrArgMemOnly, IntrWillReturn,
NoUndef<ArgIndex<1>>, ImmArg<ArgIndex<2>>]>;

def int_masked_load : Intrinsic<[llvm_anyvector_ty],
[LLVMAnyPointerType<LLVMMatchType<0>>, llvm_i32_ty,
LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>, LLVMMatchType<0>],
[IntrReadMem, IntrArgMemOnly, IntrWillReturn,
ImmArg<ArgIndex<1>>]>;
NoUndef<ArgIndex<0>>, ImmArg<ArgIndex<1>>]>;

def int_masked_gather: Intrinsic<[llvm_anyvector_ty],
[LLVMVectorOfAnyPointersToElt<0>, llvm_i32_ty,
LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>,
LLVMMatchType<0>],
[IntrReadMem, IntrWillReturn,
ImmArg<ArgIndex<1>>]>;
NoUndef<ArgIndex<0>>, ImmArg<ArgIndex<1>>]>;

def int_masked_scatter: Intrinsic<[],
[llvm_anyvector_ty,
LLVMVectorOfAnyPointersToElt<0>, llvm_i32_ty,
LLVMScalarOrSameVectorWidth<0, llvm_i1_ty>],
[IntrWillReturn, ImmArg<ArgIndex<2>>]>;
[IntrWillReturn, NoUndef<ArgIndex<1>>,
ImmArg<ArgIndex<2>>]>;

def int_masked_expandload: Intrinsic<[llvm_anyvector_ty],
[LLVMPointerToElt<0>,
Expand Down
49 changes: 19 additions & 30 deletions llvm/include/llvm/ProfileData/SampleProf.h
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ class SampleRecord {
raw_ostream &operator<<(raw_ostream &OS, const SampleRecord &Sample);

class FunctionSamples;
class SampleProfileReaderItaniumRemapper;

using BodySampleMap = std::map<LineLocation, SampleRecord>;
// NOTE: Using a StringMap here makes parsed profiles consume around 17% more
Expand Down Expand Up @@ -428,35 +429,15 @@ class FunctionSamples {
return &iter->second;
}

/// Returns a pointer to FunctionSamples at the given callsite location \p Loc
/// with callee \p CalleeName. If no callsite can be found, relax the
/// restriction to return the FunctionSamples at callsite location \p Loc
/// with the maximum total sample count.
const FunctionSamples *findFunctionSamplesAt(const LineLocation &Loc,
StringRef CalleeName) const {
std::string CalleeGUID;
CalleeName = getRepInFormat(CalleeName, UseMD5, CalleeGUID);

auto iter = CallsiteSamples.find(Loc);
if (iter == CallsiteSamples.end())
return nullptr;
auto FS = iter->second.find(CalleeName);
if (FS != iter->second.end())
return &FS->second;
// If we cannot find exact match of the callee name, return the FS with
// the max total count. Only do this when CalleeName is not provided,
// i.e., only for indirect calls.
if (!CalleeName.empty())
return nullptr;
uint64_t MaxTotalSamples = 0;
const FunctionSamples *R = nullptr;
for (const auto &NameFS : iter->second)
if (NameFS.second.getTotalSamples() >= MaxTotalSamples) {
MaxTotalSamples = NameFS.second.getTotalSamples();
R = &NameFS.second;
}
return R;
}
/// Returns a pointer to FunctionSamples at the given callsite location
/// \p Loc with callee \p CalleeName. If no callsite can be found, relax
/// the restriction to return the FunctionSamples at callsite location
/// \p Loc with the maximum total sample count. If \p Remapper is not
/// nullptr, use \p Remapper to find FunctionSamples with equivalent name
/// as \p CalleeName.
const FunctionSamples *
findFunctionSamplesAt(const LineLocation &Loc, StringRef CalleeName,
SampleProfileReaderItaniumRemapper *Remapper) const;

bool empty() const { return TotalSamples == 0; }

Expand Down Expand Up @@ -630,7 +611,11 @@ class FunctionSamples {
/// tree nodes in the profile.
///
/// \returns the FunctionSamples pointer to the inlined instance.
const FunctionSamples *findFunctionSamples(const DILocation *DIL) const;
/// If \p Remapper is not nullptr, it will be used to find matching
/// FunctionSamples with not exactly the same but equivalent name.
const FunctionSamples *findFunctionSamples(
const DILocation *DIL,
SampleProfileReaderItaniumRemapper *Remapper = nullptr) const;

static SampleProfileFormat Format;

Expand All @@ -648,6 +633,10 @@ class FunctionSamples {
return UseMD5 ? std::stoull(Name.data()) : Function::getGUID(Name);
}

// Find all the names in the current FunctionSamples including names in
// all the inline instances and names of call targets.
void findAllNames(DenseSet<StringRef> &NameSet) const;

private:
/// Mangled name of the function.
StringRef Name;
Expand Down
26 changes: 18 additions & 8 deletions llvm/include/llvm/ProfileData/SampleProfReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@
#ifndef LLVM_PROFILEDATA_SAMPLEPROFREADER_H
#define LLVM_PROFILEDATA_SAMPLEPROFREADER_H

#include "llvm/ADT/Optional.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
Expand Down Expand Up @@ -275,15 +276,18 @@ class SampleProfileReaderItaniumRemapper {
return Remappings->lookup(FunctionName);
}

/// Return the samples collected for function \p F if remapper knows
/// it is present in SampleMap.
FunctionSamples *getSamplesFor(StringRef FunctionName);
/// Return the equivalent name in the profile for \p FunctionName if
/// it exists.
Optional<StringRef> lookUpNameInProfile(StringRef FunctionName);

private:
// The buffer holding the content read from remapping file.
std::unique_ptr<MemoryBuffer> Buffer;
std::unique_ptr<SymbolRemappingReader> Remappings;
DenseMap<SymbolRemappingReader::Key, FunctionSamples *> SampleMap;
// Map remapping key to the name in the profile. By looking up the
// key in the remapper, a given new name can be mapped to the
// cannonical name using the NameMap.
DenseMap<SymbolRemappingReader::Key, StringRef> NameMap;
// The Reader the remapper is servicing.
SampleProfileReader &Reader;
// Indicate whether remapping has been applied to the profile read
Expand Down Expand Up @@ -370,15 +374,19 @@ class SampleProfileReader {

/// Return the samples collected for function \p F.
virtual FunctionSamples *getSamplesFor(StringRef Fname) {
if (Remapper) {
if (auto FS = Remapper->getSamplesFor(Fname))
return FS;
}
std::string FGUID;
Fname = getRepInFormat(Fname, useMD5(), FGUID);
auto It = Profiles.find(Fname);
if (It != Profiles.end())
return &It->second;

if (Remapper) {
if (auto NameInProfile = Remapper->lookUpNameInProfile(Fname)) {
auto It = Profiles.find(*NameInProfile);
if (It != Profiles.end())
return &It->second;
}
}
return nullptr;
}

Expand Down Expand Up @@ -423,6 +431,8 @@ class SampleProfileReader {
/// Return whether names in the profile are all MD5 numbers.
virtual bool useMD5() { return false; }

SampleProfileReaderItaniumRemapper *getRemapper() { return Remapper.get(); }

protected:
/// Map every function to its associated profile.
///
Expand Down
Loading

0 comments on commit 88e6671

Please sign in to comment.