[llvm-dev] How to insert and MPX bounds check (InLineAsm) without memory fence?

Scott A Carr via llvm-dev llvm-dev at lists.llvm.org
Thu Apr 21 13:18:15 PDT 2016


Inside my ModulePass I would like to insert an MPX bounds check instruction.  As far as I know, this is not yet supported by LLVM (please tell me if I am mistaken).

I’m creating my bounds check instruction with InLineAsm::get().  My question has to do with the hasSideEffects argument of that function.

I’m not that familiar with instruction selection and the backends, but from looking around I think hasSideEffects=True causes a memory fence.

The bounds check instruction doesn’t modify any registers or memory so I would like to try to avoid this.  However, when I changed it to hasSideEffects=false one of my bounds check instructions was removed.  I verified this by inspecting the resulting binary with both hasSideEffects=false and hasSideEffect=true. 

How can I insert an InLineAsm that definitely won’t be removed and does not cause a memory fence?  Or is there a better way?  Alternate suggestions or ideas for creating the MPX bounds checks are also welcome.

Thank you,
Scott A Carr
PhD Candidate
Purdue University

More information about the llvm-dev mailing list