From 9d3d80ccad494d31c8b290fc9e78860282f454b4 Mon Sep 17 00:00:00 2001 From: Joerg Sonnenberger Date: Tue, 23 Apr 2019 15:15:33 +0000 Subject: [PATCH] [SPARC] Use the correct register set for the "r" asm constraint. 64bit mode must use 64bit registers, otherwise assumptions about the top half of the registers are made. Problem found by Takeshi Nakayama in NetBSD. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@358998 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/Sparc/SparcISelLowering.cpp | 2 ++ test/CodeGen/SPARC/reg64.ll | 10 ++++++++++ 2 files changed, 12 insertions(+) create mode 100644 test/CodeGen/SPARC/reg64.ll diff --git a/lib/Target/Sparc/SparcISelLowering.cpp b/lib/Target/Sparc/SparcISelLowering.cpp index 05c6cce19d3..a6d440fa8aa 100644 --- a/lib/Target/Sparc/SparcISelLowering.cpp +++ b/lib/Target/Sparc/SparcISelLowering.cpp @@ -3258,6 +3258,8 @@ SparcTargetLowering::getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, case 'r': if (VT == MVT::v2i32) return std::make_pair(0U, &SP::IntPairRegClass); + else if (Subtarget->is64Bit()) + return std::make_pair(0U, &SP::I64RegsRegClass); else return std::make_pair(0U, &SP::IntRegsRegClass); case 'f': diff --git a/test/CodeGen/SPARC/reg64.ll b/test/CodeGen/SPARC/reg64.ll new file mode 100644 index 00000000000..74f4d46568f --- /dev/null +++ b/test/CodeGen/SPARC/reg64.ll @@ -0,0 +1,10 @@ +; RUN: llc < %s -march=sparcv9 | FileCheck %s + +define dso_local zeroext i32 @f() local_unnamed_addr { +entry: + %0 = tail call i64 asm "", "=r"() + %shr = lshr i64 %0, 32 + %conv = trunc i64 %shr to i32 + ret i32 %conv +} +; CHECK: srlx -- 2.50.1