[PATCH] D12630: [llgo] irgen: always use TargetMachine's data layout

Andrew Wilkins via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 4 03:53:07 PDT 2015


axw created this revision.
axw added a reviewer: pcc.
axw added a subscriber: llvm-commits.
Herald added subscribers: dschuff, jfb.

Another attempt at resolving the runtime assertion
in llgoi due to data layout mismatch between module
and execution engine.

The X86 data layout constant appears to be unnecessary,
and does not match what the execution engine picks.
Using the registered Target, we pick the same data
layout as the execution engine.

While I was in the vicinity, I deleted the last
remnants of PNaCl support.

http://reviews.llvm.org/D12630

Files:
  irgen/compiler.go
  irgen/targets.go

Index: irgen/targets.go
===================================================================
--- irgen/targets.go
+++ irgen/targets.go
@@ -20,29 +20,14 @@
 	"llvm.org/llvm/bindings/go/llvm"
 )
 
-// PNaClTriple is the LLVM target triple that should be used to compile
-// modules to be compatible with PNaCl (Portable Native Client).
-const PNaClTriple = "armv7-none-linux-gnueabi"
-
-// Below are the target data representation constants generated by clang.
-// For unknown targets, we enumerate all targets known to LLVM and use
-// the first one with a matching architecture.
-const (
-	x86TargetData = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
-)
-
 // llvmDataLayout returns the data layout string
 // representation for the specified LLVM triple.
 func llvmDataLayout(triple string) (string, error) {
 	// Triples are several fields separated by '-' characters.
 	// The first field is the architecture. The architecture's
 	// canonical form may include a '-' character, which would
 	// have been translated to '_' for inclusion in a triple.
 	arch := parseArch(triple[:strings.IndexRune(triple, '-')])
-	switch arch {
-	case "x86-64":
-		return x86TargetData, nil
-	}
 	for target := llvm.FirstTarget(); target.C != nil; target = target.NextTarget() {
 		if arch == target.Name() {
 			machine := target.CreateTargetMachine(
Index: irgen/compiler.go
===================================================================
--- irgen/compiler.go
+++ irgen/compiler.go
@@ -20,7 +20,6 @@
 	"log"
 	"sort"
 	"strconv"
-	"strings"
 
 	llgobuild "llvm.org/llgo/build"
 	"llvm.org/llgo/debug"
@@ -110,15 +109,10 @@
 type Compiler struct {
 	opts       CompilerOptions
 	dataLayout string
-	pnacl      bool
 }
 
 func NewCompiler(opts CompilerOptions) (*Compiler, error) {
 	compiler := &Compiler{opts: opts}
-	if strings.ToLower(compiler.opts.TargetTriple) == "pnacl" {
-		compiler.opts.TargetTriple = PNaClTriple
-		compiler.pnacl = true
-	}
 	dataLayout, err := llvmDataLayout(compiler.opts.TargetTriple)
 	if err != nil {
 		return nil, err
@@ -133,7 +127,6 @@
 		CompilerOptions: c.opts,
 		dataLayout:      c.dataLayout,
 		target:          target,
-		pnacl:           c.pnacl,
 		llvmtypes:       NewLLVMTypeMap(llvm.GlobalContext(), target),
 	}
 	return compiler.compile(fset, astFiles, importpath)
@@ -151,12 +144,6 @@
 	llvmtypes *llvmTypeMap
 	types     *TypeMap
 
-	// pnacl is set to true if the target triple was originally
-	// specified as "pnacl". This is necessary, as the TargetTriple
-	// field will have been updated to the true triple used to
-	// compile PNaCl modules.
-	pnacl bool
-
 	debug *debug.DIBuilder
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D12630.34022.patch
Type: text/x-patch
Size: 2740 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150904/bf9d5694/attachment.bin>


More information about the llvm-commits mailing list