summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/DIBuilder.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2015-11-05 22:03:56 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2015-11-05 22:03:56 +0000
commitd4bff30370db9f2cb13838897012768739cf1ee0 (patch)
treef6c80f666794291c78575617d326207f57939b61 /llvm/lib/IR/DIBuilder.cpp
parent18da38edb315fe9e063348c4d785b26111b6d7ec (diff)
downloadbcm5719-llvm-d4bff30370db9f2cb13838897012768739cf1ee0.tar.gz
bcm5719-llvm-d4bff30370db9f2cb13838897012768739cf1ee0.zip
DI: Reverse direction of subprogram -> function edge.
Previously, subprograms contained a metadata reference to the function they described. Because most clients need to get or set a subprogram for a given function rather than the other way around, this created unneeded inefficiency. For example, many passes needed to call the function llvm::makeSubprogramMap() to build a mapping from functions to subprograms, and the IR linker needed to fix up function references in a way that caused quadratic complexity in the IR linking phase of LTO. This change reverses the direction of the edge by storing the subprogram as function-level metadata and removing DISubprogram's function field. Since this is an IR change, a bitcode upgrade has been provided. Fixes PR23367. An upgrade script for textual IR for out-of-tree clients is attached to the PR. Differential Revision: http://reviews.llvm.org/D14265 llvm-svn: 252219
Diffstat (limited to 'llvm/lib/IR/DIBuilder.cpp')
-rw-r--r--llvm/lib/IR/DIBuilder.cpp57
1 files changed, 25 insertions, 32 deletions
diff --git a/llvm/lib/IR/DIBuilder.cpp b/llvm/lib/IR/DIBuilder.cpp
index def72d6cf6e..7fc0652bf65 100644
--- a/llvm/lib/IR/DIBuilder.cpp
+++ b/llvm/lib/IR/DIBuilder.cpp
@@ -659,19 +659,17 @@ DIExpression *DIBuilder::createBitPieceExpression(unsigned OffsetInBytes,
return DIExpression::get(VMContext, Addr);
}
-DISubprogram *DIBuilder::createFunction(DIScopeRef Context, StringRef Name,
- StringRef LinkageName, DIFile *File,
- unsigned LineNo, DISubroutineType *Ty,
- bool isLocalToUnit, bool isDefinition,
- unsigned ScopeLine, unsigned Flags,
- bool isOptimized, Function *Fn,
- MDNode *TParams, MDNode *Decl) {
+DISubprogram *DIBuilder::createFunction(
+ DIScopeRef Context, StringRef Name, StringRef LinkageName, DIFile *File,
+ unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
+ bool isDefinition, unsigned ScopeLine, unsigned Flags, bool isOptimized,
+ DITemplateParameterArray TParams, DISubprogram *Decl) {
// dragonegg does not generate identifier for types, so using an empty map
// to resolve the context should be fine.
DITypeIdentifierMap EmptyMap;
return createFunction(Context.resolve(EmptyMap), Name, LinkageName, File,
LineNo, Ty, isLocalToUnit, isDefinition, ScopeLine,
- Flags, isOptimized, Fn, TParams, Decl);
+ Flags, isOptimized, TParams, Decl);
}
template <class... Ts>
@@ -681,20 +679,17 @@ static DISubprogram *getSubprogram(bool IsDistinct, Ts &&... Args) {
return DISubprogram::get(std::forward<Ts>(Args)...);
}
-DISubprogram *DIBuilder::createFunction(DIScope *Context, StringRef Name,
- StringRef LinkageName, DIFile *File,
- unsigned LineNo, DISubroutineType *Ty,
- bool isLocalToUnit, bool isDefinition,
- unsigned ScopeLine, unsigned Flags,
- bool isOptimized, Function *Fn,
- MDNode *TParams, MDNode *Decl) {
- auto *Node = getSubprogram(/* IsDistinct = */ isDefinition, VMContext,
- DIScopeRef::get(getNonCompileUnitScope(Context)),
- Name, LinkageName, File, LineNo, Ty, isLocalToUnit,
- isDefinition, ScopeLine, nullptr, 0, 0, Flags,
- isOptimized, Fn, cast_or_null<MDTuple>(TParams),
- cast_or_null<DISubprogram>(Decl),
- MDTuple::getTemporary(VMContext, None).release());
+DISubprogram *DIBuilder::createFunction(
+ DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
+ unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
+ bool isDefinition, unsigned ScopeLine, unsigned Flags, bool isOptimized,
+ DITemplateParameterArray TParams, DISubprogram *Decl) {
+ auto *Node =
+ getSubprogram(/* IsDistinct = */ isDefinition, VMContext,
+ DIScopeRef::get(getNonCompileUnitScope(Context)), Name,
+ LinkageName, File, LineNo, Ty, isLocalToUnit, isDefinition,
+ ScopeLine, nullptr, 0, 0, Flags, isOptimized, TParams, Decl,
+ MDTuple::getTemporary(VMContext, None).release());
if (isDefinition)
AllSubprograms.push_back(Node);
@@ -706,12 +701,11 @@ DISubprogram *DIBuilder::createTempFunctionFwdDecl(
DIScope *Context, StringRef Name, StringRef LinkageName, DIFile *File,
unsigned LineNo, DISubroutineType *Ty, bool isLocalToUnit,
bool isDefinition, unsigned ScopeLine, unsigned Flags, bool isOptimized,
- Function *Fn, MDNode *TParams, MDNode *Decl) {
+ DITemplateParameterArray TParams, DISubprogram *Decl) {
return DISubprogram::getTemporary(
VMContext, DIScopeRef::get(getNonCompileUnitScope(Context)), Name,
LinkageName, File, LineNo, Ty, isLocalToUnit, isDefinition,
- ScopeLine, nullptr, 0, 0, Flags, isOptimized, Fn,
- cast_or_null<MDTuple>(TParams), cast_or_null<DISubprogram>(Decl),
+ ScopeLine, nullptr, 0, 0, Flags, isOptimized, TParams, Decl,
nullptr)
.release();
}
@@ -721,17 +715,16 @@ DIBuilder::createMethod(DIScope *Context, StringRef Name, StringRef LinkageName,
DIFile *F, unsigned LineNo, DISubroutineType *Ty,
bool isLocalToUnit, bool isDefinition, unsigned VK,
unsigned VIndex, DIType *VTableHolder, unsigned Flags,
- bool isOptimized, Function *Fn, MDNode *TParam) {
+ bool isOptimized, DITemplateParameterArray TParams) {
assert(getNonCompileUnitScope(Context) &&
"Methods should have both a Context and a context that isn't "
"the compile unit.");
// FIXME: Do we want to use different scope/lines?
- auto *SP = getSubprogram(/* IsDistinct = */ isDefinition, VMContext,
- DIScopeRef::get(cast<DIScope>(Context)), Name,
- LinkageName, F, LineNo, Ty, isLocalToUnit,
- isDefinition, LineNo, DITypeRef::get(VTableHolder),
- VK, VIndex, Flags, isOptimized, Fn,
- cast_or_null<MDTuple>(TParam), nullptr, nullptr);
+ auto *SP = getSubprogram(
+ /* IsDistinct = */ isDefinition, VMContext,
+ DIScopeRef::get(cast<DIScope>(Context)), Name, LinkageName, F, LineNo, Ty,
+ isLocalToUnit, isDefinition, LineNo, DITypeRef::get(VTableHolder), VK,
+ VIndex, Flags, isOptimized, TParams, nullptr, nullptr);
if (isDefinition)
AllSubprograms.push_back(SP);
OpenPOWER on IntegriCloud