mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-15 04:29:42 +00:00
Don't rely on 'l'(ell) modifiers to indicate a label reference
Summary: It's not necessary to use an 'l'(ell) modifier when referencing a label. Treat block addresses and MBB references as if the modifier is used anyway. This prevents us from generating references to ficticious labels. Reviewers: jyknight, nickdesaulniers, hfinkel Subscribers: hiraditya, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D71849
This commit is contained in:
parent
d8fd92eaaa
commit
83d690a149
@ -456,26 +456,23 @@ static void EmitGCCInlineAsmStr(const char *AsmStr, const MachineInstr *MI,
|
||||
|
||||
// FIXME: Shouldn't arch-independent output template handling go into
|
||||
// PrintAsmOperand?
|
||||
if (Modifier[0] == 'l') { // Labels are target independent.
|
||||
if (MI->getOperand(OpNo).isBlockAddress()) {
|
||||
const BlockAddress *BA = MI->getOperand(OpNo).getBlockAddress();
|
||||
MCSymbol *Sym = AP->GetBlockAddressSymbol(BA);
|
||||
Sym->print(OS, AP->MAI);
|
||||
MMI->getContext().registerInlineAsmLabel(Sym);
|
||||
} else if (MI->getOperand(OpNo).isMBB()) {
|
||||
const MCSymbol *Sym = MI->getOperand(OpNo).getMBB()->getSymbol();
|
||||
Sym->print(OS, AP->MAI);
|
||||
} else {
|
||||
Error = true;
|
||||
}
|
||||
// Labels are target independent.
|
||||
if (MI->getOperand(OpNo).isBlockAddress()) {
|
||||
const BlockAddress *BA = MI->getOperand(OpNo).getBlockAddress();
|
||||
MCSymbol *Sym = AP->GetBlockAddressSymbol(BA);
|
||||
Sym->print(OS, AP->MAI);
|
||||
MMI->getContext().registerInlineAsmLabel(Sym);
|
||||
} else if (MI->getOperand(OpNo).isMBB()) {
|
||||
const MCSymbol *Sym = MI->getOperand(OpNo).getMBB()->getSymbol();
|
||||
Sym->print(OS, AP->MAI);
|
||||
} else if (Modifier[0] == 'l') {
|
||||
Error = true;
|
||||
} else if (InlineAsm::isMemKind(OpFlags)) {
|
||||
Error = AP->PrintAsmMemoryOperand(
|
||||
MI, OpNo, Modifier[0] ? Modifier : nullptr, OS);
|
||||
} else {
|
||||
if (InlineAsm::isMemKind(OpFlags)) {
|
||||
Error = AP->PrintAsmMemoryOperand(
|
||||
MI, OpNo, Modifier[0] ? Modifier : nullptr, OS);
|
||||
} else {
|
||||
Error = AP->PrintAsmOperand(MI, OpNo,
|
||||
Modifier[0] ? Modifier : nullptr, OS);
|
||||
}
|
||||
Error = AP->PrintAsmOperand(MI, OpNo,
|
||||
Modifier[0] ? Modifier : nullptr, OS);
|
||||
}
|
||||
}
|
||||
if (Error) {
|
||||
|
@ -53,7 +53,6 @@ fail:
|
||||
ret i32 1
|
||||
}
|
||||
|
||||
|
||||
; Test 3 - asm-goto implements a loop. The loop gets recognized, but many loop
|
||||
; transforms fail due to canonicalization having callbr exceptions. Trivial
|
||||
; blocks at labels 1 and 3 also don't get simplified due to callbr.
|
||||
@ -131,3 +130,32 @@ normal1: ; preds = %normal0
|
||||
%1 = load i32, i32* %a.addr, align 4
|
||||
ret i32 %1
|
||||
}
|
||||
|
||||
; Test 4 - asm-goto referenced with the 'l' (ell) modifier and not.
|
||||
define void @test4() {
|
||||
; CHECK-LABEL: test4:
|
||||
; CHECK: # %bb.0:
|
||||
; CHECK-NEXT: #APP
|
||||
; CHECK-NOT: ja .Ltmp50
|
||||
; CHECK-NEXT: ja .Ltmp5
|
||||
; CHECK-NEXT: #NO_APP
|
||||
; CHECK-NEXT: .LBB3_1:
|
||||
; CHECK-NEXT: #APP
|
||||
; CHECK-NOT: ja .Ltmp50
|
||||
; CHECK-NEXT: ja .Ltmp5
|
||||
; CHECK-NEXT: #NO_APP
|
||||
; CHECK-NEXT: jmp .LBB3_3
|
||||
entry:
|
||||
callbr void asm sideeffect "ja $0", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@test4, %quux))
|
||||
to label %asm.fallthrough [label %quux]
|
||||
|
||||
asm.fallthrough: ; preds = %entry
|
||||
callbr void asm sideeffect "ja ${0:l}", "X,~{dirflag},~{fpsr},~{flags}"(i8* blockaddress(@test4, %quux))
|
||||
to label %cleanup [label %quux]
|
||||
|
||||
quux: ; preds = %asm.fallthrough, %entry
|
||||
br label %cleanup
|
||||
|
||||
cleanup: ; preds = %asm.fallthrough, %quux
|
||||
ret void
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user