changeset 584:c7d7e2282ba3

Make sure functions containing inline asm are never inlined to avoid duplicated labels.
author Christian Kamm <kamm incasoftware de>
date Mon, 08 Sep 2008 20:38:55 +0200
parents 12bda38ea366
children fbb1a366cfbc
files gen/asmstmt.cpp ir/irfunction.cpp ir/irfunction.h
diffstat 3 files changed, 21 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/gen/asmstmt.cpp	Sun Sep 07 17:44:25 2008 -0700
+++ b/gen/asmstmt.cpp	Mon Sep 08 20:38:55 2008 +0200
@@ -450,6 +450,9 @@
     LOG_SCOPE;
     Logger::println("BEGIN ASM");
 
+    // disable inlining
+    gIR->func()->setNeverInline();
+
     // create asm block structure
     assert(!p->asmBlock);
     IRAsmBlock* asmblock = new IRAsmBlock;
--- a/ir/irfunction.cpp	Sun Sep 07 17:44:25 2008 -0700
+++ b/ir/irfunction.cpp	Mon Sep 08 20:38:55 2008 +0200
@@ -63,3 +63,17 @@
     labelScopes.pop_back();
     nextUnique.pop();
 }
+
+void IrFunction::setNeverInline()
+{
+    llvm::FunctionNotes cur = func->getNotes();
+    assert(!(cur & llvm::FN_NOTE_AlwaysInline) && "function can't be never- and always-inline at the same time");
+    func->setNotes(cur | llvm::FN_NOTE_NoInline);
+}
+
+void IrFunction::setAlwaysInline()
+{
+    llvm::FunctionNotes cur = func->getNotes();
+    assert(!(cur & llvm::FN_NOTE_NoInline) && "function can't be never- and always-inline at the same time");
+    func->setNotes(cur | llvm::FN_NOTE_AlwaysInline);
+}
--- a/ir/irfunction.h	Sun Sep 07 17:44:25 2008 -0700
+++ b/ir/irfunction.h	Mon Sep 08 20:38:55 2008 +0200
@@ -52,6 +52,10 @@
 
     IrFunction(FuncDeclaration* fd);
 
+    // annotations
+    void setNeverInline();
+    void setAlwaysInline();
+
 private:
     // prefix for labels and gotos
     // used for allowing labels to be emitted twice