Skip to content

Commit 4bb02c6

Browse files
committed
[ARM] Introduce -mtp=auto and make it the default
This adds a new value auto to the possible values of the existing -mtp= clang option which controls how the thread pointer is found. auto means the same as soft if the target architecture doesn't support a hardware thread pointer at all; otherwise it means the same as cp15. This behavior is the default in gcc version 7.3.0 and later. The new auto option is therefore also the default in clang, so this change aligns clang with gcc.
1 parent a955426 commit 4bb02c6

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

clang/lib/Driver/ToolChains/Arch/ARM.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ arm::ReadTPMode arm::getReadTPMode(const Driver &D, const ArgList &Args,
239239
D.Diag(diag::err_drv_invalid_mtp) << A->getAsString(Args);
240240
return ReadTPMode::Invalid;
241241
}
242-
return ReadTPMode::Soft;
242+
return (isHardTPSupported(Triple) ? ReadTPMode::TPIDRURO : ReadTPMode::Soft);
243243
}
244244

245245
void arm::setArchNameInTriple(const Driver &D, const ArgList &Args,
@@ -574,12 +574,12 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D,
574574
A->ignoreTargetSpecific();
575575
}
576576

577-
if (getReadTPMode(D, Args, Triple, ForAS) == ReadTPMode::TPIDRURW)
577+
arm::ReadTPMode TPMode = getReadTPMode(D, Args, Triple, ForAS);
578+
579+
if (TPMode == ReadTPMode::TPIDRURW)
578580
Features.push_back("+read-tp-tpidrurw");
579-
if (getReadTPMode(D, Args, Triple, ForAS) == ReadTPMode::TPIDRURO)
581+
else if (TPMode == ReadTPMode::TPIDRURO)
580582
Features.push_back("+read-tp-tpidruro");
581-
if (getReadTPMode(D, Args, Triple, ForAS) == ReadTPMode::TPIDRPRW)
582-
Features.push_back("+read-tp-tpidrprw");
583583

584584
const Arg *ArchArg = Args.getLastArg(options::OPT_march_EQ);
585585
const Arg *CPUArg = Args.getLastArg(options::OPT_mcpu_EQ);

clang/test/Driver/arm-thread-pointer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@
4242

4343
// RUN: %clang --target=armv7-linux -### -S %s 2>&1 | \
4444
// RUN: FileCheck -check-prefix=ARMv7_THREAD_POINTER_NON %s
45-
// ARMv7_THREAD_POINTER_NON-NOT: "-target-feature" "+read-tp-tpidruro"
45+
// ARMv7_THREAD_POINTER_NON: "-target-feature" "+read-tp-tpidruro"

0 commit comments

Comments
 (0)