Skip to content

Commit a9391d9

Browse files
committed
Fix build issues once LLVM has been upgraded
* LLVM now has a C interface to LLVMBuildAtomicRMW * The exception handling support for the JIT seems to have been dropped * Various interfaces have been added or headers have changed
1 parent e08513c commit a9391d9

File tree

5 files changed

+48
-55
lines changed

5 files changed

+48
-55
lines changed

src/librustc/back/passes.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ pub fn create_standard_passes(level: OptLevel) -> ~[~str] {
9898
passes.push(~"sroa");
9999
passes.push(~"domtree");
100100
passes.push(~"early-cse");
101-
passes.push(~"simplify-libcalls");
102101
passes.push(~"lazy-value-info");
103102
passes.push(~"jump-threading");
104103
passes.push(~"correlated-propagation");

src/librustc/lib/llvm.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1589,7 +1589,8 @@ pub mod llvm {
15891589
Op: AtomicBinOp,
15901590
LHS: ValueRef,
15911591
RHS: ValueRef,
1592-
Order: AtomicOrdering)
1592+
Order: AtomicOrdering,
1593+
SingleThreaded: Bool)
15931594
-> ValueRef;
15941595

15951596
/* Selected entries from the downcasts. */

src/librustc/middle/trans/build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,6 +1124,6 @@ pub fn AtomicRMW(cx: block, op: AtomicBinOp,
11241124
dst: ValueRef, src: ValueRef,
11251125
order: AtomicOrdering) -> ValueRef {
11261126
unsafe {
1127-
llvm::LLVMBuildAtomicRMW(B(cx), op, dst, src, order)
1127+
llvm::LLVMBuildAtomicRMW(B(cx), op, dst, src, order, lib::llvm::False)
11281128
}
11291129
}

src/rustllvm/RustWrapper.cpp

