Beginner question: extending pointer to 128 bits segfaults

Hi all,

I’ve been trying to extend pointer size of the X86 target to 128 bits. For the prortype, I would like nothing more than the pointers being i128 type with the same value as before. All I’ve done was changing the data layout string to p:128:128 and when trying to run a basic program such as:

int a = 42;
int *p = &a;

it segfaults with the following stack trace:

#0 0x00000000013eff7a llvm::sys::PrintStackTrace(llvm::raw_ostream&)
#1 0x00000000013ee20e llvm::sys::RunSignalHandlers() /afs/
#2 0x00000000013ee34a SignalHandler(int) /afs/
#3 0x00007fad6b434370 __restore_rt (/lib64/
#4 0x0000000001ba1734 llvm::DAGTypeLegalizer::PromoteIntOp_ATOMIC_STORE(llvm::AtomicSDNode*)
Stack dump:
0. Program arguments: /afs/ -cc1 -triple x86_64-unknown-linux-gnu -emit-obj
-mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name simple.c -mrelocation-model static -mthread-model posix
-mdisable-fp-elim -fmath-errno -masm-verbose -mconstructor-aliases -munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info
-debugger-tuning=gdb -resource-dir /afs/ -internal-isystem /usr/local/include
-internal-isystem /afs/ -internal-externc-isystem /include
-internal-externc-isystem /usr/include -fdebug-compilation-dir /afs/ -ferror-limit 19 -fmessage-length
159 -fobjc-runtime=gcc -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/simple-2837aa.o -x c …/copy/simple.c

  1. parser at end of file
  2. Code generation
  3. Running pass ‘Function Pass Manager’ on module ‘…/copy/simple.c’.
  4. Running pass ‘X86 DAG->DAG Instruction Selection’ on function ‘@main
    clang-6.0: error: unable to execute command: Segmentation fault
    clang-6.0: error: clang frontend command failed due to signal (use -v to see invocation)

Now I know almost nothing about LLVM, but I assumed that since X86 target has SSE extensions, it wouldn’t have a problem with a 128-bit value type in general. I would really appreciate any explanations and pointers you can give me. Sorry for such a general question.

Best wishes,

While its true that X86 has 128-bit registers for SSE. There are no instructions for doing 128-bit arithmetic on them. So for example, you can’t add two 128 bit registers and get a 128 bit result. Because of this i128 isn’t considered a legal type by the X86 backend. It doesn’t have a register class assigned to it via a call to addRegisterClass in X86ISelLowering.cpp.

It’s also not possible in the X86 backend today to use an XMM register in the address calculations for a load or store.

I think in general the pointer type also needs to be listed as a valid integer type in the data layout string too.

But I’m not sure why you got the particular seg fault you go.