Skip to content

Commit 4227942

Browse files
authored
Unrolled build for rust-lang#128820
Rollup merge of rust-lang#128820 - LYF1999:yf/dev, r=nikic fix: get llvm type of global val using `LLVMTypeOf` on a global var always return ptr. so create a new function to access the value type of a global
2 parents eb33b43 + 27f92b6 commit 4227942

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

compiler/rustc_codegen_llvm/src/consts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ impl<'ll> CodegenCx<'ll, '_> {
390390
let val_llty = self.val_ty(v);
391391

392392
let g = self.get_static_inner(def_id, val_llty);
393-
let llty = self.val_ty(g);
393+
let llty = llvm::LLVMGlobalGetValueType(g);
394394

395395
let g = if val_llty == llty {
396396
g

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+1
Original file line numberDiff line numberDiff line change
@@ -974,6 +974,7 @@ unsafe extern "C" {
974974
pub fn LLVMGetAlignment(Global: &Value) -> c_uint;
975975
pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
976976
pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
977+
pub fn LLVMGlobalGetValueType(Global: &Value) -> &Type;
977978

978979
// Operations on global variables
979980
pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;

0 commit comments

Comments
 (0)