This is an archive of the discontinued LLVM Phabricator instance.

MS inline ASM: mark the function noinline if the asm has labels (PR23715)
ClosedPublic

Authored by hans on Dec 9 2015, 4:22 PM.

Details

Summary

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.)

Diff Detail

Repository
rL LLVM

Event Timeline

hans updated this revision to Diff 42353.Dec 9 2015, 4:22 PM
hans retitled this revision from to MS inline ASM: mark the function noinline if the asm has labels (PR23715).
hans updated this object.
hans added a reviewer: rnk.
hans added a subscriber: cfe-commits.
rnk accepted this revision.Dec 9 2015, 5:10 PM
rnk edited edge metadata.

Looks terrible, please commit.

lib/CodeGen/CGStmt.cpp
2005 ↗(On Diff #42353)

If this inline asm has labels, we should also add the noduplicate attribute to the callsite. That will prevent CFG transforms like tail duplication from duplicating it.

This revision is now accepted and ready to land.Dec 9 2015, 5:10 PM
majnemer added inline comments.
lib/CodeGen/CGStmt.cpp
2005 ↗(On Diff #42353)

Actually, isn't noduplicate sufficient? I'm having trouble seeing where noinline inhibits problematic transforms over noduplicate.

rsmith added a subscriber: rsmith.Dec 9 2015, 5:28 PM
rsmith added inline comments.
test/CodeGen/ms-inline-asm.c
536 ↗(On Diff #42353)

Why is this not a CHECK-LABEL any more?

hans added inline comments.Dec 9 2015, 5:40 PM
lib/CodeGen/CGStmt.cpp
2005 ↗(On Diff #42353)

You're right. I'll just do that.

test/CodeGen/ms-inline-asm.c
536 ↗(On Diff #42353)

FileCheck got upset:
error: found 'CHECK-LABEL:' with variable definition or use

This revision was automatically updated to reflect the committed changes.