diff --git a/gen/asmstmt.cpp b/gen/asmstmt.cpp index c62a1d2a..e9ce04c3 100644 --- a/gen/asmstmt.cpp +++ b/gen/asmstmt.cpp @@ -450,6 +450,9 @@ void AsmBlockStatement::toIR(IRState* p) LOG_SCOPE; Logger::println("BEGIN ASM"); + // disable inlining + gIR->func()->setNeverInline(); + // create asm block structure assert(!p->asmBlock); IRAsmBlock* asmblock = new IRAsmBlock; diff --git a/ir/irfunction.cpp b/ir/irfunction.cpp index aeeb048d..dbb96ba9 100644 --- a/ir/irfunction.cpp +++ b/ir/irfunction.cpp @@ -63,3 +63,17 @@ void IrFunction::popLabelScope() 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 --git a/ir/irfunction.h b/ir/irfunction.h index a08d7f22..7f569163 100644 --- a/ir/irfunction.h +++ b/ir/irfunction.h @@ -52,6 +52,10 @@ struct IrFunction : IrBase IrFunction(FuncDeclaration* fd); + // annotations + void setNeverInline(); + void setAlwaysInline(); + private: // prefix for labels and gotos // used for allowing labels to be emitted twice