Skip to content

Commit a70b90b

Browse files
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.
2 parents b8f08fe + 2b326e3 commit a70b90b

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

compiler/rustc_codegen_llvm/src/back/lto.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -503,9 +503,9 @@ fn thin_lto(
503503
// upstream...
504504
let data = llvm::LLVMRustCreateThinLTOData(
505505
thin_modules.as_ptr(),
506-
thin_modules.len() as u32,
506+
thin_modules.len(),
507507
symbols_below_threshold.as_ptr(),
508-
symbols_below_threshold.len() as u32,
508+
symbols_below_threshold.len(),
509509
)
510510
.ok_or_else(|| write::llvm_err(dcx, LlvmError::PrepareThinLtoContext))?;
511511

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2385,9 +2385,9 @@ unsafe extern "C" {
23852385
pub fn LLVMRustThinLTOBufferThinLinkDataLen(M: &ThinLTOBuffer) -> size_t;
23862386
pub fn LLVMRustCreateThinLTOData(
23872387
Modules: *const ThinLTOModule,
2388-
NumModules: c_uint,
2388+
NumModules: size_t,
23892389
PreservedSymbols: *const *const c_char,
2390-
PreservedSymbolsLen: c_uint,
2390+
PreservedSymbolsLen: size_t,
23912391
) -> Option<&'static mut ThinLTOData>;
23922392
pub fn LLVMRustPrepareThinLTORename(
23932393
Data: &ThinLTOData,

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -1251,12 +1251,12 @@ getFirstDefinitionForLinker(const GlobalValueSummaryList &GVSummaryList) {
12511251
// here is basically the same as before threads are spawned in the `run`
12521252
// function of `lib/LTO/ThinLTOCodeGenerator.cpp`.
12531253
extern "C" LLVMRustThinLTOData *
1254-
LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, int num_modules,
1255-
const char **preserved_symbols, int num_symbols) {
1254+
LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, size_t num_modules,
1255+
const char **preserved_symbols, size_t num_symbols) {
12561256
auto Ret = std::make_unique<LLVMRustThinLTOData>();
12571257

12581258
// Load each module's summary and merge it into one combined index
1259-
for (int i = 0; i < num_modules; i++) {
1259+
for (size_t i = 0; i < num_modules; i++) {
12601260
auto module = &modules[i];
12611261
auto buffer = StringRef(module->data, module->len);
12621262
auto mem_buffer = MemoryBufferRef(buffer, module->identifier);
@@ -1275,7 +1275,7 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules, int num_modules,
12751275

12761276
// Convert the preserved symbols set from string to GUID, this is then needed
12771277
// for internalization.
1278-
for (int i = 0; i < num_symbols; i++) {
1278+
for (size_t i = 0; i < num_symbols; i++) {
12791279
auto GUID = GlobalValue::getGUID(preserved_symbols[i]);
12801280
Ret->GUIDPreservedSymbols.insert(GUID);
12811281
}

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,7 @@ extern "C" uint64_t LLVMRustDIBuilderCreateOpPlusUconst() {
12311231
return dwarf::DW_OP_plus_uconst;
12321232
}
12331233

1234-
extern "C" int64_t LLVMRustDIBuilderCreateOpLLVMFragment() {
1234+
extern "C" uint64_t LLVMRustDIBuilderCreateOpLLVMFragment() {
12351235
return dwarf::DW_OP_LLVM_fragment;
12361236
}
12371237

0 commit comments

Comments
 (0)