# HG changeset patch # User Christian Kamm # Date 1220899135 -7200 # Node ID c7d7e2282ba3e6bf1f6778c09f0b73ba10394b58 # Parent 12bda38ea3662e08feb18d3f524c5a193c0c4459 Make sure functions containing inline asm are never inlined to avoid duplicated labels. diff -r 12bda38ea366 -r c7d7e2282ba3 gen/asmstmt.cpp --- 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; diff -r 12bda38ea366 -r c7d7e2282ba3 ir/irfunction.cpp --- 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); +} diff -r 12bda38ea366 -r c7d7e2282ba3 ir/irfunction.h --- 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