Skip to content

Commit 0ddefec

Browse files
authored
Merge pull request llvm#65 from Amanieu/asm-srcloc-fastisel2
Fix FastISel dropping srcloc metadata from InlineAsm
2 parents 02e0d7f + 428d9f3 commit 0ddefec

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

llvm/lib/CodeGen/SelectionDAG/FastISel.cpp

+11-4
Original file line numberDiff line numberDiff line change
@@ -1322,12 +1322,19 @@ bool FastISel::selectCall(const User *I) {
13221322
ExtraInfo |= InlineAsm::Extra_HasSideEffects;
13231323
if (IA->isAlignStack())
13241324
ExtraInfo |= InlineAsm::Extra_IsAlignStack;
1325+
if (Call->isConvergent())
1326+
ExtraInfo |= InlineAsm::Extra_IsConvergent;
13251327
ExtraInfo |= IA->getDialect() * InlineAsm::Extra_AsmDialect;
13261328

1327-
BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1328-
TII.get(TargetOpcode::INLINEASM))
1329-
.addExternalSymbol(IA->getAsmString().c_str())
1330-
.addImm(ExtraInfo);
1329+
MachineInstrBuilder MIB = BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, DbgLoc,
1330+
TII.get(TargetOpcode::INLINEASM));
1331+
MIB.addExternalSymbol(IA->getAsmString().c_str());
1332+
MIB.addImm(ExtraInfo);
1333+
1334+
const MDNode *SrcLoc = Call->getMetadata("srcloc");
1335+
if (SrcLoc)
1336+
MIB.addMetadata(SrcLoc);
1337+
13311338
return true;
13321339
}
13331340

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
; RUN: llc -O0 -stop-after=finalize-isel -o - %s | FileCheck %s
2+
3+
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
4+
target triple = "aarch64"
5+
6+
; CHECK-LABEL: name: foo
7+
; CHECK: INLINEASM {{.*}}, !0
8+
define void @foo() {
9+
call void asm sideeffect "nowayisthisavalidinstruction", "r"(i32 0), !srcloc !0
10+
ret void
11+
}
12+
13+
; CHECK-LABEL: name: bar
14+
; CHECK: INLINEASM {{.*}}, !1
15+
define void @bar() {
16+
call void asm sideeffect "nowayisthisavalidinstruction", ""(), !srcloc !1
17+
ret void
18+
}
19+
20+
!0 = !{i32 23}
21+
!1 = !{i32 91}

0 commit comments

Comments
 (0)