Skip to content

Commit 837a706

Browse files
authored
[AMDGPU] Fix source location for assembler warnings (#156621)
Call MCInst::setLoc earlier so it is available for warnings generated during MatchInstructionImpl.
1 parent e4c0b3e commit 837a706

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5832,6 +5832,7 @@ bool AMDGPUAsmParser::matchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
58325832
uint64_t &ErrorInfo,
58335833
bool MatchingInlineAsm) {
58345834
MCInst Inst;
5835+
Inst.setLoc(IDLoc);
58355836
unsigned Result = Match_Success;
58365837
for (auto Variant : getMatchedVariants()) {
58375838
uint64_t EI;
@@ -5855,7 +5856,6 @@ bool AMDGPUAsmParser::matchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
58555856
if (!validateInstruction(Inst, IDLoc, Operands)) {
58565857
return true;
58575858
}
5858-
Inst.setLoc(IDLoc);
58595859
Out.emitInstruction(Inst, getSTI());
58605860
return false;
58615861
}

llvm/test/MC/AMDGPU/warnings.s

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// NOTE: Assertions have been autogenerated by utils/update_mc_test_checks.py UTC_ARGS: --version 5
2+
// RUN: llvm-mc -triple=amdgcn -mcpu=gfx900 -filetype=null %s 2>&1 | FileCheck %s
3+
4+
v_floor_f64 v[0:1], 1.23456
5+
// CHECK: :[[@LINE-1]]:1: warning: Can't encode literal as exact 64-bit floating-point operand. Low 32-bits will be set to zero

0 commit comments

Comments
 (0)