[llvm] [AMDGPU] Fix source location for assembler warnings (PR #156621)
Jay Foad via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 3 01:48:56 PDT 2025
https://github.com/jayfoad created https://github.com/llvm/llvm-project/pull/156621
Call MCInst::setLoc earlier so it is available for warnings generated
during MatchInstructionImpl.
>From 4efe35c8af78c8b17a9674e70b6d22fc0a6028f6 Mon Sep 17 00:00:00 2001
From: Jay Foad <jay.foad at amd.com>
Date: Wed, 3 Sep 2025 09:46:28 +0100
Subject: [PATCH] [AMDGPU] Fix source location for assembler warnings
Call MCInst::setLoc earlier so it is available for warnings generated
during MatchInstructionImpl.
---
llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp | 2 +-
llvm/test/MC/AMDGPU/warnings.s | 5 +++++
2 files changed, 6 insertions(+), 1 deletion(-)
create mode 100644 llvm/test/MC/AMDGPU/warnings.s
diff --git a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
index 93083f2660c2d..68424cc2f7071 100644
--- a/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
+++ b/llvm/lib/Target/AMDGPU/AsmParser/AMDGPUAsmParser.cpp
@@ -5819,6 +5819,7 @@ bool AMDGPUAsmParser::matchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
uint64_t &ErrorInfo,
bool MatchingInlineAsm) {
MCInst Inst;
+ Inst.setLoc(IDLoc);
unsigned Result = Match_Success;
for (auto Variant : getMatchedVariants()) {
uint64_t EI;
@@ -5842,7 +5843,6 @@ bool AMDGPUAsmParser::matchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
if (!validateInstruction(Inst, IDLoc, Operands)) {
return true;
}
- Inst.setLoc(IDLoc);
Out.emitInstruction(Inst, getSTI());
return false;
}
diff --git a/llvm/test/MC/AMDGPU/warnings.s b/llvm/test/MC/AMDGPU/warnings.s
new file mode 100644
index 0000000000000..3f94d14a59ce6
--- /dev/null
+++ b/llvm/test/MC/AMDGPU/warnings.s
@@ -0,0 +1,5 @@
+// NOTE: Assertions have been autogenerated by utils/update_mc_test_checks.py UTC_ARGS: --version 5
+// RUN: llvm-mc -triple=amdgcn -mcpu=gfx900 -filetype=null %s 2>&1 | FileCheck %s
+
+v_floor_f64 v[0:1], 1.23456
+// CHECK: :[[@LINE-1]]:1: warning: Can't encode literal as exact 64-bit floating-point operand. Low 32-bits will be set to zero
More information about the llvm-commits
mailing list