Skip to content

Commit a34948a

Browse files
committed
rustllvm: Initialize target analysis passes
Without this the target info for certain optimizations will not be created and the compiler will sometimes crash
1 parent 344628f commit a34948a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/rustllvm/RustWrapper.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,8 @@ LLVMRustWriteOutputFile(LLVMPassManagerRef PMR,
452452
Options.NoFramePointerElim = true;
453453
Options.EnableSegmentedStacks = EnableSegmentedStacks;
454454

455+
PassManager *PM = unwrap<PassManager>(PMR);
456+
455457
std::string Err;
456458
std::string Trip(Triple::normalize(triple));
457459
std::string FeaturesStr;
@@ -461,8 +463,9 @@ LLVMRustWriteOutputFile(LLVMPassManagerRef PMR,
461463
TheTarget->createTargetMachine(Trip, CPUStr, FeaturesStr,
462464
Options, Reloc::PIC_,
463465
CodeModel::Default, OptLevel);
466+
Target->addAnalysisPasses(*PM);
467+
464468
bool NoVerify = false;
465-
PassManager *PM = unwrap<PassManager>(PMR);
466469
std::string ErrorInfo;
467470
raw_fd_ostream OS(path, ErrorInfo,
468471
raw_fd_ostream::F_Binary);

0 commit comments

Comments
 (0)