Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[IRGen] Collect metadata from like type and add type information when GEPing into raw layouts #76303

Merged
merged 2 commits into from
Sep 11, 2024

Conversation

Azoy
Copy link
Contributor

@Azoy Azoy commented Sep 6, 2024

Previously, we weren't collecting the metadata from the like or count type so something generic over say a Mutex would cause a compiler crash because it wouldn't know where to find some metadata. Additionally, we weren't typing the addresses used when handling takes and destroys of raw layout causing some issues with certain like types because they would require long chains of GEPs to get the underlying value where previously we would exhaust the storage type (because it was in terms of the raw layout's storage type).

Resolves: rdar://134365415 and rdar://132358675

@Azoy
Copy link
Contributor Author

Azoy commented Sep 6, 2024

@swift-ci please test

@Azoy
Copy link
Contributor Author

Azoy commented Sep 11, 2024

@swift-ci please test

@Azoy Azoy merged commit 3b741ee into swiftlang:main Sep 11, 2024
5 checks passed
@Azoy Azoy deleted the rawlayout-fixes branch September 11, 2024 23:25
@kateinoigakukun
Copy link
Member

kateinoigakukun commented Sep 13, 2024

Hi @Azoy, could you take a look at the test failure of test/IRGen/stdlib/Mutex.swift on wasm32? 🙏
Should we just make getelementptr inbounds i32, ptr [[MUTEX]], i{{32|64}} 7 into getelementptr inbounds i32, ptr [[MUTEX]], i{{32 4|||64 7}}?

https://ci.swift.org/job/oss-swift-pr-test-crosscompile-wasm-ubuntu-20_04/1491/console

--
Exit Code: 1

Command Output (stderr):
--
/home/build-user/build/buildbot_linux/wasmstdlib-linux-x86_64/test-wasi-wasm32/IRGen/stdlib/Output/Mutex.swift.tmp/Mutex.swift:36:11: error: CHECK: expected string not found in input
// CHECK: [[DEST_MUTEX_VALUE_OFFSET_PTR:%.*]] = getelementptr inbounds i32, ptr [[MUTEX]], i{{32|64}} 7
          ^
<stdin>:717:96: note: scanning from here
 call void @llvm.memcpy.p0.p0.i32(ptr align 4 %.handle, ptr align 4 %.handle3, i32 4, i1 false)
                                                                                               ^
<stdin>:717:96: note: with "MUTEX" equal to "%\"Mutex<Awaitable<Value, Failure>\\.State>\""
 call void @llvm.memcpy.p0.p0.i32(ptr align 4 %.handle, ptr align 4 %.handle3, i32 4, i1 false)
                                                                                               ^
<stdin>:720:2: note: possible intended match here
 %4 = getelementptr inbounds i8, ptr %1, i32 %3
 ^

Input file: <stdin>
Check file: /home/build-user/build/buildbot_linux/wasmstdlib-linux-x86_64/test-wasi-wasm32/IRGen/stdlib/Output/Mutex.swift.tmp/Mutex.swift

-dump-input=help explains the following input dump.

Input was:
<<<<<<
            .
            .
            .
          712:  %Failure2 = alloca ptr, align 4 
          713:  store ptr %Value, ptr %Value1, align 4 
          714:  store ptr %Failure, ptr %Failure2, align 4 
          715:  %.handle = getelementptr inbounds %T15Synchronization5MutexV, ptr %1, i32 0, i32 0 
          716:  %.handle3 = getelementptr inbounds %T15Synchronization5MutexV, ptr %0, i32 0, i32 0 
          717:  call void @llvm.memcpy.p0.p0.i32(ptr align 4 %.handle, ptr align 4 %.handle3, i32 4, i1 false) 
check:36'0                                                                                                    X error: no match found
check:36'1                                                                                                      with "MUTEX" equal to "%\"Mutex<Awaitable<Value, Failure>\\.State>\""
          718:  %2 = getelementptr inbounds i32, ptr %"Mutex<Awaitable<Value, Failure>.State>", i32 4 
check:36'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          719:  %3 = load i32, ptr %2, align 4 
check:36'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          720:  %4 = getelementptr inbounds i8, ptr %1, i32 %3 
check:36'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
check:36'2      ?                                               possible intended match
          721:  %5 = getelementptr inbounds i32, ptr %"Mutex<Awaitable<Value, Failure>.State>", i32 4 
check:36'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          722:  %6 = load i32, ptr %5, align 4 
check:36'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          723:  %7 = getelementptr inbounds i8, ptr %0, i32 %6 
check:36'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          724:  %.pendingConsumers = getelementptr inbounds %T6stdlib9AwaitableC5StateV, ptr %4, i32 0, i32 0 
check:36'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          725:  %.pendingConsumers4 = getelementptr inbounds %T6stdlib9AwaitableC5StateV, ptr %7, i32 0, i32 0 
check:36'0     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            .
            .
            .
>>>>>>

--

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants