Skip to content

Commit 7707ae5

Browse files
committed
Switch to LLVM 8
1 parent d5f7304 commit 7707ae5

File tree

9 files changed

+80
-56
lines changed

9 files changed

+80
-56
lines changed

InstrumentationBindings.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
#include "llvm/IR/LegacyPassManager.h"
1717
#include "llvm/IR/Module.h"
1818
#include "llvm/Transforms/Instrumentation.h"
19+
#include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
20+
#include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
1921

2022
using namespace llvm;
2123

@@ -28,11 +30,11 @@ void LLVMAddAddressSanitizerModulePass(LLVMPassManagerRef PM) {
2830
}
2931

3032
void LLVMAddThreadSanitizerPass(LLVMPassManagerRef PM) {
31-
unwrap(PM)->add(createThreadSanitizerPass());
33+
unwrap(PM)->add(createThreadSanitizerLegacyPassPass());
3234
}
3335

34-
void LLVMAddMemorySanitizerPass(LLVMPassManagerRef PM) {
35-
unwrap(PM)->add(createMemorySanitizerPass());
36+
void LLVMAddMemorySanitizerLegacyPassPass(LLVMPassManagerRef PM) {
37+
unwrap(PM)->add(createMemorySanitizerLegacyPassPass());
3638
}
3739

3840
void LLVMAddDataFlowSanitizerPass(LLVMPassManagerRef PM,

InstrumentationBindings.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ extern "C" {
2727
void LLVMAddAddressSanitizerFunctionPass(LLVMPassManagerRef PM);
2828
void LLVMAddAddressSanitizerModulePass(LLVMPassManagerRef PM);
2929
void LLVMAddThreadSanitizerPass(LLVMPassManagerRef PM);
30-
void LLVMAddMemorySanitizerPass(LLVMPassManagerRef PM);
30+
void LLVMAddMemorySanitizerLegacyPassPass(LLVMPassManagerRef PM);
3131
void LLVMAddDataFlowSanitizerPass(LLVMPassManagerRef PM, int ABIListFilesNum,
3232
const char **ABIListFiles);
3333

backports.go

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -6,33 +6,6 @@ package llvm
66
// #include <stdlib.h>
77
// #include "backports.h"
88
import "C"
9-
import "unsafe"
10-
11-
// Token type (used by coroutines)
12-
// https://reviews.llvm.org/D47684
13-
14-
const TokenTypeKind TypeKind = C.LLVMTokenTypeKind
15-
16-
func (c Context) TokenType() (t Type) { t.C = C.LLVMTokenTypeInContext(c.C); return }
17-
18-
// Inline assembly
19-
// https://reviews.llvm.org/D46437
20-
21-
type InlineAsmDialect C.LLVMInlineAsmDialect
22-
23-
const (
24-
InlineAsmDialectATT InlineAsmDialect = C.LLVMInlineAsmDialectATT
25-
InlineAsmDialectIntel InlineAsmDialect = C.LLVMInlineAsmDialectIntel
26-
)
27-
28-
func InlineAsm(t Type, asmString, constraints string, hasSideEffects, isAlignStack bool, dialect InlineAsmDialect) (rv Value) {
29-
casm := C.CString(asmString)
30-
defer C.free(unsafe.Pointer(casm))
31-
cconstraints := C.CString(constraints)
32-
defer C.free(unsafe.Pointer(cconstraints))
33-
rv.C = C.LLVMGetInlineAsm(t.C, casm, C.size_t(len(asmString)), cconstraints, C.size_t(len(constraints)), boolToLLVMBool(hasSideEffects), boolToLLVMBool(isAlignStack), C.LLVMInlineAsmDialect(dialect))
34-
return
35-
}
369

3710
// Coroutine optimization passes
3811
// https://reviews.llvm.org/D51642 (in progress)
@@ -55,21 +28,6 @@ func (v Value) CalledValue() (rv Value) {
5528
return
5629
}
5730

58-
// Indices
59-
// https://reviews.llvm.org/D53883 (in progress)
60-
61-
func (v Value) Indices() []uint32 {
62-
num := C.LLVMGetNumIndices(v.C)
63-
indicesPtr := C.LLVMGetIndices(v.C)
64-
// https://github.com/golang/go/wiki/cgo#turning-c-arrays-into-go-slices
65-
rawIndices := (*[1 << 20]C.uint)(unsafe.Pointer(indicesPtr))[:num:num]
66-
indices := make([]uint32, num)
67-
for i := range indices {
68-
indices[i] = uint32(rawIndices[i])
69-
}
70-
return indices
71-
}
72-
7331
// Predicates
7432
// https://reviews.llvm.org/D53884 (in progress)
7533

dibuilder.go

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,8 @@ func (d *DIBuilder) CreateBasicType(t DIBasicType) Metadata {
298298
name,
299299
C.size_t(len(t.Name)),
300300
C.uint64_t(t.SizeInBits),
301-
C.unsigned(t.Encoding),
301+
C.LLVMDWARFTypeEncoding(t.Encoding),
302+
C.LLVMDIFlags(0),
302303
)
303304
return Metadata{C: result}
304305
}
@@ -564,15 +565,19 @@ func (d *DIBuilder) CreateExpression(addr []int64) Metadata {
564565

565566
// InsertDeclareAtEnd inserts a call to llvm.dbg.declare at the end of the
566567
// specified basic block for the given value and associated debug metadata.
567-
func (d *DIBuilder) InsertDeclareAtEnd(v Value, diVarInfo, expr Metadata, bb BasicBlock) Value {
568-
result := C.LLVMDIBuilderInsertDeclareAtEnd(d.ref, v.C, diVarInfo.C, expr.C, nil, bb.C)
568+
func (d *DIBuilder) InsertDeclareAtEnd(v Value, diVarInfo, expr Metadata, l DebugLoc, bb BasicBlock) Value {
569+
loc := C.LLVMDIBuilderCreateDebugLocation(
570+
d.m.Context().C, C.uint(l.Line), C.uint(l.Col), l.Scope.C, l.InlinedAt.C)
571+
result := C.LLVMDIBuilderInsertDeclareAtEnd(d.ref, v.C, diVarInfo.C, expr.C, loc, bb.C)
569572
return Value{C: result}
570573
}
571574

572575
// InsertValueAtEnd inserts a call to llvm.dbg.value at the end of the
573576
// specified basic block for the given value and associated debug metadata.
574-
func (d *DIBuilder) InsertValueAtEnd(v Value, diVarInfo, expr Metadata, bb BasicBlock) Value {
575-
result := C.LLVMDIBuilderInsertDbgValueAtEnd(d.ref, v.C, diVarInfo.C, expr.C, nil, bb.C)
577+
func (d *DIBuilder) InsertValueAtEnd(v Value, diVarInfo, expr Metadata, l DebugLoc, bb BasicBlock) Value {
578+
loc := C.LLVMDIBuilderCreateDebugLocation(
579+
d.m.Context().C, C.uint(l.Line), C.uint(l.Col), l.Scope.C, l.InlinedAt.C)
580+
result := C.LLVMDIBuilderInsertDbgValueAtEnd(d.ref, v.C, diVarInfo.C, expr.C, loc, bb.C)
576581
return Value{C: result}
577582
}
578583

ir.go

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ type (
7474
IntPredicate C.LLVMIntPredicate
7575
FloatPredicate C.LLVMRealPredicate
7676
LandingPadClause C.LLVMLandingPadClauseTy
77+
InlineAsmDialect C.LLVMInlineAsmDialect
7778
)
7879

7980
func (c Context) IsNil() bool { return c.C == nil }
@@ -211,6 +212,7 @@ const (
211212
PointerTypeKind TypeKind = C.LLVMPointerTypeKind
212213
VectorTypeKind TypeKind = C.LLVMVectorTypeKind
213214
MetadataTypeKind TypeKind = C.LLVMMetadataTypeKind
215+
TokenTypeKind TypeKind = C.LLVMTokenTypeKind
214216
)
215217

216218
//-------------------------------------------------------------------------
@@ -314,6 +316,15 @@ const (
314316
LandingPadFilter LandingPadClause = C.LLVMLandingPadFilter
315317
)
316318

319+
//-------------------------------------------------------------------------
320+
// llvm.InlineAsmDialect
321+
//-------------------------------------------------------------------------
322+
323+
const (
324+
InlineAsmDialectATT InlineAsmDialect = C.LLVMInlineAsmDialectATT
325+
InlineAsmDialectIntel InlineAsmDialect = C.LLVMInlineAsmDialectIntel
326+
)
327+
317328
//-------------------------------------------------------------------------
318329
// llvm.Context
319330
//-------------------------------------------------------------------------
@@ -655,6 +666,7 @@ func (t Type) VectorSize() int { return int(C.LLVMGetVectorSize(t.C)) }
655666
// Operations on other types
656667
func (c Context) VoidType() (t Type) { t.C = C.LLVMVoidTypeInContext(c.C); return }
657668
func (c Context) LabelType() (t Type) { t.C = C.LLVMLabelTypeInContext(c.C); return }
669+
func (c Context) TokenType() (t Type) { t.C = C.LLVMTokenTypeInContext(c.C); return }
658670

659671
func VoidType() (t Type) { t.C = C.LLVMVoidType(); return }
660672
func LabelType() (t Type) { t.C = C.LLVMLabelType(); return }
@@ -727,7 +739,6 @@ func (v Value) IsAPHINode() (rv Value) { rv.C = C.LLVMIsAPHINode(v.C
727739
func (v Value) IsASelectInst() (rv Value) { rv.C = C.LLVMIsASelectInst(v.C); return }
728740
func (v Value) IsAShuffleVectorInst() (rv Value) { rv.C = C.LLVMIsAShuffleVectorInst(v.C); return }
729741
func (v Value) IsAStoreInst() (rv Value) { rv.C = C.LLVMIsAStoreInst(v.C); return }
730-
func (v Value) IsATerminatorInst() (rv Value) { rv.C = C.LLVMIsATerminatorInst(v.C); return }
731742
func (v Value) IsABranchInst() (rv Value) { rv.C = C.LLVMIsABranchInst(v.C); return }
732743
func (v Value) IsAInvokeInst() (rv Value) { rv.C = C.LLVMIsAInvokeInst(v.C); return }
733744
func (v Value) IsAReturnInst() (rv Value) { rv.C = C.LLVMIsAReturnInst(v.C); return }
@@ -1237,6 +1248,29 @@ func (v Value) IncomingBlock(i int) (bb BasicBlock) {
12371248
return
12381249
}
12391250

1251+
// Operations on inline assembly
1252+
func InlineAsm(t Type, asmString, constraints string, hasSideEffects, isAlignStack bool, dialect InlineAsmDialect) (rv Value) {
1253+
casm := C.CString(asmString)
1254+
defer C.free(unsafe.Pointer(casm))
1255+
cconstraints := C.CString(constraints)
1256+
defer C.free(unsafe.Pointer(cconstraints))
1257+
rv.C = C.LLVMGetInlineAsm(t.C, casm, C.size_t(len(asmString)), cconstraints, C.size_t(len(constraints)), boolToLLVMBool(hasSideEffects), boolToLLVMBool(isAlignStack), C.LLVMInlineAsmDialect(dialect))
1258+
return
1259+
}
1260+
1261+
// Operations on aggregates
1262+
func (v Value) Indices() []uint32 {
1263+
num := C.LLVMGetNumIndices(v.C)
1264+
indicesPtr := C.LLVMGetIndices(v.C)
1265+
// https://github.com/golang/go/wiki/cgo#turning-c-arrays-into-go-slices
1266+
rawIndices := (*[1 << 20]C.uint)(unsafe.Pointer(indicesPtr))[:num:num]
1267+
indices := make([]uint32, num)
1268+
for i := range indices {
1269+
indices[i] = uint32(rawIndices[i])
1270+
}
1271+
return indices
1272+
}
1273+
12401274
//-------------------------------------------------------------------------
12411275
// llvm.Builder
12421276
//-------------------------------------------------------------------------

llvm_config_linux.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ package llvm
44

55
// Automatically generated by `make config BUILDDIR=`, do not edit.
66

7-
// #cgo CPPFLAGS: -I/usr/lib/llvm-7/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
7+
// #cgo CPPFLAGS: -I/usr/lib/llvm-8/include -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
88
// #cgo CXXFLAGS: -std=c++11
9-
// #cgo LDFLAGS: -L/usr/lib/llvm-7/lib -lLLVM-7
9+
// #cgo LDFLAGS: -L/usr/lib/llvm-8/lib -lLLVM-8
1010
import "C"
1111

1212
type (run_build_sh int)

target.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ const (
6262
const (
6363
CodeModelDefault CodeModel = C.LLVMCodeModelDefault
6464
CodeModelJITDefault CodeModel = C.LLVMCodeModelJITDefault
65+
CodeModelTiny CodeModel = C.LLVMCodeModelTiny
6566
CodeModelSmall CodeModel = C.LLVMCodeModelSmall
6667
CodeModelKernel CodeModel = C.LLVMCodeModelKernel
6768
CodeModelMedium CodeModel = C.LLVMCodeModelMedium

transforms_coroutines.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
//===- transforms_coroutines.go - Bindings for coroutines -----------------===//
2+
//
3+
// The LLVM Compiler Infrastructure
4+
//
5+
// This file is distributed under the University of Illinois Open Source
6+
// License. See LICENSE.TXT for details.
7+
//
8+
//===----------------------------------------------------------------------===//
9+
//
10+
// This file defines bindings for the coroutines component.
11+
//
12+
//===----------------------------------------------------------------------===//
13+
14+
package llvm
15+
16+
/*
17+
#include "llvm-c/Transforms/Coroutines.h"
18+
*/
19+
import "C"
20+
21+
func (pm PassManager) AddCoroEarlyPass() { C.LLVMAddCoroEarlyPass(pm.C) }
22+
func (pm PassManager) AddCoroSplitPass() { C.LLVMAddCoroSplitPass(pm.C) }
23+
func (pm PassManager) AddCoroElidePass() { C.LLVMAddCoroElidePass(pm.C) }
24+
func (pm PassManager) AddCoroCleanupPass() { C.LLVMAddCoroCleanupPass(pm.C) }

transforms_instrumentation.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ func (pm PassManager) AddThreadSanitizerPass() {
3232
C.LLVMAddThreadSanitizerPass(pm.C)
3333
}
3434

35-
func (pm PassManager) AddMemorySanitizerPass() {
36-
C.LLVMAddMemorySanitizerPass(pm.C)
35+
func (pm PassManager) AddMemorySanitizerLegacyPassPass() {
36+
C.LLVMAddMemorySanitizerLegacyPassPass(pm.C)
3737
}
3838

3939
func (pm PassManager) AddDataFlowSanitizerPass(abilist []string) {

0 commit comments

Comments
 (0)