Skip to content

Commit 0db0405

Browse files
committed
Revert "[GlobalISel] Diagnose inline assembly constraint lowering errors (#135782)"
This reverts commit c22081c.
1 parent c7b2d98 commit 0db0405

File tree

6 files changed

+37
-75
lines changed

6 files changed

+37
-75
lines changed

llvm/lib/CodeGen/GlobalISel/InlineAsmLowering.cpp

Lines changed: 33 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "llvm/CodeGen/MachineOperand.h"
1717
#include "llvm/CodeGen/MachineRegisterInfo.h"
1818
#include "llvm/CodeGen/TargetLowering.h"
19-
#include "llvm/IR/DiagnosticInfo.h"
2019
#include "llvm/IR/Module.h"
2120

2221
#define DEBUG_TYPE "inline-asm-lowering"
@@ -232,15 +231,6 @@ bool InlineAsmLowering::lowerInlineAsm(
232231
TargetLowering::AsmOperandInfoVector TargetConstraints =
233232
TLI->ParseConstraints(DL, TRI, Call);
234233

235-
const auto ConstraintError = [&](const GISelAsmOperandInfo &Info, Twine Msg) {
236-
LLVMContext &Ctx = MIRBuilder.getContext();
237-
Ctx.diagnose(DiagnosticInfoInlineAsm(
238-
Call, "invalid constraint '" + Info.ConstraintCode + "': " + Msg));
239-
// TODO: Recover if fallback isn't used. Otherwise let the fallback to DAG
240-
// kick in.
241-
return false;
242-
};
243-
244234
ExtraFlags ExtraInfo(Call);
245235
unsigned ArgNo = 0; // ArgNo - The argument of the CallInst.
246236
unsigned ResNo = 0; // ResNo - The result number of the next output.
@@ -253,8 +243,8 @@ bool InlineAsmLowering::lowerInlineAsm(
253243
OpInfo.CallOperandVal = const_cast<Value *>(Call.getArgOperand(ArgNo));
254244

255245
if (isa<BasicBlock>(OpInfo.CallOperandVal)) {
256-
return ConstraintError(OpInfo,
257-
"basic block input operands not supported yet");
246+
LLVM_DEBUG(dbgs() << "Basic block input operands not supported yet\n");
247+
return false;
258248
}
259249

260250
Type *OpTy = OpInfo.CallOperandVal->getType();
@@ -268,8 +258,9 @@ bool InlineAsmLowering::lowerInlineAsm(
268258

269259
// FIXME: Support aggregate input operands
270260
if (!OpTy->isSingleValueType()) {
271-
return ConstraintError(OpInfo,
272-
"aggregate input operands not supported yet");
261+
LLVM_DEBUG(
262+
dbgs() << "Aggregate input operands are not supported yet\n");
263+
return false;
273264
}
274265

275266
OpInfo.ConstraintVT =
@@ -353,8 +344,9 @@ bool InlineAsmLowering::lowerInlineAsm(
353344

354345
// Find a register that we can use.
355346
if (OpInfo.Regs.empty()) {
356-
return ConstraintError(
357-
OpInfo, "could not allocate output register for constraint");
347+
LLVM_DEBUG(dbgs()
348+
<< "Couldn't allocate output register for constraint\n");
349+
return false;
358350
}
359351

360352
// Add information to the INLINEASM instruction to know that this
@@ -397,13 +389,13 @@ bool InlineAsmLowering::lowerInlineAsm(
397389

398390
const InlineAsm::Flag MatchedOperandFlag(Inst->getOperand(InstFlagIdx).getImm());
399391
if (MatchedOperandFlag.isMemKind()) {
400-
return ConstraintError(
401-
OpInfo,
402-
"matching input constraint to mem operand not supported; this "
403-
"should be target specific");
392+
LLVM_DEBUG(dbgs() << "Matching input constraint to mem operand not "
393+
"supported. This should be target specific.\n");
394+
return false;
404395
}
405396
if (!MatchedOperandFlag.isRegDefKind() && !MatchedOperandFlag.isRegDefEarlyClobberKind()) {
406-
return ConstraintError(OpInfo, "unknown matching constraint");
397+
LLVM_DEBUG(dbgs() << "Unknown matching constraint\n");
398+
return false;
407399
}
408400

409401
// We want to tie input to register in next operand.
@@ -433,10 +425,9 @@ bool InlineAsmLowering::lowerInlineAsm(
433425

434426
if (OpInfo.ConstraintType == TargetLowering::C_Other &&
435427
OpInfo.isIndirect) {
436-
return ConstraintError(
437-
OpInfo,
438-
"indirect input operands with unknown constraint not supported "
439-
"yet");
428+
LLVM_DEBUG(dbgs() << "Indirect input operands with unknown constraint "
429+
"not supported yet\n");
430+
return false;
440431
}
441432

442433
if (OpInfo.ConstraintType == TargetLowering::C_Immediate ||
@@ -446,7 +437,9 @@ bool InlineAsmLowering::lowerInlineAsm(
446437
if (!lowerAsmOperandForConstraint(OpInfo.CallOperandVal,
447438
OpInfo.ConstraintCode, Ops,
448439
MIRBuilder)) {
449-
return ConstraintError(OpInfo, "unsupported constraint");
440+
LLVM_DEBUG(dbgs() << "Don't support constraint: "
441+
<< OpInfo.ConstraintCode << " yet\n");
442+
return false;
450443
}
451444

452445
assert(Ops.size() > 0 &&
@@ -463,8 +456,9 @@ bool InlineAsmLowering::lowerInlineAsm(
463456
if (OpInfo.ConstraintType == TargetLowering::C_Memory) {
464457

465458
if (!OpInfo.isIndirect) {
466-
return ConstraintError(
467-
OpInfo, "indirect memory input operands are not supported yet");
459+
LLVM_DEBUG(dbgs()
460+
<< "Cannot indirectify memory input operands yet\n");
461+
return false;
468462
}
469463

470464
assert(OpInfo.isIndirect && "Operand must be indirect to be a mem!");
@@ -488,15 +482,18 @@ bool InlineAsmLowering::lowerInlineAsm(
488482
"Unknown constraint type!");
489483

490484
if (OpInfo.isIndirect) {
491-
return ConstraintError(
492-
OpInfo, "indirect register inputs are not supported yet");
485+
LLVM_DEBUG(dbgs() << "Can't handle indirect register inputs yet "
486+
"for constraint '"
487+
<< OpInfo.ConstraintCode << "'\n");
488+
return false;
493489
}
494490

495491
// Copy the input into the appropriate registers.
496492
if (OpInfo.Regs.empty()) {
497-
return ConstraintError(
498-
OpInfo,
499-
"could not allocate input register for register constraint");
493+
LLVM_DEBUG(
494+
dbgs()
495+
<< "Couldn't allocate input register for register constraint\n");
496+
return false;
500497
}
501498

502499
unsigned NumRegs = OpInfo.Regs.size();
@@ -506,10 +503,9 @@ bool InlineAsmLowering::lowerInlineAsm(
506503
"source registers");
507504

508505
if (NumRegs > 1) {
509-
return ConstraintError(
510-
OpInfo,
511-
"input operands with multiple input registers are not supported "
512-
"yet");
506+
LLVM_DEBUG(dbgs() << "Input operands with multiple input registers are "
507+
"not supported yet\n");
508+
return false;
513509
}
514510

515511
InlineAsm::Flag Flag(InlineAsm::Kind::RegUse, NumRegs);

llvm/test/CodeGen/AArch64/GlobalISel/arm64-fallback.ll

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,13 @@
1-
; RUN: not llc -O0 -global-isel -global-isel-abort=2 -pass-remarks-missed='gisel*' -verify-machineinstrs %s -o - > %t.out 2> %t.err
1+
; RUN: llc -O0 -global-isel -global-isel-abort=2 -pass-remarks-missed='gisel*' -verify-machineinstrs %s -o %t.out 2> %t.err
22
; RUN: FileCheck %s --check-prefix=FALLBACK-WITH-REPORT-OUT < %t.out
33
; RUN: FileCheck %s --check-prefix=FALLBACK-WITH-REPORT-ERR < %t.err
44
; RUN: not --crash llc -global-isel -mtriple aarch64_be %s -o - 2>&1 | FileCheck %s --check-prefix=BIG-ENDIAN
5-
65
; This file checks that the fallback path to selection dag works.
76
; The test is fragile in the sense that it must be updated to expose
87
; something that fails with global-isel.
98
; When we cannot produce a test case anymore, that means we can remove
109
; the fallback path.
1110

12-
; -o - > %t.out is used instead of -o %t.out because llc does not write the output
13-
; file if an error is emitted, but it will still print to stdout.
14-
1511
target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
1612
target triple = "aarch64--"
1713

llvm/test/CodeGen/AArch64/arm64-preserve-all.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ define preserve_allcc void @preserve_all() {
4343
define dso_local void @normal_cc_caller() {
4444
entry:
4545
%v = alloca i32, align 4
46-
call void asm sideeffect "mov x9, $0", "n,~{x9}"(i32 48879) #2
46+
call void asm sideeffect "mov x9, $0", "N,~{x9}"(i32 48879) #2
4747
call void asm sideeffect "movi v9.2d, #0","~{v9}" () #2
4848

4949

llvm/test/CodeGen/AArch64/arm64-preserve-most.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ define preserve_mostcc void @preserve_most() {
2929
define dso_local void @normal_cc_caller() {
3030
entry:
3131
%v = alloca i32, align 4
32-
call void asm sideeffect "mov x9, $0", "n,~{x9}"(i32 48879) #2
32+
call void asm sideeffect "mov x9, $0", "N,~{x9}"(i32 48879) #2
3333
call preserve_mostcc void @preserve_most()
3434
%0 = load i32, ptr %v, align 4
3535
%1 = call i32 asm sideeffect "mov ${0:w}, w9", "=r,r"(i32 %0) #2

llvm/test/CodeGen/AMDGPU/GlobalISel/inline-asm-lowering-errors.ll

Lines changed: 0 additions & 30 deletions
This file was deleted.

llvm/test/CodeGen/AMDGPU/GlobalISel/inline-asm-mismatched-size.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
; NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py
2-
; RUN: not llc -global-isel -global-isel-abort=2 -pass-remarks-missed='gisel*' -mtriple=amdgcn -mcpu=fiji -stop-after=irtranslator -verify-machineinstrs %s -o - 2>%t | FileCheck %s
2+
; RUN: llc -global-isel -global-isel-abort=2 -pass-remarks-missed='gisel*' -mtriple=amdgcn -mcpu=fiji -stop-after=irtranslator -verify-machineinstrs %s -o - 2>%t | FileCheck %s
33
; RUN: FileCheck -check-prefix=ERR %s < %t
44

55
; ERR: remark: <unknown>:0:0: unable to translate instruction: call: ' %sgpr = call <4 x i32> asm sideeffect "; def $0", "={s[8:12]}"()' (in function: return_type_is_too_big_vector)

0 commit comments

Comments
 (0)