Rollup merge of #132216 - klensy:c_uint, r=cuviper

correct LLVMRustCreateThinLTOData arg types

`LLVMRustCreateThinLTOData` defined in rust as
```rust
    pub fn LLVMRustCreateThinLTOData(
        Modules: *const ThinLTOModule,
        NumModules: c_uint,
        PreservedSymbols: *const *const c_char,
        PreservedSymbolsLen: c_uint,
    ) -> Option<&'static mut ThinLTOData>;
```
but in cpp as
```cpp
extern "C" LLVMRustThinLTOData *
LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, int num_modules,
                          const char **preserved_symbols, int num_symbols) {
```

(note `c_unit` vs `int` types). Let it be actually `size_t`.

Also fixes return type of `LLVMRustDIBuilderCreateOpLLVMFragment` to uint64_t as other similar functions around, which should be correct, i assume.
This commit is contained in:
Jubilee 2024-10-29 03:11:42 -07:00 committed by GitHub
commit a70b90b822
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 9 deletions

View File

@ -503,9 +503,9 @@ fn thin_lto(
// upstream... // upstream...
let data = llvm::LLVMRustCreateThinLTOData( let data = llvm::LLVMRustCreateThinLTOData(
thin_modules.as_ptr(), thin_modules.as_ptr(),
thin_modules.len() as u32, thin_modules.len(),
symbols_below_threshold.as_ptr(), symbols_below_threshold.as_ptr(),
symbols_below_threshold.len() as u32, symbols_below_threshold.len(),
) )
.ok_or_else(|| write::llvm_err(dcx, LlvmError::PrepareThinLtoContext))?; .ok_or_else(|| write::llvm_err(dcx, LlvmError::PrepareThinLtoContext))?;

View File

@ -2385,9 +2385,9 @@ unsafe extern "C" {
pub fn LLVMRustThinLTOBufferThinLinkDataLen(M: &ThinLTOBuffer) -> size_t; pub fn LLVMRustThinLTOBufferThinLinkDataLen(M: &ThinLTOBuffer) -> size_t;
pub fn LLVMRustCreateThinLTOData( pub fn LLVMRustCreateThinLTOData(
Modules: *const ThinLTOModule, Modules: *const ThinLTOModule,
NumModules: c_uint, NumModules: size_t,
PreservedSymbols: *const *const c_char, PreservedSymbols: *const *const c_char,
PreservedSymbolsLen: c_uint, PreservedSymbolsLen: size_t,
) -> Option<&'static mut ThinLTOData>; ) -> Option<&'static mut ThinLTOData>;
pub fn LLVMRustPrepareThinLTORename( pub fn LLVMRustPrepareThinLTORename(
Data: &ThinLTOData, Data: &ThinLTOData,

View File

@ -1251,12 +1251,12 @@ getFirstDefinitionForLinker(const GlobalValueSummaryList &GVSummaryList) {
// here is basically the same as before threads are spawned in the `run` // here is basically the same as before threads are spawned in the `run`
// function of `lib/LTO/ThinLTOCodeGenerator.cpp`. // function of `lib/LTO/ThinLTOCodeGenerator.cpp`.
extern "C" LLVMRustThinLTOData * extern "C" LLVMRustThinLTOData *
LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, int num_modules, LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, size_t num_modules,
const char **preserved_symbols, int num_symbols) { const char **preserved_symbols, size_t num_symbols) {
auto Ret = std::make_unique<LLVMRustThinLTOData>(); auto Ret = std::make_unique<LLVMRustThinLTOData>();
// Load each module's summary and merge it into one combined index // Load each module's summary and merge it into one combined index
for (int i = 0; i < num_modules; i++) { for (size_t i = 0; i < num_modules; i++) {
auto module = &modules[i]; auto module = &modules[i];
auto buffer = StringRef(module->data, module->len); auto buffer = StringRef(module->data, module->len);
auto mem_buffer = MemoryBufferRef(buffer, module->identifier); auto mem_buffer = MemoryBufferRef(buffer, module->identifier);
@ -1275,7 +1275,7 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, int num_modules,
// Convert the preserved symbols set from string to GUID, this is then needed // Convert the preserved symbols set from string to GUID, this is then needed
// for internalization. // for internalization.
for (int i = 0; i < num_symbols; i++) { for (size_t i = 0; i < num_symbols; i++) {
auto GUID = GlobalValue::getGUID(preserved_symbols[i]); auto GUID = GlobalValue::getGUID(preserved_symbols[i]);
Ret->GUIDPreservedSymbols.insert(GUID); Ret->GUIDPreservedSymbols.insert(GUID);
} }

View File

@ -1231,7 +1231,7 @@ extern "C" uint64_t LLVMRustDIBuilderCreateOpPlusUconst() {
return dwarf::DW_OP_plus_uconst; return dwarf::DW_OP_plus_uconst;
} }
extern "C" int64_t LLVMRustDIBuilderCreateOpLLVMFragment() { extern "C" uint64_t LLVMRustDIBuilderCreateOpLLVMFragment() {
return dwarf::DW_OP_LLVM_fragment; return dwarf::DW_OP_LLVM_fragment;
} }