In ARM mode, passing -mtp=cp15 forces the use of an inline MRC system register read to move the thread pointer value into a register.
Currently, in Thumb2 mode, -mtp=cp15 is ignored, and a call to the __aeabi_read_tp helper is emitted instead.
This is inconsistent, and breaks the Linux/ARM build for Thumb2 targets, as the Linux kernel does not provide an implementation of __aeabi_read_tp,.
Let's make this a test under llvm/test/CodeGen/, using IR:
; RUN: llc --mtriple=armv7-linux-gnueabihf -o - %s | FileCheck %s ; RUN: llc --mtriple=thumbv7-linux-gnu -o - %s | FileCheck %s define dso_local i8* @tphard() "target-features"="+read-tp-hard" { // CHECK-NOT: __aeabi_read_tp %1 = tail call i8* @llvm.thread.pointer() ret i8* %1 } declare i8* @llvm.thread.pointer()