1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 19:23:23 +01:00

GlobalISel: support trivial inlineasm calls.

They're used for nefarious purposes by ObjC.

llvm-svn: 297422
This commit is contained in:
Tim Northover 2017-03-09 23:36:26 +00:00
parent ed6c98dcd2
commit c6c9bc0cd8
4 changed files with 33 additions and 3 deletions

View File

@ -143,6 +143,8 @@ private:
bool translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID,
MachineIRBuilder &MIRBuilder);
bool translateInlineAsm(const CallInst &CI, MachineIRBuilder &MIRBuilder);
/// Translate call instruction.
/// \pre \p U is a call instruction.
bool translateCall(const User &U, MachineIRBuilder &MIRBuilder);

View File

@ -715,13 +715,32 @@ bool IRTranslator::translateKnownIntrinsic(const CallInst &CI, Intrinsic::ID ID,
return false;
}
bool IRTranslator::translateInlineAsm(const CallInst &CI,
MachineIRBuilder &MIRBuilder) {
const InlineAsm &IA = cast<InlineAsm>(*CI.getCalledValue());
if (!IA.getConstraintString().empty())
return false;
unsigned ExtraInfo = 0;
if (IA.hasSideEffects())
ExtraInfo |= InlineAsm::Extra_HasSideEffects;
if (IA.getDialect() == InlineAsm::AD_Intel)
ExtraInfo |= InlineAsm::Extra_AsmDialect;
MIRBuilder.buildInstr(TargetOpcode::INLINEASM)
.addExternalSymbol(IA.getAsmString().c_str())
.addImm(ExtraInfo);
return true;
}
bool IRTranslator::translateCall(const User &U, MachineIRBuilder &MIRBuilder) {
const CallInst &CI = cast<CallInst>(U);
auto TII = MF->getTarget().getIntrinsicInfo();
const Function *F = CI.getCalledFunction();
if (CI.isInlineAsm())
return false;
return translateInlineAsm(CI, MIRBuilder);
if (!F || !F->isIntrinsic()) {
unsigned Res = CI.getType()->isVoidTy() ? 0 : getOrCreateVReg(CI);

View File

@ -1262,3 +1262,12 @@ define double @test_fneg_f64(double %x) {
%neg = fsub double -0.000000e+00, %x
ret double %neg
}
define void @test_trivial_inlineasm() {
; CHECK-LABEL: name: test_trivial_inlineasm
; CHECK: INLINEASM $wibble, 1
; CHECK: INLINEASM $wibble, 0
call void asm sideeffect "wibble", ""()
call void asm "wibble", ""()
ret void
}

View File

@ -2,9 +2,9 @@
; CHECK-LABEL: test_asm:
; CHECK: {{APP|InlineAsm Start}}
; CHECK: mov x0, x0
; CHECK: mov x0, {{x[0-9]+}}
; CHECK: {{NO_APP|InlineAsm End}}
define void @test_asm() {
call void asm sideeffect "mov x0, x0", ""()
call void asm sideeffect "mov x0, $0", "r"(i64 42)
ret void
}