Changeset View
Standalone View
llvm/lib/Target/PowerPC/PPCISelLowering.cpp
- This file is larger than 256 KB, so syntax highlighting is disabled by default.
Show First 20 Lines • Show All 5,135 Lines • ▼ Show 20 Lines | bool UsePlt = | ||||
Subtarget.getTargetMachine().getRelocationModel() == Reloc::PIC_; | Subtarget.getTargetMachine().getRelocationModel() == Reloc::PIC_; | ||||
const auto getAIXFuncEntryPointSymbolSDNode = [&](const GlobalValue *GV) { | const auto getAIXFuncEntryPointSymbolSDNode = [&](const GlobalValue *GV) { | ||||
const TargetMachine &TM = Subtarget.getTargetMachine(); | const TargetMachine &TM = Subtarget.getTargetMachine(); | ||||
const TargetLoweringObjectFile *TLOF = TM.getObjFileLowering(); | const TargetLoweringObjectFile *TLOF = TM.getObjFileLowering(); | ||||
MCSymbolXCOFF *S = | MCSymbolXCOFF *S = | ||||
cast<MCSymbolXCOFF>(TLOF->getFunctionEntryPointSymbol(GV, TM)); | cast<MCSymbolXCOFF>(TLOF->getFunctionEntryPointSymbol(GV, TM)); | ||||
if (GV->isDeclaration() && !S->hasRepresentedCsectSet()) { | |||||
// On AIX, an undefined symbol needs to be associated with a | |||||
// MCSectionXCOFF to get the correct storage mapping class. | |||||
// In this case, XCOFF::XMC_PR. | |||||
const XCOFF::StorageClass SC = | |||||
TargetLoweringObjectFileXCOFF::getStorageClassForGlobal(GV); | |||||
auto &Context = DAG.getMachineFunction().getMMI().getContext(); | |||||
MCSectionXCOFF *Sec = Context.getXCOFFSection( | |||||
S->getSymbolTableName(), XCOFF::XMC_PR, XCOFF::XTY_ER, SC, | |||||
SectionKind::getMetadata()); | |||||
S->setRepresentedCsect(Sec); | |||||
} | |||||
MVT PtrVT = DAG.getTargetLoweringInfo().getPointerTy(DAG.getDataLayout()); | MVT PtrVT = DAG.getTargetLoweringInfo().getPointerTy(DAG.getDataLayout()); | ||||
return DAG.getMCSymbol(S, PtrVT); | return DAG.getMCSymbol(S, PtrVT); | ||||
}; | }; | ||||
if (isFunctionGlobalAddress(Callee)) { | if (isFunctionGlobalAddress(Callee)) { | ||||
const GlobalValue *GV = cast<GlobalAddressSDNode>(Callee)->getGlobal(); | const GlobalValue *GV = cast<GlobalAddressSDNode>(Callee)->getGlobal(); | ||||
if (Subtarget.isAIXABI()) { | if (Subtarget.isAIXABI()) { | ||||
Show All 11 Lines | if (Subtarget.isAIXABI()) { | ||||
// ExternalSymbol's, then we pick up the user-declared version. | // ExternalSymbol's, then we pick up the user-declared version. | ||||
const Module *Mod = DAG.getMachineFunction().getFunction().getParent(); | const Module *Mod = DAG.getMachineFunction().getFunction().getParent(); | ||||
if (const Function *F = | if (const Function *F = | ||||
dyn_cast_or_null<Function>(Mod->getNamedValue(SymName))) | dyn_cast_or_null<Function>(Mod->getNamedValue(SymName))) | ||||
return getAIXFuncEntryPointSymbolSDNode(F); | return getAIXFuncEntryPointSymbolSDNode(F); | ||||
// On AIX, direct function calls reference the symbol for the function's | // On AIX, direct function calls reference the symbol for the function's | ||||
// entry point, which is named by prepending a "." before the function's | // entry point, which is named by prepending a "." before the function's | ||||
// C-linkage name. | // C-linkage name and storage mapping classs[PR]. | ||||
jasonliu: Suggestion for the comment:
...... C-linkage name. A Qualname is returned here because an… | |||||
const auto getFunctionEntryPointSymbol = [&](StringRef SymName) { | const auto getFunctionEntryPointQualNameSymbol = [&](StringRef SymName) { | ||||
I don't think it's necessary to change the name, as the sister function in TLOF have the same name but still return qualname when needed. jasonliu: I don't think it's necessary to change the name, as the sister function in TLOF have the same… | |||||
MCSymbol *TargetLoweringObjectFileXCOFF::getFunctionEntryPointSymbol() return .foo not .foo[PR] . DiggerLin: MCSymbol *TargetLoweringObjectFileXCOFF::getFunctionEntryPointSymbol() return .foo not .foo[PR]… | |||||
Not Done ReplyInline ActionsBy looking at what this function does. It seems the name should be getExternalFunctionEntryPointSymbol, as it's always returning a function entry point to an external function. That's an important information that we should include in the name. jasonliu: By looking at what this function does. It seems the name should be… | |||||
auto &Context = DAG.getMachineFunction().getMMI().getContext(); | auto &Context = DAG.getMachineFunction().getMMI().getContext(); | ||||
return cast<MCSymbolXCOFF>( | MCSectionXCOFF *Sec = Context.getXCOFFSection( | ||||
Context.getOrCreateSymbol(Twine(".") + Twine(SymName))); | (Twine(".") + Twine(SymName)).str(), XCOFF::XMC_PR, XCOFF::XTY_ER, | ||||
SectionKind::getMetadata()); | |||||
Dont use twine in local. You could do Context.getXCOFFSection(("." + Twine(SymName)).str(), .... jasonliu: Dont use twine in local. You could do
```
Context.getXCOFFSection(("." + Twine(SymName)).str()… | |||||
agree. changed DiggerLin: agree. changed | |||||
return Sec->getQualNameSymbol(); | |||||
}; | }; | ||||
SymName = getFunctionEntryPointSymbol(SymName)->getName().data(); | SymName = getFunctionEntryPointQualNameSymbol(SymName)->getName().data(); | ||||
} | } | ||||
return DAG.getTargetExternalSymbol(SymName, Callee.getValueType(), | return DAG.getTargetExternalSymbol(SymName, Callee.getValueType(), | ||||
UsePlt ? PPCII::MO_PLT : 0); | UsePlt ? PPCII::MO_PLT : 0); | ||||
} | } | ||||
// No transformation needed. | // No transformation needed. | ||||
assert(Callee.getNode() && "What no callee?"); | assert(Callee.getNode() && "What no callee?"); | ||||
return Callee; | return Callee; | ||||
} | } | ||||
Lint: Pre-merge checks clang-tidy: warning: invalid case style for variable 'getFunctionEntryPointQualNameSymbol' [readability-identifier-naming] Lint: Pre-merge checks: clang-tidy: warning: invalid case style for variable 'getFunctionEntryPointQualNameSymbol'… | |||||
static SDValue getOutputChainFromCallSeq(SDValue CallSeqStart) { | static SDValue getOutputChainFromCallSeq(SDValue CallSeqStart) { | ||||
assert(CallSeqStart.getOpcode() == ISD::CALLSEQ_START && | assert(CallSeqStart.getOpcode() == ISD::CALLSEQ_START && | ||||
"Expected a CALLSEQ_STARTSDNode."); | "Expected a CALLSEQ_STARTSDNode."); | ||||
// The last operand is the chain, except when the node has glue. If the node | // The last operand is the chain, except when the node has glue. If the node | ||||
// has glue, then the last operand is the glue, and the chain is the second | // has glue, then the last operand is the glue, and the chain is the second | ||||
// last operand. | // last operand. | ||||
SDValue LastValue = CallSeqStart.getValue(CallSeqStart->getNumValues() - 1); | SDValue LastValue = CallSeqStart.getValue(CallSeqStart->getNumValues() - 1); | ||||
▲ Show 20 Lines • Show All 11,092 Lines • Show Last 20 Lines |
Suggestion for the comment:
...... C-linkage name. A Qualname is returned here because an external function entry point is a csect with XTY_ER property.