Merge pull request #5406 from kumpera/fix_12157
[mono.git] / mono / mini / mini-llvm-cpp.cpp
index 425eea95ed81854b1d84e0637c7a0929dc3dbbc7..8ac2da6b60711132f7873655aa30e318bc9a18d9 100644 (file)
 
 using namespace llvm;
 
+#if LLVM_API_VERSION > 100
+// These are c++11 scoped enums in recent llvm versions
+#define Acquire AtomicOrdering::Acquire
+#define Release AtomicOrdering::Release
+#define SequentiallyConsistent AtomicOrdering::SequentiallyConsistent
+#endif
+
 void
 mono_llvm_dump_value (LLVMValueRef value)
 {
@@ -229,6 +236,14 @@ mono_llvm_set_call_preserveall_cc (LLVMValueRef func)
        unwrap<CallInst>(func)->setCallingConv (CallingConv::PreserveAll);
 }
 
+void
+mono_llvm_set_call_notail (LLVMValueRef func)
+{
+#if LLVM_API_VERSION > 100
+       unwrap<CallInst>(func)->setTailCallKind (CallInst::TailCallKind::TCK_NoTail);
+#endif
+}
+
 #if LLVM_API_VERSION > 100
 
 void*
@@ -246,16 +261,21 @@ mono_llvm_di_create_compile_unit (void *di_builder, const char *cu_name, const c
 }
 
 void*
-mono_llvm_di_create_function (void *di_builder, void *cu, const char *name, const char *mangled_name, const char *dir, const char *file, int line)
+mono_llvm_di_create_function (void *di_builder, void *cu, LLVMValueRef func, const char *name, const char *mangled_name, const char *dir, const char *file, int line)
 {
        DIBuilder *builder = (DIBuilder*)di_builder;
        DIFile *di_file;
        DISubroutineType *type;
+       DISubprogram *di_func;
 
        // FIXME: Share DIFile
        di_file = builder->createFile (file, dir);
        type = builder->createSubroutineType (builder->getOrCreateTypeArray (ArrayRef<Metadata*> ()));
-       return builder->createFunction (di_file, name, mangled_name, di_file, line, type, true, true, 0);
+       di_func = builder->createFunction (di_file, name, mangled_name, di_file, line, type, true, true, 0);
+
+       unwrap<Function>(func)->setMetadata ("dbg", di_func);
+
+       return di_func;
 }
 
 void*