Skip to content

Commit 576b7a7

Browse files
authored
[SPARC] Remove assertions in printOperand for inline asm operands (llvm#104692)
Inline asm operands could contain any kind of relocation, so remove the checks. Fixes llvm#103493
1 parent cfc76b6 commit 576b7a7

File tree

2 files changed

+10
-51
lines changed

2 files changed

+10
-51
lines changed

llvm/lib/Target/Sparc/SparcAsmPrinter.cpp

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -319,57 +319,6 @@ void SparcAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
319319
const MachineOperand &MO = MI->getOperand (opNum);
320320
SparcMCExpr::VariantKind TF = (SparcMCExpr::VariantKind) MO.getTargetFlags();
321321

322-
#ifndef NDEBUG
323-
// Verify the target flags.
324-
if (MO.isGlobal() || MO.isSymbol() || MO.isCPI()) {
325-
if (MI->getOpcode() == SP::CALL)
326-
assert(TF == SparcMCExpr::VK_Sparc_None &&
327-
"Cannot handle target flags on call address");
328-
else if (MI->getOpcode() == SP::SETHIi)
329-
assert((TF == SparcMCExpr::VK_Sparc_HI
330-
|| TF == SparcMCExpr::VK_Sparc_H44
331-
|| TF == SparcMCExpr::VK_Sparc_HH
332-
|| TF == SparcMCExpr::VK_Sparc_LM
333-
|| TF == SparcMCExpr::VK_Sparc_TLS_GD_HI22
334-
|| TF == SparcMCExpr::VK_Sparc_TLS_LDM_HI22
335-
|| TF == SparcMCExpr::VK_Sparc_TLS_LDO_HIX22
336-
|| TF == SparcMCExpr::VK_Sparc_TLS_IE_HI22
337-
|| TF == SparcMCExpr::VK_Sparc_TLS_LE_HIX22) &&
338-
"Invalid target flags for address operand on sethi");
339-
else if (MI->getOpcode() == SP::TLS_CALL)
340-
assert((TF == SparcMCExpr::VK_Sparc_None
341-
|| TF == SparcMCExpr::VK_Sparc_TLS_GD_CALL
342-
|| TF == SparcMCExpr::VK_Sparc_TLS_LDM_CALL) &&
343-
"Cannot handle target flags on tls call address");
344-
else if (MI->getOpcode() == SP::TLS_ADDrr)
345-
assert((TF == SparcMCExpr::VK_Sparc_TLS_GD_ADD
346-
|| TF == SparcMCExpr::VK_Sparc_TLS_LDM_ADD
347-
|| TF == SparcMCExpr::VK_Sparc_TLS_LDO_ADD
348-
|| TF == SparcMCExpr::VK_Sparc_TLS_IE_ADD) &&
349-
"Cannot handle target flags on add for TLS");
350-
else if (MI->getOpcode() == SP::TLS_LDrr)
351-
assert(TF == SparcMCExpr::VK_Sparc_TLS_IE_LD &&
352-
"Cannot handle target flags on ld for TLS");
353-
else if (MI->getOpcode() == SP::TLS_LDXrr)
354-
assert(TF == SparcMCExpr::VK_Sparc_TLS_IE_LDX &&
355-
"Cannot handle target flags on ldx for TLS");
356-
else if (MI->getOpcode() == SP::XORri)
357-
assert((TF == SparcMCExpr::VK_Sparc_TLS_LDO_LOX10
358-
|| TF == SparcMCExpr::VK_Sparc_TLS_LE_LOX10) &&
359-
"Cannot handle target flags on xor for TLS");
360-
else
361-
assert((TF == SparcMCExpr::VK_Sparc_LO
362-
|| TF == SparcMCExpr::VK_Sparc_M44
363-
|| TF == SparcMCExpr::VK_Sparc_L44
364-
|| TF == SparcMCExpr::VK_Sparc_HM
365-
|| TF == SparcMCExpr::VK_Sparc_TLS_GD_LO10
366-
|| TF == SparcMCExpr::VK_Sparc_TLS_LDM_LO10
367-
|| TF == SparcMCExpr::VK_Sparc_TLS_IE_LO10 ) &&
368-
"Invalid target flags for small address operand");
369-
}
370-
#endif
371-
372-
373322
bool CloseParen = SparcMCExpr::printVariantKind(O, TF);
374323

375324
switch (MO.getType()) {

llvm/test/CodeGen/SPARC/inlineasm.ll

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,3 +152,13 @@ define i64 @test_twinword(){
152152
%1 = tail call i64 asm sideeffect "rd %asr5, ${0:L} \0A\09 srlx ${0:L}, 32, ${0:H}", "={i0}"()
153153
ret i64 %1
154154
}
155+
156+
; CHECK-LABEL: test_symbol:
157+
; CHECK: ba,a brtarget
158+
define void @test_symbol() {
159+
Entry:
160+
call void asm sideeffect "ba,a ${0}", "X"(ptr @brtarget)
161+
unreachable
162+
}
163+
164+
declare void @brtarget()

0 commit comments

Comments
 (0)