Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion compiler/rustc_codegen_llvm/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -860,9 +860,10 @@ unsafe fn create_call<'a>(tgt: &'a Value, src: &'a Value, rev_mode: bool,
LLVMRustEraseInstBefore(bb, last_inst);

let f_return_type = LLVMGetReturnType(LLVMGlobalGetValueType(src));
let f_is_struct = llvm::LLVMRustIsStructType(f_return_type);
let void_type = LLVMVoidTypeInContext(llcx);
// Now unwrap the struct_ret if it's actually a struct
if f_return_type != void_type {
if f_is_struct {
let num_elem_in_ret_struct = LLVMCountStructElementTypes(f_return_type);
if num_elem_in_ret_struct == 1 {
let inner_grad_name = "foo".to_string();
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,7 @@ extern "C" {
pub fn LLVMRustEraseInstFromParent(V: &Value);
pub fn LLVMRustGetTerminator<'a>(B: &BasicBlock) -> &'a Value;
pub fn LLVMGetReturnType(T: &Type) -> &Type;
pub fn LLVMRustIsStructType(T: &Type) -> bool;
pub fn LLVMDumpModule(M: &Module);
pub fn LLVMCountStructElementTypes(T: &Type) -> c_uint;
pub fn LLVMDeleteFunction(V: &Value);
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,10 @@ extern "C" void LLVMRustAddFunctionAttributes(LLVMValueRef Fn, unsigned Index,
AddAttributes(F, Index, Attrs, AttrsLen);
}

extern "C" bool LLVMRustIsStructType(LLVMTypeRef Ty) {
return unwrap(Ty)->isStructTy();
}

extern "C" void LLVMRustAddCallSiteAttributes(LLVMValueRef Instr,
unsigned Index,
LLVMAttributeRef *Attrs,
Expand Down