Skip to content

Commit

Permalink
add missing global metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
TimNN committed Mar 16, 2017
1 parent 222ca3c commit 95bd7f2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/rustllvm/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// except according to those terms.

#include "rustllvm.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DiagnosticInfo.h"
#include "llvm/IR/DiagnosticPrinter.h"
#include "llvm/IR/Instructions.h"
Expand Down Expand Up @@ -594,7 +595,7 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateStaticVariable(
const char *LinkageName, LLVMRustMetadataRef File, unsigned LineNo,
LLVMRustMetadataRef Ty, bool IsLocalToUnit, LLVMValueRef V,
LLVMRustMetadataRef Decl = nullptr, uint32_t AlignInBits = 0) {
Constant *InitVal = cast<Constant>(unwrap(V));
llvm::GlobalVariable *InitVal = cast<llvm::GlobalVariable>(unwrap(V));

#if LLVM_VERSION_GE(4, 0)
llvm::DIExpression *InitExpr = nullptr;
Expand All @@ -607,10 +608,14 @@ extern "C" LLVMRustMetadataRef LLVMRustDIBuilderCreateStaticVariable(
FPVal->getValueAPF().bitcastToAPInt().getZExtValue());
}

return wrap(Builder->createGlobalVariableExpression(
llvm::DIGlobalVariableExpression *VarExpr = Builder->createGlobalVariableExpression(
unwrapDI<DIDescriptor>(Context), Name, LinkageName,
unwrapDI<DIFile>(File), LineNo, unwrapDI<DIType>(Ty), IsLocalToUnit,
InitExpr, unwrapDIPtr<MDNode>(Decl), AlignInBits));
InitExpr, unwrapDIPtr<MDNode>(Decl), AlignInBits);

InitVal->setMetadata("dbg", VarExpr);

return wrap(VarExpr);
#else
return wrap(Builder->createGlobalVariable(
unwrapDI<DIDescriptor>(Context), Name, LinkageName,
Expand Down

0 comments on commit 95bd7f2

Please sign in to comment.