Wrong MachineOperand accessor


I’m working on a sanitizer-like project and my modified module is getting past the verifier but crashing in CodeGen. I’m hoping someone can give me a hint towards the problem.

Specifically the assertion that is failing is:

llvm/CodeGen/MachineOperand.h:411: int64_t llvm::MachineOperand::getImm() const: Assertion `isImm() && “Wrong MachineOperand accessor”’ failed.

My pass is an IPO transformation. I haven’t modified anything in CodeGen.

I reduced the crash-causing module as much as possible. It is here: https://gist.github.com/scottcarr/72cf5cc3396e8a7156bc

If I compile this module with the command:

clang -c mk_sched_worker_free.ll

The command completes without error. If I compile with optimizations like:

clang -c -O3 mk_sched_worker_free.ll

Then I trip the assertion and the compilation aborts.

I’m using a pretty new LLVM (3.9) but not the very latest commit. If anyone could give me a hint as to what is wrong with this module or tell me if this seems like a bug in CodeGen that’d be a big help.

Thank you,
Scott A Carr
PhD Candidate
Purdue University