mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-03-06 04:13:17 +01:00
Make sure functions containing inline asm are never inlined to avoid
duplicated labels.
This commit is contained in:
@@ -450,6 +450,9 @@ void AsmBlockStatement::toIR(IRState* p)
|
|||||||
LOG_SCOPE;
|
LOG_SCOPE;
|
||||||
Logger::println("BEGIN ASM");
|
Logger::println("BEGIN ASM");
|
||||||
|
|
||||||
|
// disable inlining
|
||||||
|
gIR->func()->setNeverInline();
|
||||||
|
|
||||||
// create asm block structure
|
// create asm block structure
|
||||||
assert(!p->asmBlock);
|
assert(!p->asmBlock);
|
||||||
IRAsmBlock* asmblock = new IRAsmBlock;
|
IRAsmBlock* asmblock = new IRAsmBlock;
|
||||||
|
|||||||
@@ -63,3 +63,17 @@ void IrFunction::popLabelScope()
|
|||||||
labelScopes.pop_back();
|
labelScopes.pop_back();
|
||||||
nextUnique.pop();
|
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);
|
||||||
|
}
|
||||||
|
|||||||
@@ -52,6 +52,10 @@ struct IrFunction : IrBase
|
|||||||
|
|
||||||
IrFunction(FuncDeclaration* fd);
|
IrFunction(FuncDeclaration* fd);
|
||||||
|
|
||||||
|
// annotations
|
||||||
|
void setNeverInline();
|
||||||
|
void setAlwaysInline();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// prefix for labels and gotos
|
// prefix for labels and gotos
|
||||||
// used for allowing labels to be emitted twice
|
// used for allowing labels to be emitted twice
|
||||||
|
|||||||
Reference in New Issue
Block a user