]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_codegen_llvm/src/type_.rs
Rollup merge of #105847 - compiler-errors:issue-104396, r=oli-obk
[rust.git] / compiler / rustc_codegen_llvm / src / type_.rs
index 5772b7e1d812afa3c2566ecb3fd31e042e078f80..ff111d96f840b1bc817ceb7bfbecf29aa1ee0e6d 100644 (file)
@@ -316,4 +316,19 @@ fn typeid_metadata(&self, typeid: String) -> &'ll Value {
             )
         }
     }
+
+    fn set_kcfi_type_metadata(&self, function: &'ll Value, kcfi_typeid: u32) {
+        let kcfi_type_metadata = self.const_u32(kcfi_typeid);
+        unsafe {
+            llvm::LLVMGlobalSetMetadata(
+                function,
+                llvm::MD_kcfi_type as c_uint,
+                llvm::LLVMMDNodeInContext2(
+                    self.llcx,
+                    &llvm::LLVMValueAsMetadata(kcfi_type_metadata),
+                    1,
+                ),
+            )
+        }
+    }
 }