Skip to content

Commit

Permalink
Merge pull request llvm#65 from Amanieu/asm-srcloc-fastisel2
Browse files Browse the repository at this point in the history
Fix FastISel dropping srcloc metadata from InlineAsm
  • Loading branch information
nikic authored Jun 13, 2020
2 parents 02e0d7f + 428d9f3 commit 0ddefec
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
15 changes: 11 additions & 4 deletions llvm/lib/CodeGen/SelectionDAG/FastISel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1322,12 +1322,19 @@ bool FastISel::selectCall(const User *I) {
ExtraInfo |= InlineAsm::Extra_HasSideEffects;
if (IA->isAlignStack())
ExtraInfo |= InlineAsm::Extra_IsAlignStack;
if (Call->isConvergent())
ExtraInfo |= InlineAsm::Extra_IsConvergent;
ExtraInfo |= IA->getDialect() * InlineAsm::Extra_AsmDialect;

BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(TargetOpcode::INLINEASM))
.addExternalSymbol(IA->getAsmString().c_str())
.addImm(ExtraInfo);
MachineInstrBuilder MIB = BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
TII.get(TargetOpcode::INLINEASM));
MIB.addExternalSymbol(IA->getAsmString().c_str());
MIB.addImm(ExtraInfo);

const MDNode *SrcLoc = Call->getMetadata("srcloc");
if (SrcLoc)
MIB.addMetadata(SrcLoc);

return true;
}

Expand Down
21 changes: 21 additions & 0 deletions llvm/test/CodeGen/AArch64/asm-srcloc.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
; RUN: llc -O0 -stop-after=finalize-isel -o - %s | FileCheck %s

target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64"

; CHECK-LABEL: name: foo
; CHECK: INLINEASM {{.*}}, !0
define void @foo() {
call void asm sideeffect "nowayisthisavalidinstruction", "r"(i32 0), !srcloc !0
ret void
}

; CHECK-LABEL: name: bar
; CHECK: INLINEASM {{.*}}, !1
define void @bar() {
call void asm sideeffect "nowayisthisavalidinstruction", ""(), !srcloc !1
ret void
}

!0 = !{i32 23}
!1 = !{i32 91}

0 comments on commit 0ddefec

Please sign in to comment.