How to use the Speculative Load Hardening pass?

I’m trying to run Speculative Load Hardening pass in LLVM. I try the command “opt --x86-slh program.ll”, but it doesn’t work, it causes a segmentation fault.

Stack dump:
0. Program arguments: opt --x86-slh program.ll
#0 0x0000560fd5a7e33a llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/usr/local/bin/opt+0x27e133a)
#1 0x0000560fd5a7be34 llvm::sys::RunSignalHandlers() (/usr/local/bin/opt+0x27dee34)
#2 0x0000560fd5a7bf83 SignalHandler(int) (/usr/local/bin/opt+0x27def83)
#3 0x00007f44afab1890 __restore_rt (/lib/x86_64-linux-gnu/
#4 0x0000560fd4f8dab7 llvm::MachineModuleInfo::MachineModuleInfo(llvm::LLVMTargetMachine const*) (/usr/local/bin/opt+0x1cf0ab7)
#5 0x0000560fd4f8e916 llvm::MachineModuleInfoWrapperPass::MachineModuleInfoWrapperPass(llvm::LLVMTargetMachine const*) (/usr/local/bin/opt+0x1cf1916)
#6 0x0000560fd4f8e948 llvm::Pass* llvm::callDefaultCtorllvm::MachineModuleInfoWrapperPass() (/usr/local/bin/opt+0x1cf1948)
#7 0x0000560fd534317d llvm::PMTopLevelManager::schedulePass(llvm::Pass*) (/usr/local/bin/opt+0x20a617d)
#8 0x0000560fd3a68e90 main (/usr/local/bin/opt+0x7cbe90)
#9 0x00007f44aeb8cb97 __libc_start_main /build/glibc-OTsEL5/glibc-2.27/csu/…/csu/libc-start.c:344:0
#10 0x0000560fd3b0549a _start (/usr/local/bin/opt+0x86849a)
Segmentation fault (`core’ generated)

Is this the correct way to execute the pass? How can I fix the error?

I cannot help you but you should ask on the llvm mailing list, this discourse is (apparently) for MLIR only. The list can be found here and emails are send to

I bet someone there can help you.


Speculative load hardening is a pass on Machine IR. opt is for passes that work transform LLVM IR. You should be able to run it with llc -x86-speculative-load-hardening progam.ll

Thank you so much. It have work me.

Can you tell me where did you find that flag for llc? Before post my question, I looked for in LLVM Documentation, but I didn’t find anything.

You can find it in the output of

llc -help-hidden
1 Like