Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 16 additions & 23 deletions llvm/lib/Target/SystemZ/SystemZISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10200,22 +10200,6 @@ SDValue SystemZTargetLowering::lowerVECREDUCE_ADD(SDValue Op,
DAG.getConstant(OpVT.getVectorNumElements() - 1, DL, MVT::i32));
}

// Only consider a function fully internal as long as it has local linkage
// and is not used in any other way than acting as the called function at
// call sites.
bool SystemZTargetLowering::isFullyInternal(const Function *Fn) const {
if (!Fn->hasLocalLinkage())
return false;
for (const User *U : Fn->users()) {
if (auto *CB = dyn_cast<CallBase>(U)) {
if (CB->getCalledFunction() != Fn)
return false;
} else
return false;
}
return true;
}

static void printFunctionArgExts(const Function *F, raw_fd_ostream &OS) {
FunctionType *FT = F->getFunctionType();
const AttributeList &Attrs = F->getAttributes();
Expand All @@ -10234,6 +10218,16 @@ static void printFunctionArgExts(const Function *F, raw_fd_ostream &OS) {
OS << ")\n";
}

bool SystemZTargetLowering::isInternal(const Function *Fn) const {
std::map<const Function *, bool>::iterator Itr = IsInternalCache.find(Fn);
if (Itr == IsInternalCache.end())
Itr = IsInternalCache
.insert(std::pair<const Function *, bool>(
Fn, (Fn->hasLocalLinkage() && !Fn->hasAddressTaken())))
.first;
return Itr->second;
}

void SystemZTargetLowering::
verifyNarrowIntegerArgs_Call(const SmallVectorImpl<ISD::OutputArg> &Outs,
const Function *F, SDValue Callee) const {
Expand All @@ -10246,8 +10240,8 @@ verifyNarrowIntegerArgs_Call(const SmallVectorImpl<ISD::OutputArg> &Outs,
const Function *CalleeFn = nullptr;
if (auto *G = dyn_cast<GlobalAddressSDNode>(Callee))
if ((CalleeFn = dyn_cast<Function>(G->getGlobal())))
IsInternal = isFullyInternal(CalleeFn);
if (!verifyNarrowIntegerArgs(Outs, IsInternal)) {
IsInternal = isInternal(CalleeFn);
if (!IsInternal && !verifyNarrowIntegerArgs(Outs)) {
errs() << "ERROR: Missing extension attribute of passed "
<< "value in call to function:\n" << "Callee: ";
if (CalleeFn != nullptr)
Expand All @@ -10268,7 +10262,7 @@ verifyNarrowIntegerArgs_Ret(const SmallVectorImpl<ISD::OutputArg> &Outs,
if (!EnableIntArgExtCheck)
return;

if (!verifyNarrowIntegerArgs(Outs, isFullyInternal(F))) {
if (!isInternal(F) && !verifyNarrowIntegerArgs(Outs)) {
errs() << "ERROR: Missing extension attribute of returned "
<< "value from function:\n";
printFunctionArgExts(F, errs());
Expand All @@ -10278,10 +10272,9 @@ verifyNarrowIntegerArgs_Ret(const SmallVectorImpl<ISD::OutputArg> &Outs,

// Verify that narrow integer arguments are extended as required by the ABI.
// Return false if an error is found.
bool SystemZTargetLowering::
verifyNarrowIntegerArgs(const SmallVectorImpl<ISD::OutputArg> &Outs,
bool IsInternal) const {
if (IsInternal || !Subtarget.isTargetELF())
bool SystemZTargetLowering::verifyNarrowIntegerArgs(
const SmallVectorImpl<ISD::OutputArg> &Outs) const {
if (!Subtarget.isTargetELF())
return true;

if (EnableIntArgExtCheck.getNumOccurrences()) {
Expand Down
10 changes: 7 additions & 3 deletions llvm/lib/Target/SystemZ/SystemZISelLowering.h
Original file line number Diff line number Diff line change
Expand Up @@ -815,13 +815,17 @@ class SystemZTargetLowering : public TargetLowering {
getTargetMMOFlags(const Instruction &I) const override;
const TargetRegisterClass *getRepRegClassFor(MVT VT) const override;

bool isFullyInternal(const Function *Fn) const;
private:
bool isInternal(const Function *Fn) const;
mutable std::map<const Function *, bool> IsInternalCache;
void verifyNarrowIntegerArgs_Call(const SmallVectorImpl<ISD::OutputArg> &Outs,
const Function *F, SDValue Callee) const;
void verifyNarrowIntegerArgs_Ret(const SmallVectorImpl<ISD::OutputArg> &Outs,
const Function *F) const;
bool verifyNarrowIntegerArgs(const SmallVectorImpl<ISD::OutputArg> &Outs,
bool IsInternal) const;
bool
verifyNarrowIntegerArgs(const SmallVectorImpl<ISD::OutputArg> &Outs) const;

public:
};

struct SystemZVectorConstantInfo {
Expand Down