Emit all D inline asm labels as local labels.

On OS X, there is an actual significance to the distinction, which before lead e.g. to exception throwing in the below example being broken:

---
import core.exception;

void main() {
  asm {
    jmp Lfoo;
Lfoo:
    ;
  }
  throw cast(OutOfMemoryError)cast(void*)OutOfMemoryError.classinfo.init;
  assert(0);
}
---
This commit is contained in:
David Nadlinger
2011-12-04 18:13:33 +01:00
parent 1afc01df72
commit d0ea856024
7 changed files with 25 additions and 9 deletions
+11
View File
@@ -8,6 +8,9 @@
#include "template.h"
#include "module.h"
#include "llvm/MC/MCAsmInfo.h"
#include "llvm/Target/TargetMachine.h"
#include "gen/tollvm.h"
#include "gen/irstate.h"
#include "gen/runtime.h"
@@ -1851,3 +1854,11 @@ void callPostblit(Loc &loc, Expression *exp, LLValue *val)
}
}
#endif
//////////////////////////////////////////////////////////////////////////////////////////
void printLabelName(std::ostream& target, const char* func_mangle, const char* label_name)
{
target << gTargetMachine->getMCAsmInfo()->getPrivateGlobalPrefix() <<
func_mangle << "_" << label_name;
}