From 6c1b0752997a8bf0c3109bcf4101eff24d97c9ce Mon Sep 17 00:00:00 2001 From: Thomas Preud'homme Date: Mon, 30 Jul 2018 16:45:40 +0000 Subject: [PATCH] Fix uninitialized read in ARM's PrintAsmOperand Summary: Fix read of uninitialized RC variable in ARM's PrintAsmOperand when hasRegClassConstraint returns false. This was causing inline-asm-operand-implicit-cast test to fail in r338206. Reviewers: t.p.northover, weimingz, javed.absar, chill Reviewed By: chill Subscribers: chill, eraman, kristof.beyls, chrib, llvm-commits Differential Revision: https://reviews.llvm.org/D49984 llvm-svn: 338268 --- llvm/lib/Target/ARM/ARMAsmPrinter.cpp | 5 +++-- llvm/test/CodeGen/ARM/inlineasm-64bit.ll | 8 ++++++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp index 2196f9b..19d483e 100644 --- a/llvm/lib/Target/ARM/ARMAsmPrinter.cpp +++ b/llvm/lib/Target/ARM/ARMAsmPrinter.cpp @@ -367,8 +367,9 @@ bool ARMAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNum, unsigned NumVals = InlineAsm::getNumOperandRegisters(Flags); unsigned RC; - InlineAsm::hasRegClassConstraint(Flags, RC); - if (RC == ARM::GPRPairRegClassID) { + const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo(); + if (InlineAsm::hasRegClassConstraint(Flags, RC) && + ARM::GPRPairRegClass.hasSubClassEq(TRI->getRegClass(RC))) { if (NumVals != 1) return true; const MachineOperand &MO = MI->getOperand(OpNum); diff --git a/llvm/test/CodeGen/ARM/inlineasm-64bit.ll b/llvm/test/CodeGen/ARM/inlineasm-64bit.ll index 8e747c5..62c71ab 100644 --- a/llvm/test/CodeGen/ARM/inlineasm-64bit.ll +++ b/llvm/test/CodeGen/ARM/inlineasm-64bit.ll @@ -104,3 +104,11 @@ define i64 @tied_64bit_lookback_test(i64 %in) nounwind { %res = extractvalue {i64, i32, i64} %vars, 2 ret i64 %res } + +; Check access to low and high part with a specific register pair constraint +define i64 @low_high_specific_reg_pair(i64 %in) nounwind { +; CHECK-LABEL: low_high_specific_reg_pair +; CHECK: mov r3, r2 + %res = call i64 asm "mov ${0:R}, ${1:Q}", "=&{r2},0"(i64 %in) + ret i64 %res +} -- 2.7.4