diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2024-09-05 18:58:53 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-05 18:58:53 +0200 |
| commit | b89ee99d573ef1493933214e76d5a1e199f5d64c (patch) | |
| tree | b830c9b22107a47b41a6d536a76a0918dc61e4d7 /compiler/rustc_codegen_llvm/src | |
| parent | eb33b43bab08223fa6b46abacc1e95e859fe375d (diff) | |
| parent | 27f92b6c10ecb0385f22409430b64d13c02dd7a4 (diff) | |
| download | rust-b89ee99d573ef1493933214e76d5a1e199f5d64c.tar.gz rust-b89ee99d573ef1493933214e76d5a1e199f5d64c.zip | |
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
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/consts.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/llvm/ffi.rs | 1 |
2 files changed, 2 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_llvm/src/consts.rs b/compiler/rustc_codegen_llvm/src/consts.rs index b143e28c5f9..d60122fccee 100644 --- a/compiler/rustc_codegen_llvm/src/consts.rs +++ b/compiler/rustc_codegen_llvm/src/consts.rs @@ -390,7 +390,7 @@ impl<'ll> CodegenCx<'ll, '_> { 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 diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs index 138cc3219aa..3bf4d496408 100644 --- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs +++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs @@ -974,6 +974,7 @@ unsafe extern "C" { 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>; |
