Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3cc8b17

Browse files
committedNov 5, 2018
Remove support for building against LLVM 4
With emscripten removed in #55626, we no longer need to support building against LLVM 4.
1 parent 6cfc603 commit 3cc8b17

File tree

6 files changed

+29
-259
lines changed

6 files changed

+29
-259
lines changed
 

‎src/librustc_codegen_llvm/back/lto.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -595,9 +595,7 @@ fn run_pass_manager(cgcx: &CodegenContext,
595595
};
596596
with_llvm_pmb(llmod, config, opt_level, false, &mut |b| {
597597
if thin {
598-
if !llvm::LLVMRustPassManagerBuilderPopulateThinLTOPassManager(b, pm) {
599-
panic!("this version of LLVM does not support ThinLTO");
600-
}
598+
llvm::LLVMRustPassManagerBuilderPopulateThinLTOPassManager(b, pm);
601599
} else {
602600
llvm::LLVMPassManagerBuilderPopulateLTOPassManager(b, pm,
603601
/* Internalize = */ False,

‎src/librustc_codegen_llvm/builder.rs

Lines changed: 13 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -859,8 +859,7 @@ impl Builder<'a, 'll, 'tcx> {
859859
// FIXME: add a non-fast math version once
860860
// https://bugs.llvm.org/show_bug.cgi?id=36732
861861
// is fixed.
862-
let instr = llvm::LLVMRustBuildVectorReduceFAdd(self.llbuilder, acc, src)
863-
.expect("LLVMRustBuildVectorReduceFAdd is not available in LLVM version < 5.0");
862+
let instr = llvm::LLVMRustBuildVectorReduceFAdd(self.llbuilder, acc, src);
864863
llvm::LLVMRustSetHasUnsafeAlgebra(instr);
865864
instr
866865
}
@@ -871,92 +870,62 @@ impl Builder<'a, 'll, 'tcx> {
871870
// FIXME: add a non-fast math version once
872871
// https://bugs.llvm.org/show_bug.cgi?id=36732
873872
// is fixed.
874-
let instr = llvm::LLVMRustBuildVectorReduceFMul(self.llbuilder, acc, src)
875-
.expect("LLVMRustBuildVectorReduceFMul is not available in LLVM version < 5.0");
873+
let instr = llvm::LLVMRustBuildVectorReduceFMul(self.llbuilder, acc, src);
876874
llvm::LLVMRustSetHasUnsafeAlgebra(instr);
877875
instr
878876
}
879877
}
880878
pub fn vector_reduce_add(&self, src: &'ll Value) -> &'ll Value {
881879
self.count_insn("vector.reduce.add");
882-
unsafe {
883-
let instr = llvm::LLVMRustBuildVectorReduceAdd(self.llbuilder, src);
884-
instr.expect("LLVMRustBuildVectorReduceAdd is not available in LLVM version < 5.0")
885-
}
880+
unsafe { llvm::LLVMRustBuildVectorReduceAdd(self.llbuilder, src) }
886881
}
887882
pub fn vector_reduce_mul(&self, src: &'ll Value) -> &'ll Value {
888883
self.count_insn("vector.reduce.mul");
889-
unsafe {
890-
let instr = llvm::LLVMRustBuildVectorReduceMul(self.llbuilder, src);
891-
instr.expect("LLVMRustBuildVectorReduceMul is not available in LLVM version < 5.0")
892-
}
884+
unsafe { llvm::LLVMRustBuildVectorReduceMul(self.llbuilder, src) }
893885
}
894886
pub fn vector_reduce_and(&self, src: &'ll Value) -> &'ll Value {
895887
self.count_insn("vector.reduce.and");
896-
unsafe {
897-
let instr = llvm::LLVMRustBuildVectorReduceAnd(self.llbuilder, src);
898-
instr.expect("LLVMRustBuildVectorReduceAnd is not available in LLVM version < 5.0")
899-
}
888+
unsafe { llvm::LLVMRustBuildVectorReduceAnd(self.llbuilder, src) }
900889
}
901890
pub fn vector_reduce_or(&self, src: &'ll Value) -> &'ll Value {
902891
self.count_insn("vector.reduce.or");
903-
unsafe {
904-
let instr = llvm::LLVMRustBuildVectorReduceOr(self.llbuilder, src);
905-
instr.expect("LLVMRustBuildVectorReduceOr is not available in LLVM version < 5.0")
906-
}
892+
unsafe { llvm::LLVMRustBuildVectorReduceOr(self.llbuilder, src) }
907893
}
908894
pub fn vector_reduce_xor(&self, src: &'ll Value) -> &'ll Value {
909895
self.count_insn("vector.reduce.xor");
910-
unsafe {
911-
let instr = llvm::LLVMRustBuildVectorReduceXor(self.llbuilder, src);
912-
instr.expect("LLVMRustBuildVectorReduceXor is not available in LLVM version < 5.0")
913-
}
896+
unsafe { llvm::LLVMRustBuildVectorReduceXor(self.llbuilder, src) }
914897
}
915898
pub fn vector_reduce_fmin(&self, src: &'ll Value) -> &'ll Value {
916899
self.count_insn("vector.reduce.fmin");
917-
unsafe {
918-
let instr = llvm::LLVMRustBuildVectorReduceFMin(self.llbuilder, src, /*NoNaNs:*/ false);
919-
instr.expect("LLVMRustBuildVectorReduceFMin is not available in LLVM version < 5.0")
920-
}
900+
unsafe { llvm::LLVMRustBuildVectorReduceFMin(self.llbuilder, src, /*NoNaNs:*/ false) }
921901
}
922902
pub fn vector_reduce_fmax(&self, src: &'ll Value) -> &'ll Value {
923903
self.count_insn("vector.reduce.fmax");
924-
unsafe {
925-
let instr = llvm::LLVMRustBuildVectorReduceFMax(self.llbuilder, src, /*NoNaNs:*/ false);
926-
instr.expect("LLVMRustBuildVectorReduceFMax is not available in LLVM version < 5.0")
927-
}
904+
unsafe { llvm::LLVMRustBuildVectorReduceFMax(self.llbuilder, src, /*NoNaNs:*/ false) }
928905
}
929906
pub fn vector_reduce_fmin_fast(&self, src: &'ll Value) -> &'ll Value {
930907
self.count_insn("vector.reduce.fmin_fast");
931908
unsafe {
932-
let instr = llvm::LLVMRustBuildVectorReduceFMin(self.llbuilder, src, /*NoNaNs:*/ true)
933-
.expect("LLVMRustBuildVectorReduceFMin is not available in LLVM version < 5.0");
909+
let instr = llvm::LLVMRustBuildVectorReduceFMin(self.llbuilder, src, /*NoNaNs:*/ true);
934910
llvm::LLVMRustSetHasUnsafeAlgebra(instr);
935911
instr
936912
}
937913
}
938914
pub fn vector_reduce_fmax_fast(&self, src: &'ll Value) -> &'ll Value {
939915
self.count_insn("vector.reduce.fmax_fast");
940916
unsafe {
941-
let instr = llvm::LLVMRustBuildVectorReduceFMax(self.llbuilder, src, /*NoNaNs:*/ true)
942-
.expect("LLVMRustBuildVectorReduceFMax is not available in LLVM version < 5.0");
917+
let instr = llvm::LLVMRustBuildVectorReduceFMax(self.llbuilder, src, /*NoNaNs:*/ true);
943918
llvm::LLVMRustSetHasUnsafeAlgebra(instr);
944919
instr
945920
}
946921
}
947922
pub fn vector_reduce_min(&self, src: &'ll Value, is_signed: bool) -> &'ll Value {
948923
self.count_insn("vector.reduce.min");
949-
unsafe {
950-
let instr = llvm::LLVMRustBuildVectorReduceMin(self.llbuilder, src, is_signed);
951-
instr.expect("LLVMRustBuildVectorReduceMin is not available in LLVM version < 5.0")
952-
}
924+
unsafe { llvm::LLVMRustBuildVectorReduceMin(self.llbuilder, src, is_signed) }
953925
}
954926
pub fn vector_reduce_max(&self, src: &'ll Value, is_signed: bool) -> &'ll Value {
955927
self.count_insn("vector.reduce.max");
956-
unsafe {
957-
let instr = llvm::LLVMRustBuildVectorReduceMax(self.llbuilder, src, is_signed);
958-
instr.expect("LLVMRustBuildVectorReduceMax is not available in LLVM version < 5.0")
959-
}
928+
unsafe { llvm::LLVMRustBuildVectorReduceMax(self.llbuilder, src, is_signed) }
960929
}
961930

962931
pub fn extract_value(&self, agg_val: &'ll Value, idx: u64) -> &'ll Value {

‎src/librustc_codegen_llvm/llvm/ffi.rs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,42 +1041,42 @@ extern "C" {
10411041
pub fn LLVMRustBuildVectorReduceFAdd(B: &Builder<'a>,
10421042
Acc: &'a Value,
10431043
Src: &'a Value)
1044-
-> Option<&'a Value>;
1044+
-> &'a Value;
10451045
pub fn LLVMRustBuildVectorReduceFMul(B: &Builder<'a>,
10461046
Acc: &'a Value,
10471047
Src: &'a Value)
1048-
-> Option<&'a Value>;
1048+
-> &'a Value;
10491049
pub fn LLVMRustBuildVectorReduceAdd(B: &Builder<'a>,
10501050
Src: &'a Value)
1051-
-> Option<&'a Value>;
1051+
-> &'a Value;
10521052
pub fn LLVMRustBuildVectorReduceMul(B: &Builder<'a>,
10531053
Src: &'a Value)
1054-
-> Option<&'a Value>;
1054+
-> &'a Value;
10551055
pub fn LLVMRustBuildVectorReduceAnd(B: &Builder<'a>,
10561056
Src: &'a Value)
1057-
-> Option<&'a Value>;
1057+
-> &'a Value;
10581058
pub fn LLVMRustBuildVectorReduceOr(B: &Builder<'a>,
10591059
Src: &'a Value)
1060-
-> Option<&'a Value>;
1060+
-> &'a Value;
10611061
pub fn LLVMRustBuildVectorReduceXor(B: &Builder<'a>,
10621062
Src: &'a Value)
1063-
-> Option<&'a Value>;
1063+
-> &'a Value;
10641064
pub fn LLVMRustBuildVectorReduceMin(B: &Builder<'a>,
10651065
Src: &'a Value,
10661066
IsSigned: bool)
1067-
-> Option<&'a Value>;
1067+
-> &'a Value;
10681068
pub fn LLVMRustBuildVectorReduceMax(B: &Builder<'a>,
10691069
Src: &'a Value,
10701070
IsSigned: bool)
1071-
-> Option<&'a Value>;
1071+
-> &'a Value;
10721072
pub fn LLVMRustBuildVectorReduceFMin(B: &Builder<'a>,
10731073
Src: &'a Value,
10741074
IsNaN: bool)
1075-
-> Option<&'a Value>;
1075+
-> &'a Value;
10761076
pub fn LLVMRustBuildVectorReduceFMax(B: &Builder<'a>,
10771077
Src: &'a Value,
10781078
IsNaN: bool)
1079-
-> Option<&'a Value>;
1079+
-> &'a Value;
10801080

10811081
pub fn LLVMRustBuildMinNum(
10821082
B: &Builder<'a>,
@@ -1157,7 +1157,7 @@ extern "C" {
11571157
RunInliner: Bool);
11581158
pub fn LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
11591159
PMB: &PassManagerBuilder,
1160-
PM: &PassManager) -> bool;
1160+
PM: &PassManager);
11611161

11621162
// Stuff that's in rustllvm/ because it's not upstream yet.
11631163

‎src/rustllvm/ArchiveWrapper.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,7 @@ LLVMRustWriteArchive(char *Dst, size_t NumMembers,
204204
LLVMRustSetLastError(toString(MOrErr.takeError()).c_str());
205205
return LLVMRustResult::Failure;
206206
}
207-
#if LLVM_VERSION_GE(5, 0)
208207
MOrErr->MemberName = sys::path::filename(MOrErr->MemberName);
209-
#endif
210208
Members.push_back(std::move(*MOrErr));
211209
} else {
212210
Expected<NewArchiveMember> MOrErr =

‎src/rustllvm/PassWrapper.cpp

Lines changed: 1 addition & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@
3636
#include "llvm/Transforms/IPO/FunctionImport.h"
3737
#include "llvm/Transforms/Utils/FunctionImportUtils.h"
3838
#include "llvm/LTO/LTO.h"
39-
#if LLVM_VERSION_LE(4, 0)
40-
#include "llvm/Object/ModuleSummaryIndexObjectFile.h"
41-
#endif
4239

4340
#include "llvm-c/Transforms/PassManagerBuilder.h"
4441

@@ -111,12 +108,11 @@ extern "C" void LLVMRustAddPass(LLVMPassManagerRef PMR, LLVMPassRef RustPass) {
111108
}
112109

113110
extern "C"
114-
bool LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
111+
void LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
115112
LLVMPassManagerBuilderRef PMBR,
116113
LLVMPassManagerRef PMR
117114
) {
118115
unwrap(PMBR)->populateThinLTOPassManager(*unwrap(PMR));
119-
return true;
120116
}
121117

122118
#ifdef LLVM_COMPONENT_X86
@@ -869,21 +865,10 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
869865

870866
Ret->ModuleMap[module->identifier] = mem_buffer;
871867

872-
#if LLVM_VERSION_GE(5, 0)
873868
if (Error Err = readModuleSummaryIndex(mem_buffer, Ret->Index, i)) {
874869
LLVMRustSetLastError(toString(std::move(Err)).c_str());
875870
return nullptr;
876871
}
877-
#else
878-
Expected<std::unique_ptr<object::ModuleSummaryIndexObjectFile>> ObjOrErr =
879-
object::ModuleSummaryIndexObjectFile::create(mem_buffer);
880-
if (!ObjOrErr) {
881-
LLVMRustSetLastError(toString(ObjOrErr.takeError()).c_str());
882-
return nullptr;
883-
}
884-
auto Index = (*ObjOrErr)->takeIndex();
885-
Ret->Index.mergeFrom(std::move(Index), i);
886-
#endif
887872
}
888873

889874
// Collect for each module the list of function it defines (GUID -> Summary)
@@ -900,7 +885,6 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
900885
// combined index
901886
//
902887
// This is copied from `lib/LTO/ThinLTOCodeGenerator.cpp`
903-
#if LLVM_VERSION_GE(5, 0)
904888
#if LLVM_VERSION_GE(7, 0)
905889
auto deadIsPrevailing = [&](GlobalValue::GUID G) {
906890
return PrevailingType::Unknown;
@@ -915,16 +899,6 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
915899
Ret->ImportLists,
916900
Ret->ExportLists
917901
);
918-
#else
919-
auto DeadSymbols = computeDeadSymbols(Ret->Index, Ret->GUIDPreservedSymbols);
920-
ComputeCrossModuleImport(
921-
Ret->Index,
922-
Ret->ModuleToDefinedGVSummaries,
923-
Ret->ImportLists,
924-
Ret->ExportLists,
925-
&DeadSymbols
926-
);
927-
#endif
928902

929903
// Resolve LinkOnce/Weak symbols, this has to be computed early be cause it
930904
// impacts the caching.
@@ -934,13 +908,8 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
934908
StringMap<std::map<GlobalValue::GUID, GlobalValue::LinkageTypes>> ResolvedODR;
935909
DenseMap<GlobalValue::GUID, const GlobalValueSummary *> PrevailingCopy;
936910
for (auto &I : Ret->Index) {
937-
#if LLVM_VERSION_GE(5, 0)
938911
if (I.second.SummaryList.size() > 1)
939912
PrevailingCopy[I.first] = getFirstDefinitionForLinker(I.second.SummaryList);
940-
#else
941-
if (I.second.size() > 1)
942-
PrevailingCopy[I.first] = getFirstDefinitionForLinker(I.second);
943-
#endif
944913
}
945914
auto isPrevailing = [&](GlobalValue::GUID GUID, const GlobalValueSummary *S) {
946915
const auto &Prevailing = PrevailingCopy.find(GUID);
@@ -962,19 +931,11 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
962931
// linkage will stay as external, and internal will stay as internal.
963932
std::set<GlobalValue::GUID> ExportedGUIDs;
964933
for (auto &List : Ret->Index) {
965-
#if LLVM_VERSION_GE(5, 0)
966934
for (auto &GVS: List.second.SummaryList) {
967-
#else
968-
for (auto &GVS: List.second) {
969-
#endif
970935
if (GlobalValue::isLocalLinkage(GVS->linkage()))
971936
continue;
972937
auto GUID = GVS->getOriginalName();
973-
#if LLVM_VERSION_GE(5, 0)
974938
if (GVS->flags().Live)
975-
#else
976-
if (!DeadSymbols.count(GUID))
977-
#endif
978939
ExportedGUIDs.insert(GUID);
979940
}
980941
}

‎src/rustllvm/RustWrapper.cpp

Lines changed: 2 additions & 158 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
// except according to those terms.
1010

1111
#include "rustllvm.h"
12+
#include "llvm/IR/CallSite.h"
1213
#include "llvm/IR/DebugInfoMetadata.h"
1314
#include "llvm/IR/DiagnosticInfo.h"
1415
#include "llvm/IR/DiagnosticPrinter.h"
@@ -18,14 +19,7 @@
1819
#include "llvm/Object/ObjectFile.h"
1920
#include "llvm/Bitcode/BitcodeWriterPass.h"
2021
#include "llvm/Support/Signals.h"
21-
22-
#include "llvm/IR/CallSite.h"
23-
24-
#if LLVM_VERSION_GE(5, 0)
2522
#include "llvm/ADT/Optional.h"
26-
#else
27-
#include <cstdlib>
28-
#endif
2923

3024
#include <iostream>
3125

@@ -212,14 +206,7 @@ extern "C" void LLVMRustAddCallSiteAttribute(LLVMValueRef Instr, unsigned Index,
212206
LLVMRustAttribute RustAttr) {
213207
CallSite Call = CallSite(unwrap<Instruction>(Instr));
214208
Attribute Attr = Attribute::get(Call->getContext(), fromRust(RustAttr));
215-
#if LLVM_VERSION_GE(5, 0)
216209
Call.addAttribute(Index, Attr);
217-
#else
218-
AttrBuilder B(Attr);
219-
Call.setAttributes(Call.getAttributes().addAttributes(
220-
Call->getContext(), Index,
221-
AttributeSet::get(Call->getContext(), Index, B)));
222-
#endif
223210
}
224211

225212
extern "C" void LLVMRustAddAlignmentCallSiteAttr(LLVMValueRef Instr,
@@ -228,14 +215,8 @@ extern "C" void LLVMRustAddAlignmentCallSiteAttr(LLVMValueRef Instr,
228215
CallSite Call = CallSite(unwrap<Instruction>(Instr));
229216
AttrBuilder B;
230217
B.addAlignmentAttr(Bytes);
231-
#if LLVM_VERSION_GE(5, 0)
232218
Call.setAttributes(Call.getAttributes().addAttributes(
233219
Call->getContext(), Index, B));
234-
#else
235-
Call.setAttributes(Call.getAttributes().addAttributes(
236-
Call->getContext(), Index,
237-
AttributeSet::get(Call->getContext(), Index, B)));
238-
#endif
239220
}
240221

241222
extern "C" void LLVMRustAddDereferenceableCallSiteAttr(LLVMValueRef Instr,
@@ -244,14 +225,8 @@ extern "C" void LLVMRustAddDereferenceableCallSiteAttr(LLVMValueRef Instr,
244225
CallSite Call = CallSite(unwrap<Instruction>(Instr));
245226
AttrBuilder B;
246227
B.addDereferenceableAttr(Bytes);
247-
#if LLVM_VERSION_GE(5, 0)
248228
Call.setAttributes(Call.getAttributes().addAttributes(
249229
Call->getContext(), Index, B));
250-
#else
251-
Call.setAttributes(Call.getAttributes().addAttributes(
252-
Call->getContext(), Index,
253-
AttributeSet::get(Call->getContext(), Index, B)));
254-
#endif
255230
}
256231

257232
extern "C" void LLVMRustAddDereferenceableOrNullCallSiteAttr(LLVMValueRef Instr,
@@ -260,26 +235,16 @@ extern "C" void LLVMRustAddDereferenceableOrNullCallSiteAttr(LLVMValueRef Instr,
260235
CallSite Call = CallSite(unwrap<Instruction>(Instr));
261236
AttrBuilder B;
262237
B.addDereferenceableOrNullAttr(Bytes);
263-
#if LLVM_VERSION_GE(5, 0)
264238
Call.setAttributes(Call.getAttributes().addAttributes(
265239
Call->getContext(), Index, B));
266-
#else
267-
Call.setAttributes(Call.getAttributes().addAttributes(
268-
Call->getContext(), Index,
269-
AttributeSet::get(Call->getContext(), Index, B)));
270-
#endif
271240
}
272241

273242
extern "C" void LLVMRustAddFunctionAttribute(LLVMValueRef Fn, unsigned Index,
274243
LLVMRustAttribute RustAttr) {
275244
Function *A = unwrap<Function>(Fn);
276245
Attribute Attr = Attribute::get(A->getContext(), fromRust(RustAttr));
277246
AttrBuilder B(Attr);
278-
#if LLVM_VERSION_GE(5, 0)
279247
A->addAttributes(Index, B);
280-
#else
281-
A->addAttributes(Index, AttributeSet::get(A->getContext(), Index, B));
282-
#endif
283248
}
284249

285250
extern "C" void LLVMRustAddAlignmentAttr(LLVMValueRef Fn,
@@ -288,23 +253,15 @@ extern "C" void LLVMRustAddAlignmentAttr(LLVMValueRef Fn,
288253
Function *A = unwrap<Function>(Fn);
289254
AttrBuilder B;
290255
B.addAlignmentAttr(Bytes);
291-
#if LLVM_VERSION_GE(5, 0)
292256
A->addAttributes(Index, B);
293-
#else
294-
A->addAttributes(Index, AttributeSet::get(A->getContext(), Index, B));
295-
#endif
296257
}
297258

298259
extern "C" void LLVMRustAddDereferenceableAttr(LLVMValueRef Fn, unsigned Index,
299260
uint64_t Bytes) {
300261
Function *A = unwrap<Function>(Fn);
301262
AttrBuilder B;
302263
B.addDereferenceableAttr(Bytes);
303-
#if LLVM_VERSION_GE(5, 0)
304264
A->addAttributes(Index, B);
305-
#else
306-
A->addAttributes(Index, AttributeSet::get(A->getContext(), Index, B));
307-
#endif
308265
}
309266

310267
extern "C" void LLVMRustAddDereferenceableOrNullAttr(LLVMValueRef Fn,
@@ -313,11 +270,7 @@ extern "C" void LLVMRustAddDereferenceableOrNullAttr(LLVMValueRef Fn,
313270
Function *A = unwrap<Function>(Fn);
314271
AttrBuilder B;
315272
B.addDereferenceableOrNullAttr(Bytes);
316-
#if LLVM_VERSION_GE(5, 0)
317273
A->addAttributes(Index, B);
318-
#else
319-
A->addAttributes(Index, AttributeSet::get(A->getContext(), Index, B));
320-
#endif
321274
}
322275

323276
extern "C" void LLVMRustAddFunctionAttrStringValue(LLVMValueRef Fn,
@@ -327,11 +280,7 @@ extern "C" void LLVMRustAddFunctionAttrStringValue(LLVMValueRef Fn,
327280
Function *F = unwrap<Function>(Fn);
328281
AttrBuilder B;
329282
B.addAttribute(Name, Value);
330-
#if LLVM_VERSION_GE(5, 0)
331283
F->addAttributes(Index, B);
332-
#else
333-
F->addAttributes(Index, AttributeSet::get(F->getContext(), Index, B));
334-
#endif
335284
}
336285

337286
extern "C" void LLVMRustRemoveFunctionAttributes(LLVMValueRef Fn,
@@ -341,12 +290,7 @@ extern "C" void LLVMRustRemoveFunctionAttributes(LLVMValueRef Fn,
341290
Attribute Attr = Attribute::get(F->getContext(), fromRust(RustAttr));
342291
AttrBuilder B(Attr);
343292
auto PAL = F->getAttributes();
344-
#if LLVM_VERSION_GE(5, 0)
345293
auto PALNew = PAL.removeAttributes(F->getContext(), Index, B);
346-
#else
347-
const AttributeSet PALNew = PAL.removeAttributes(
348-
F->getContext(), Index, AttributeSet::get(F->getContext(), Index, B));
349-
#endif
350294
F->setAttributes(PALNew);
351295
}
352296

@@ -396,7 +340,6 @@ enum class LLVMRustSynchronizationScope {
396340
CrossThread,
397341
};
398342

399-
#if LLVM_VERSION_GE(5, 0)
400343
static SyncScope::ID fromRust(LLVMRustSynchronizationScope Scope) {
401344
switch (Scope) {
402345
case LLVMRustSynchronizationScope::SingleThread:
@@ -407,18 +350,6 @@ static SyncScope::ID fromRust(LLVMRustSynchronizationScope Scope) {
407350
report_fatal_error("bad SynchronizationScope.");
408351
}
409352
}
410-
#else
411-
static SynchronizationScope fromRust(LLVMRustSynchronizationScope Scope) {
412-
switch (Scope) {
413-
case LLVMRustSynchronizationScope::SingleThread:
414-
return SingleThread;
415-
case LLVMRustSynchronizationScope::CrossThread:
416-
return CrossThread;
417-
default:
418-
report_fatal_error("bad SynchronizationScope.");
419-
}
420-
}
421-
#endif
422353

423354
extern "C" LLVMValueRef
424355
LLVMRustBuildAtomicFence(LLVMBuilderRef B, LLVMAtomicOrdering Order,
@@ -463,18 +394,6 @@ extern "C" void LLVMRustAppendModuleInlineAsm(LLVMModuleRef M, const char *Asm)
463394

464395
typedef DIBuilder *LLVMRustDIBuilderRef;
465396

466-
#if LLVM_VERSION_LT(5, 0)
467-
typedef struct LLVMOpaqueMetadata *LLVMMetadataRef;
468-
469-
namespace llvm {
470-
DEFINE_ISA_CONVERSION_FUNCTIONS(Metadata, LLVMMetadataRef)
471-
472-
inline Metadata **unwrap(LLVMMetadataRef *Vals) {
473-
return reinterpret_cast<Metadata **>(Vals);
474-
}
475-
}
476-
#endif
477-
478397
template <typename DIT> DIT *unwrapDIPtr(LLVMMetadataRef Ref) {
479398
return (DIT *)(Ref ? unwrap<MDNode>(Ref) : nullptr);
480399
}
@@ -590,11 +509,6 @@ static DINode::DIFlags fromRust(LLVMRustDIFlags Flags) {
590509
if (isSet(Flags & LLVMRustDIFlags::FlagRValueReference)) {
591510
Result |= DINode::DIFlags::FlagRValueReference;
592511
}
593-
#if LLVM_VERSION_LE(4, 0)
594-
if (isSet(Flags & LLVMRustDIFlags::FlagExternalTypeRef)) {
595-
Result |= DINode::DIFlags::FlagExternalTypeRef;
596-
}
597-
#endif
598512
if (isSet(Flags & LLVMRustDIFlags::FlagIntroducedVirtual)) {
599513
Result |= DINode::DIFlags::FlagIntroducedVirtual;
600514
}
@@ -693,9 +607,7 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreatePointerType(
693607
uint64_t SizeInBits, uint32_t AlignInBits, const char *Name) {
694608
return wrap(Builder->createPointerType(unwrapDI<DIType>(PointeeTy),
695609
SizeInBits, AlignInBits,
696-
#if LLVM_VERSION_GE(5, 0)
697610
/* DWARFAddressSpace */ None,
698-
#endif
699611
Name));
700612
}
701613

@@ -902,12 +814,7 @@ LLVMRustDIBuilderCreateNameSpace(LLVMRustDIBuilderRef Builder,
902814
LLVMMetadataRef Scope, const char *Name,
903815
LLVMMetadataRef File, unsigned LineNo) {
904816
return wrap(Builder->createNameSpace(
905-
unwrapDI<DIDescriptor>(Scope), Name
906-
#if LLVM_VERSION_LT(5, 0)
907-
,
908-
unwrapDI<DIFile>(File), LineNo
909-
#endif
910-
,
817+
unwrapDI<DIDescriptor>(Scope), Name,
911818
false // ExportSymbols (only relevant for C++ anonymous namespaces)
912819
));
913820
}
@@ -937,12 +844,7 @@ extern "C" int64_t LLVMRustDIBuilderCreateOpDeref() {
937844
}
938845

939846
extern "C" int64_t LLVMRustDIBuilderCreateOpPlusUconst() {
940-
#if LLVM_VERSION_GE(5, 0)
941847
return dwarf::DW_OP_plus_uconst;
942-
#else
943-
// older LLVM used `plus` to behave like `plus_uconst`.
944-
return dwarf::DW_OP_plus;
945-
#endif
946848
}
947849

948850
extern "C" void LLVMRustWriteTypeToString(LLVMTypeRef Ty, RustStringRef Str) {
@@ -1014,21 +916,12 @@ extern "C" void LLVMRustUnpackOptimizationDiagnostic(
1014916
*FunctionOut = wrap(&Opt->getFunction());
1015917

1016918
RawRustStringOstream FilenameOS(FilenameOut);
1017-
#if LLVM_VERSION_GE(5,0)
1018919
DiagnosticLocation loc = Opt->getLocation();
1019920
if (loc.isValid()) {
1020921
*Line = loc.getLine();
1021922
*Column = loc.getColumn();
1022923
FilenameOS << loc.getFilename();
1023924
}
1024-
#else
1025-
const DebugLoc &loc = Opt->getDebugLoc();
1026-
if (loc) {
1027-
*Line = loc.getLine();
1028-
*Column = loc.getCol();
1029-
FilenameOS << cast<DIScope>(loc.getScope())->getFilename();
1030-
}
1031-
#endif
1032925

1033926
RawRustStringOstream MessageOS(MessageOut);
1034927
MessageOS << Opt->getMsg();
@@ -1451,7 +1344,6 @@ LLVMRustModuleCost(LLVMModuleRef M) {
14511344
}
14521345

14531346
// Vector reductions:
1454-
#if LLVM_VERSION_GE(5, 0)
14551347
extern "C" LLVMValueRef
14561348
LLVMRustBuildVectorReduceFAdd(LLVMBuilderRef B, LLVMValueRef Acc, LLVMValueRef Src) {
14571349
return wrap(unwrap(B)->CreateFAddReduce(unwrap(Acc),unwrap(Src)));
@@ -1497,54 +1389,6 @@ LLVMRustBuildVectorReduceFMax(LLVMBuilderRef B, LLVMValueRef Src, bool NoNaN) {
14971389
return wrap(unwrap(B)->CreateFPMaxReduce(unwrap(Src), NoNaN));
14981390
}
14991391

1500-
#else
1501-
1502-
extern "C" LLVMValueRef
1503-
LLVMRustBuildVectorReduceFAdd(LLVMBuilderRef, LLVMValueRef, LLVMValueRef) {
1504-
return nullptr;
1505-
}
1506-
extern "C" LLVMValueRef
1507-
LLVMRustBuildVectorReduceFMul(LLVMBuilderRef, LLVMValueRef, LLVMValueRef) {
1508-
return nullptr;
1509-
}
1510-
extern "C" LLVMValueRef
1511-
LLVMRustBuildVectorReduceAdd(LLVMBuilderRef, LLVMValueRef) {
1512-
return nullptr;
1513-
}
1514-
extern "C" LLVMValueRef
1515-
LLVMRustBuildVectorReduceMul(LLVMBuilderRef, LLVMValueRef) {
1516-
return nullptr;
1517-
}
1518-
extern "C" LLVMValueRef
1519-
LLVMRustBuildVectorReduceAnd(LLVMBuilderRef, LLVMValueRef) {
1520-
return nullptr;
1521-
}
1522-
extern "C" LLVMValueRef
1523-
LLVMRustBuildVectorReduceOr(LLVMBuilderRef, LLVMValueRef) {
1524-
return nullptr;
1525-
}
1526-
extern "C" LLVMValueRef
1527-
LLVMRustBuildVectorReduceXor(LLVMBuilderRef, LLVMValueRef) {
1528-
return nullptr;
1529-
}
1530-
extern "C" LLVMValueRef
1531-
LLVMRustBuildVectorReduceMin(LLVMBuilderRef, LLVMValueRef, bool) {
1532-
return nullptr;
1533-
}
1534-
extern "C" LLVMValueRef
1535-
LLVMRustBuildVectorReduceMax(LLVMBuilderRef, LLVMValueRef, bool) {
1536-
return nullptr;
1537-
}
1538-
extern "C" LLVMValueRef
1539-
LLVMRustBuildVectorReduceFMin(LLVMBuilderRef, LLVMValueRef, bool) {
1540-
return nullptr;
1541-
}
1542-
extern "C" LLVMValueRef
1543-
LLVMRustBuildVectorReduceFMax(LLVMBuilderRef, LLVMValueRef, bool) {
1544-
return nullptr;
1545-
}
1546-
#endif
1547-
15481392
#if LLVM_VERSION_GE(6, 0)
15491393
extern "C" LLVMValueRef
15501394
LLVMRustBuildMinNum(LLVMBuilderRef B, LLVMValueRef LHS, LLVMValueRef RHS) {

0 commit comments

Comments
 (0)
Please sign in to comment.