Lines changed: 43 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ class RustMCJITMemoryManager : public JITMemoryManager {
113113

114114
virtual uint8_t *allocateDataSection(uintptr_t Size, unsigned Alignment,
115115
unsigned SectionID, bool isReadOnly);
116+
bool finalizeMemory(std::string *ErrMsg) { return false; }
116117

117118
virtual bool applyPermissions(std::string *Str);
118119

@@ -340,7 +341,6 @@ LLVMRustBuildJIT(void* mem,
340341

341342
std::string Err;
342343
TargetOptions Options;
343-
Options.JITExceptionHandling = true;
344344
Options.JITEmitDebugInfo = true;
345345
Options.NoFramePointerElim = true;
346346
Options.EnableSegmentedStacks = EnableSegmentedStacks;
@@ -513,15 +513,6 @@ extern "C" LLVMValueRef LLVMBuildAtomicCmpXchg(LLVMBuilderRef B,
513513
return wrap(unwrap(B)->CreateAtomicCmpXchg(unwrap(target), unwrap(old),
514514
unwrap(source), order));
515515
}
516-
extern "C" LLVMValueRef LLVMBuildAtomicRMW(LLVMBuilderRef B,
517-
AtomicRMWInst::BinOp op,
518-
LLVMValueRef target,
519-
LLVMValueRef source,
520-
AtomicOrdering order) {
521-
return wrap(unwrap(B)->CreateAtomicRMW(op,
522-
unwrap(target), unwrap(source),
523-
order));
524-
}
525516

526517
extern "C" void LLVMSetDebug(int Enabled) {
527518
#ifndef NDEBUG
@@ -565,8 +556,8 @@ extern "C" bool LLVMRustStartMultithreading() {
565556
typedef DIBuilder* DIBuilderRef;
566557

567558
template<typename DIT>
568-
DIT unwrapDI(LLVMValueRef ref) {
569-
return DIT(ref ? unwrap<MDNode>(ref) : NULL);
559+
DIT unwrapDI(LLVMValueRef ref) {
560+
return DIT(ref ? unwrap<MDNode>(ref) : NULL);
570561
}
571562

572563
extern "C" DIBuilderRef LLVMDIBuilderCreate(LLVMModuleRef M) {
@@ -604,21 +595,21 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateFile(
604595

605596
extern "C" LLVMValueRef LLVMDIBuilderCreateSubroutineType(
606597
DIBuilderRef Builder,
607-
LLVMValueRef File,
598+
LLVMValueRef File,
608599
LLVMValueRef ParameterTypes) {
609600
return wrap(Builder->createSubroutineType(
610-
unwrapDI<DIFile>(File),
601+
unwrapDI<DIFile>(File),
611602
unwrapDI<DIArray>(ParameterTypes)));
612603
}
613604

614605
extern "C" LLVMValueRef LLVMDIBuilderCreateFunction(
615606
DIBuilderRef Builder,
616-
LLVMValueRef Scope,
607+
LLVMValueRef Scope,
617608
const char* Name,
618609
const char* LinkageName,
619-
LLVMValueRef File,
610+
LLVMValueRef File,
620611
unsigned LineNo,
621-
LLVMValueRef Ty,
612+
LLVMValueRef Ty,
622613
bool isLocalToUnit,
623614
bool isDefinition,
624615
unsigned ScopeLine,
@@ -628,11 +619,11 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateFunction(
628619
LLVMValueRef TParam,
629620
LLVMValueRef Decl) {
630621
return wrap(Builder->createFunction(
631-
unwrapDI<DIScope>(Scope), Name, LinkageName,
632-
unwrapDI<DIFile>(File), LineNo,
633-
unwrapDI<DIType>(Ty), isLocalToUnit, isDefinition, ScopeLine,
622+
unwrapDI<DIDescriptor>(Scope), Name, LinkageName,
623+
unwrapDI<DIFile>(File), LineNo,
624+
unwrapDI<DICompositeType>(Ty), isLocalToUnit, isDefinition, ScopeLine,
634625
Flags, isOptimized,
635-
unwrap<Function>(Fn),
626+
unwrap<Function>(Fn),
636627
unwrapDI<MDNode*>(TParam),
637628
unwrapDI<MDNode*>(Decl)));
638629
}
@@ -644,10 +635,10 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateBasicType(
644635
uint64_t AlignInBits,
645636
unsigned Encoding) {
646637
return wrap(Builder->createBasicType(
647-
Name, SizeInBits,
638+
Name, SizeInBits,
648639
AlignInBits, Encoding));
649640
}
650-
641+
651642
extern "C" LLVMValueRef LLVMDIBuilderCreatePointerType(
652643
DIBuilderRef Builder,
653644
LLVMValueRef PointeeTy,
@@ -672,11 +663,11 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateStructType(
672663
unsigned RunTimeLang,
673664
LLVMValueRef VTableHolder) {
674665
return wrap(Builder->createStructType(
675-
unwrapDI<DIDescriptor>(Scope), Name,
676-
unwrapDI<DIFile>(File), LineNumber,
677-
SizeInBits, AlignInBits, Flags,
678-
unwrapDI<DIType>(DerivedFrom),
679-
unwrapDI<DIArray>(Elements), RunTimeLang,
666+
unwrapDI<DIDescriptor>(Scope), Name,
667+
unwrapDI<DIFile>(File), LineNumber,
668+
SizeInBits, AlignInBits, Flags,
669+
unwrapDI<DIType>(DerivedFrom),
670+
unwrapDI<DIArray>(Elements), RunTimeLang,
680671
unwrapDI<MDNode*>(VTableHolder)));
681672
}
682673

@@ -692,23 +683,23 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateMemberType(
692683
unsigned Flags,
693684
LLVMValueRef Ty) {
694685
return wrap(Builder->createMemberType(
695-
unwrapDI<DIDescriptor>(Scope), Name,
686+
unwrapDI<DIDescriptor>(Scope), Name,
696687
unwrapDI<DIFile>(File), LineNo,
697-
SizeInBits, AlignInBits, OffsetInBits, Flags,
688+
SizeInBits, AlignInBits, OffsetInBits, Flags,
698689
unwrapDI<DIType>(Ty)));
699690
}
700-
691+
701692
extern "C" LLVMValueRef LLVMDIBuilderCreateLexicalBlock(
702693
DIBuilderRef Builder,
703694
LLVMValueRef Scope,
704695
LLVMValueRef File,
705696
unsigned Line,
706697
unsigned Col) {
707698
return wrap(Builder->createLexicalBlock(
708-
unwrapDI<DIDescriptor>(Scope),
699+
unwrapDI<DIDescriptor>(Scope),
709700
unwrapDI<DIFile>(File), Line, Col));
710701
}
711-
702+
712703
extern "C" LLVMValueRef LLVMDIBuilderCreateLocalVariable(
713704
DIBuilderRef Builder,
714705
unsigned Tag,
@@ -720,45 +711,45 @@ extern "C" LLVMValueRef LLVMDIBuilderCreateLocalVariable(
720711
bool AlwaysPreserve,
721712
unsigned Flags,
722713
unsigned ArgNo) {
723-
return wrap(Builder->createLocalVariable(Tag,
724-
unwrapDI<DIDescriptor>(Scope), Name,
725-
unwrapDI<DIFile>(File),
726-
LineNo,
714+
return wrap(Builder->createLocalVariable(Tag,
715+
unwrapDI<DIDescriptor>(Scope), Name,
716+
unwrapDI<DIFile>(File),
717+
LineNo,
727718
unwrapDI<DIType>(Ty), AlwaysPreserve, Flags, ArgNo));
728719
}
729720

730721
extern "C" LLVMValueRef LLVMDIBuilderCreateArrayType(
731722
DIBuilderRef Builder,
732-
uint64_t Size,
733-
uint64_t AlignInBits,
734-
LLVMValueRef Ty,
723+
uint64_t Size,
724+
uint64_t AlignInBits,
725+
LLVMValueRef Ty,
735726
LLVMValueRef Subscripts) {
736727
return wrap(Builder->createArrayType(Size, AlignInBits,
737-
unwrapDI<DIType>(Ty),
728+
unwrapDI<DIType>(Ty),
738729
unwrapDI<DIArray>(Subscripts)));
739730
}
740731

741732
extern "C" LLVMValueRef LLVMDIBuilderCreateVectorType(
742733
DIBuilderRef Builder,
743-
uint64_t Size,
744-
uint64_t AlignInBits,
745-
LLVMValueRef Ty,
734+
uint64_t Size,
735+
uint64_t AlignInBits,
736+
LLVMValueRef Ty,
746737
LLVMValueRef Subscripts) {
747738
return wrap(Builder->createVectorType(Size, AlignInBits,
748-
unwrapDI<DIType>(Ty),
739+
unwrapDI<DIType>(Ty),
749740
unwrapDI<DIArray>(Subscripts)));
750741
}
751742

752743
extern "C" LLVMValueRef LLVMDIBuilderGetOrCreateSubrange(
753-
DIBuilderRef Builder,
754-
int64_t Lo,
744+
DIBuilderRef Builder,
745+
int64_t Lo,
755746
int64_t Count) {
756747
return wrap(Builder->getOrCreateSubrange(Lo, Count));
757748
}
758749

759750
extern "C" LLVMValueRef LLVMDIBuilderGetOrCreateArray(
760751
DIBuilderRef Builder,
761-
LLVMValueRef* Ptr,
752+
LLVMValueRef* Ptr,
762753
unsigned Count) {
763754
return wrap(Builder->getOrCreateArray(
764755
ArrayRef<Value*>(reinterpret_cast<Value**>(Ptr), Count)));
@@ -770,8 +761,8 @@ extern "C" LLVMValueRef LLVMDIBuilderInsertDeclareAtEnd(
770761
LLVMValueRef VarInfo,
771762
LLVMBasicBlockRef InsertAtEnd) {
772763
return wrap(Builder->insertDeclare(
773-
unwrap(Val),
774-
unwrapDI<DIVariable>(VarInfo),
764+
unwrap(Val),
765+
unwrapDI<DIVariable>(VarInfo),
775766
unwrap(InsertAtEnd)));
776767
}
777768

@@ -781,7 +772,7 @@ extern "C" LLVMValueRef LLVMDIBuilderInsertDeclareBefore(
781772
LLVMValueRef VarInfo,
782773
LLVMValueRef InsertBefore) {
783774
return wrap(Builder->insertDeclare(
784-
unwrap(Val),
785-
unwrapDI<DIVariable>(VarInfo),
775+
unwrap(Val),
776+
unwrapDI<DIVariable>(VarInfo),
786777
unwrap<Instruction>(InsertBefore)));
787778
}

src/rustllvm/rustllvm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#include "llvm/IR/IRBuilder.h"
1112
#include "llvm/IR/InlineAsm.h"
1213
#include "llvm/IR/LLVMContext.h"
14+
#include "llvm/IR/Module.h"
1315
#include "llvm/Linker.h"
1416
#include "llvm/PassManager.h"
1517
#include "llvm/IR/InlineAsm.h"

0 commit comments

Comments
 (0)