[PATCH] D15399: MS inline ASM: mark the function noinline if the asm has labels (PR23715)
Hans Wennborg via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 9 16:22:11 PST 2015
hans created this revision.
hans added a reviewer: rnk.
hans added a subscriber: cfe-commits.
This avoids defining the same label twice if the function gets inlined.
It's pretty hacky, but also very non-intrusive. (I also played with adding a flag on the MSAsmStmt and set that in ParseMicrosoftAsmStatement, but all that churn doesn't really buy us much.)
http://reviews.llvm.org/D15399
Files:
lib/CodeGen/CGStmt.cpp
test/CodeGen/ms-inline-asm.c
Index: test/CodeGen/ms-inline-asm.c
===================================================================
--- test/CodeGen/ms-inline-asm.c
+++ test/CodeGen/ms-inline-asm.c
@@ -533,7 +533,7 @@
label:
jmp label
}
- // CHECK-LABEL: define void @label1
+ // CHECK: define void @label1() [[ATTR1:#[0-9]+]] {
// CHECK: call void asm sideeffect inteldialect "{{.*}}__MSASMLABEL_.1__label:\0A\09jmp {{.*}}__MSASMLABEL_.1__label", "~{dirflag},~{fpsr},~{flags}"()
}
@@ -581,3 +581,6 @@
}
// CHECK-LABEL: define i32 @test_indirect_field(
// CHECK: call i32 asm sideeffect inteldialect "mov eax, dword ptr $1",
+
+// Functions with inline asm containing labels should be noinline (PR23715)
+// CHECK: attributes [[ATTR1]] = { {{.*}}noinline{{.*}} }
Index: lib/CodeGen/CGStmt.cpp
===================================================================
--- lib/CodeGen/CGStmt.cpp
+++ lib/CodeGen/CGStmt.cpp
@@ -1884,6 +1884,12 @@
ResultRegDests, AsmString, S.getNumOutputs());
SawAsmBlock = true;
}
+
+ // If the assembly contains any labels, mark the function noinline. Inlining
+ // it could cause the callee to contain the same ASM label twice (PR23715).
+ // This is pretty hacky, but it works.
+ if (AsmString.find("__MSASMLABEL_") != std::string::npos)
+ CurFn->addFnAttr(llvm::Attribute::NoInline);
}
for (unsigned i = 0, e = S.getNumInputs(); i != e; i++) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D15399.42353.patch
Type: text/x-patch
Size: 1418 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151210/c39b8640/attachment.bin>
More information about the cfe-commits
mailing list