diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2015-11-05 22:03:56 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2015-11-05 22:03:56 +0000 |
commit | 5f220beefcb655de6aae7c80b456fd4e5cb76ac0 (patch) | |
tree | d478c6bd28ca4a860f194ccd49ec67aa8f6b062e /bindings | |
parent | cc5dc01d7f7b6acdc7160fe30fda00e3b1b48687 (diff) |
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
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@252219 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'bindings')
-rw-r--r-- | bindings/go/llvm/DIBuilderBindings.cpp | 4 | ||||
-rw-r--r-- | bindings/go/llvm/DIBuilderBindings.h | 2 | ||||
-rw-r--r-- | bindings/go/llvm/IRBindings.cpp | 4 | ||||
-rw-r--r-- | bindings/go/llvm/IRBindings.h | 2 | ||||
-rw-r--r-- | bindings/go/llvm/dibuilder.go | 2 | ||||
-rw-r--r-- | bindings/go/llvm/ir.go | 3 |
6 files changed, 12 insertions, 5 deletions
diff --git a/bindings/go/llvm/DIBuilderBindings.cpp b/bindings/go/llvm/DIBuilderBindings.cpp index e7fe8f5dde8..e767144bb32 100644 --- a/bindings/go/llvm/DIBuilderBindings.cpp +++ b/bindings/go/llvm/DIBuilderBindings.cpp @@ -74,13 +74,13 @@ LLVMMetadataRef LLVMDIBuilderCreateFunction( LLVMDIBuilderRef Dref, LLVMMetadataRef Scope, const char *Name, const char *LinkageName, LLVMMetadataRef File, unsigned Line, LLVMMetadataRef CompositeType, int IsLocalToUnit, int IsDefinition, - unsigned ScopeLine, unsigned Flags, int IsOptimized, LLVMValueRef Func) { + unsigned ScopeLine, unsigned Flags, int IsOptimized) { DIBuilder *D = unwrap(Dref); return wrap(D->createFunction(unwrap<DIScope>(Scope), Name, LinkageName, File ? unwrap<DIFile>(File) : nullptr, Line, unwrap<DISubroutineType>(CompositeType), IsLocalToUnit, IsDefinition, ScopeLine, Flags, - IsOptimized, unwrap<Function>(Func))); + IsOptimized)); } LLVMMetadataRef diff --git a/bindings/go/llvm/DIBuilderBindings.h b/bindings/go/llvm/DIBuilderBindings.h index ef6eda15e65..f14fd0f7b5f 100644 --- a/bindings/go/llvm/DIBuilderBindings.h +++ b/bindings/go/llvm/DIBuilderBindings.h @@ -55,7 +55,7 @@ LLVMMetadataRef LLVMDIBuilderCreateFunction( LLVMDIBuilderRef D, LLVMMetadataRef Scope, const char *Name, const char *LinkageName, LLVMMetadataRef File, unsigned Line, LLVMMetadataRef CompositeType, int IsLocalToUnit, int IsDefinition, - unsigned ScopeLine, unsigned Flags, int IsOptimized, LLVMValueRef Function); + unsigned ScopeLine, unsigned Flags, int IsOptimized); LLVMMetadataRef LLVMDIBuilderCreateAutoVariable(LLVMDIBuilderRef D, LLVMMetadataRef Scope, diff --git a/bindings/go/llvm/IRBindings.cpp b/bindings/go/llvm/IRBindings.cpp index fd0cb8006a4..4308f84cc1b 100644 --- a/bindings/go/llvm/IRBindings.cpp +++ b/bindings/go/llvm/IRBindings.cpp @@ -98,3 +98,7 @@ void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Bref, unsigned Line, DebugLoc::get(Line, Col, Scope ? unwrap<MDNode>(Scope) : nullptr, InlinedAt ? unwrap<MDNode>(InlinedAt) : nullptr)); } + +void LLVMSetSubprogram(LLVMValueRef Func, LLVMMetadataRef SP) { + unwrap<Function>(Func)->setSubprogram(unwrap<DISubprogram>(SP)); +} diff --git a/bindings/go/llvm/IRBindings.h b/bindings/go/llvm/IRBindings.h index a53e178f1e0..dcdb26eda79 100644 --- a/bindings/go/llvm/IRBindings.h +++ b/bindings/go/llvm/IRBindings.h @@ -55,6 +55,8 @@ void LLVMSetCurrentDebugLocation2(LLVMBuilderRef Bref, unsigned Line, unsigned Col, LLVMMetadataRef Scope, LLVMMetadataRef InlinedAt); +void LLVMSetSubprogram(LLVMValueRef Fn, LLVMMetadataRef SP); + #ifdef __cplusplus } diff --git a/bindings/go/llvm/dibuilder.go b/bindings/go/llvm/dibuilder.go index 4ec60738a7a..778c3178583 100644 --- a/bindings/go/llvm/dibuilder.go +++ b/bindings/go/llvm/dibuilder.go @@ -189,7 +189,6 @@ type DIFunction struct { ScopeLine int Flags int Optimized bool - Function Value } // CreateCompileUnit creates function debug metadata. @@ -211,7 +210,6 @@ func (d *DIBuilder) CreateFunction(diScope Metadata, f DIFunction) Metadata { C.unsigned(f.ScopeLine), C.unsigned(f.Flags), boolToCInt(f.Optimized), - f.Function.C, ) return Metadata{C: result} } diff --git a/bindings/go/llvm/ir.go b/bindings/go/llvm/ir.go index 8fcd6ec4d74..b8ea28d3a0d 100644 --- a/bindings/go/llvm/ir.go +++ b/bindings/go/llvm/ir.go @@ -1057,6 +1057,9 @@ func (v Value) AddTargetDependentFunctionAttr(attr, value string) { func (v Value) SetPersonality(p Value) { C.LLVMSetPersonalityFn(v.C, p.C) } +func (v Value) SetSubprogram(sp Metadata) { + C.LLVMSetSubprogram(v.C, sp.C) +} // Operations on parameters func (v Value) ParamsCount() int { return int(C.LLVMCountParams(v.C)) } |