Commit Graph

18 Commits

Author SHA1 Message Date
Peter Collingbourne 5ab8061293 irgen: expose DisableUnusedImportCheck flag
Differential Revision: http://reviews.llvm.org/D6956

llvm-svn: 225946
2015-01-14 05:18:16 +00:00
Peter Collingbourne c253ebc4af irgen: expose PackageCreated hook
Differential Revision: http://reviews.llvm.org/D6955

llvm-svn: 225945
2015-01-14 05:17:41 +00:00
Peter Collingbourne 56109b78c7 Roll gotools to 47f2109c.
At the same time, perform a number of simplifications:

- Rename go.tools directory to gotools.

- Import only the go directory; all required Go analysis code and
  its dependencies have now been moved to this directory.

llvm-svn: 225825
2015-01-13 20:45:08 +00:00
Andrew Wilkins f3718a9bf1 [llgo] irgen: generate switch instructions
Summary:
    With this patch, llgo uses ssautil.Switches
    to reconstitute (and synthesise) switches,
    which can then be lowered to lookup tables,
    trees, etc.

    We currently only handle integer const case
    switches. We erase the comparison blocks (other
    than the initial block), and generate a switch
    instruction at the end of the block starting
    the if-else-if chain. ssautil.Switches does
    not remove duplicate const cases (e.g. same
    operands for "||"), so we do this in llgo for
    now.

Test Plan: lit test added

Reviewers: pcc

Reviewed By: pcc

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D6831

llvm-svn: 225433
2015-01-08 07:49:28 +00:00
Andrew Wilkins 75f34af99c [llgo] Elide alloca for unused received values in select
Summary: If a receive case in a select statement is not assigned to a named variable, then we can eliminate the alloca and copy at runtime.

Test Plan: lit test added

Reviewers: pcc

Reviewed By: pcc

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D6785

llvm-svn: 225033
2014-12-31 03:46:49 +00:00
Peter Collingbourne d34d92fb9c irgen: modify the ABI to use init guards instead of priority
The new ABI is simpler for use cases such as dynamically loaded packages.

The calling convention for import functions is similar to what go/ssa would
produce if BareInits were cleared. However, simply clearing this flag causes
two additional issues:

 1) We would need to special case the 'init$guard' variable (see
    discussion in https://codereview.appspot.com/78780043/).

 2) The call to __go_register_gc_roots needs to appear in the right
    place, i.e. after the guard check. Making this check appear
    in the right place with non-bare inits seems unreliable at best.

So we keep BareInits set and generate the necessary code manually.

It is still possible to get the old ABI by specifying a path to a gccgo
installation.

Differential Revision: http://reviews.llvm.org/D6804

llvm-svn: 225030
2014-12-31 00:25:39 +00:00
Peter Collingbourne a0a53085e1 irgen: make it possible to use a custom importer
Differential Revision: http://reviews.llvm.org/D6803

llvm-svn: 225029
2014-12-31 00:25:36 +00:00
Peter Collingbourne 76c1d4e4dd irgen: return a types.Package to the compiler client
Differential Revision: http://reviews.llvm.org/D6802

llvm-svn: 225028
2014-12-31 00:25:35 +00:00
Peter Collingbourne 82a260eaaf irgen: introduce ManglePackagePath function
This is useful for clients that need to use llgo's mangling of the package
path to look up a specific function within a given package.

Differential Revision: http://reviews.llvm.org/D6801

llvm-svn: 225027
2014-12-31 00:25:34 +00:00
Peter Collingbourne 9350942b20 irgen, driver: modify Compiler.Compile to take a FileSet and Files
This change allows clients to generate IR using "files" received from locations
other than the file system. The regular file parser is moved to a new library,
"driver", which is intended to eventually contain much of the logic from
the existing driver.

Differential Revision: http://reviews.llvm.org/D6794

llvm-svn: 225026
2014-12-31 00:25:32 +00:00
Peter Collingbourne b113d0206e irgen: remove unused compiler.runtimetypespkg field.
llvm-svn: 224931
2014-12-29 13:01:28 +00:00
Peter Collingbourne b6edff93ae irgen: do not emit an extra terminator for panic thunks
Found with GoSmith.

Differential Revision: http://reviews.llvm.org/D6714

llvm-svn: 224904
2014-12-28 22:39:01 +00:00
Andrew Wilkins c17d0bbfb3 Test commit
Just changing whitespace to test commit access...

llvm-svn: 224565
2014-12-19 02:45:48 +00:00
Peter Collingbourne 1f89ffdf4d irgen: fix canAvoid*
Patch by Andrew Wilkins!

canAvoidElementLoad and canAvoidLoad were incorrectly
eliding loads when an index expression is used as an
another array index expression. This led to a panic.

See comments on https://github.com/go-llvm/llgo/issues/175

Test Plan: lit test added

Differential Revision: http://reviews.llvm.org/D6676

llvm-svn: 224420
2014-12-17 09:45:05 +00:00
Peter Collingbourne 545e7276a8 Use the object's package to mangle method names, rather than the receiver's package
If we use the receiver's package, we can end up with identical manglings
for different functions. Consider:

package p
type U struct{}
func (U) f()

package q
import "p"
type T struct { p.U }
func (T) f()

The method set of *T has two synthetic methods named (*T).f(); one forwards to
(T).f(), and the other to (U).f(). Previously, we were distinguishing them
by the receiver's package, and in this case because both methods have the
same receiver, they received the same name.

The methods are correctly distinguished by the package owning the identifier
"f", which is available via f.Object().Pkg().

Differential Revision: http://reviews.llvm.org/D6673

llvm-svn: 224357
2014-12-16 20:04:55 +00:00
Peter Collingbourne 8bcc05d5f4 Update to new bindings.
llvm-svn: 224180
2014-12-13 02:26:00 +00:00
Peter Collingbourne c5b84a53f7 Optimize comparisons to empty string.
Geo-mean performance improvement of 0.2% (-0.3% - 0.9% @ 95% CI).

Differential Revision: http://reviews.llvm.org/D6569

llvm-svn: 223728
2014-12-09 01:02:12 +00:00
Peter Collingbourne ad9841e8ac Initial commit of llgo.
llvm-svn: 222857
2014-11-27 00:06:42 +00:00