Rollup merge of #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
This commit is contained in:
Matthias Krüger 2024-09-05 18:58:53 +02:00 committed by GitHub
commit b89ee99d57
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 2 additions and 1 deletions

View File

@ -390,7 +390,7 @@ fn codegen_static_item(&self, def_id: DefId) {
let val_llty = self.val_ty(v);
let g = self.get_static_inner(def_id, val_llty);
let llty = self.val_ty(g);
let llty = llvm::LLVMGlobalGetValueType(g);
let g = if val_llty == llty {
g

View File

@ -974,6 +974,7 @@ pub fn LLVMConstInBoundsGEP2<'a>(
pub fn LLVMGetAlignment(Global: &Value) -> c_uint;
pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
pub fn LLVMGlobalGetValueType(Global: &Value) -> &Type;
// Operations on global variables
pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;