[LLVMdev] Use SEGMENT_REG in X86 calling convention

Tim Northover t.p.northover at gmail.com
Sat Feb 22 00:04:52 PST 2014


Hi Chen,

> Does anyone have any idea on how to fix it or the correct way to use the
> segment register?

At the moment LLVM only uses segment registers passively, where the
actual value in the register isn't changed by LLVM (for example
thread-local storage access is via %fs on Linux, but that value is set
by the OS when the thread is created and we don't need to worry about
it).

Because of that, we don't have infrastructure in place for actually
shuffling values around them and you should probably expect to have to
add bits yourself as you go along.

You've discovered copyPhysReg (you'll have to implement a copy
yourself, probably with push/pop like EFLAGS since there's no direct
seg/seg move instruction). You'll probably eventually need to be able
to spill & restore them too, if lots of moves are going on (the
storeRegToStackSlot and loadRegFromStackSlot functions).

Depending on what you're trying to do that may be everything, or you
may meet even more worlds of pain later on.

Good luck!

Tim.



More information about the llvm-dev mailing list