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

[MCE] common type too low #23

Open
Commaster opened this issue Aug 7, 2018 · 2 comments
Open

[MCE] common type too low #23

Commaster opened this issue Aug 7, 2018 · 2 comments

Comments

@Commaster
Copy link
Contributor

Commaster commented Aug 7, 2018

-- memCopy elision log --
Found divergent memcpy:   call void @llvm.memcpy.p0i8.p0i8.i64(i8* nonnull %11, i8* %12, i64 16, i32 4, i1 false), !tbaa.struct !12
derive   %arrayidx7.prol.i.i = getelementptr inbounds %struct.FOUR_VECTOR, %struct.FOUR_VECTOR* %callable.coerce3, i64 %10 size 16
        hit: pointer aligns with type!
derive   %arrayidx9.prol.i.i = getelementptr inbounds [100 x %struct.FOUR_VECTOR], [100 x %struct.FOUR_VECTOR]* @_ZZ6kernelIN5pacxx2v25rangeEEvRT_7par_str7dim_strP7box_strP11FOUR_VECTORPfSA_E9rA_shared, i64 0, i64 %indvars.iv245.prol.i.i size 16
        hit: pointer aligns with type!
                 derive common type for %struct.FOUR_VECTOR = type { float, float, float, float } and %struct.FOUR_VECTOR = type { float, float, float, float }
                 derive common type for float and %struct.FOUR_VECTOR = type { float, float, float, float }
                 derive common type for float and float
        skip: common base type: float
[llvm] CreateGEP called
[llvm] General case
[llvm] Values: 3
[llvm] PointeeType is nullptr, replacing
[llvm] Base type: %struct.FOUR_VECTOR*, ScalarPointerType: %struct.FOUR_VECTOR*, ElementType: %struct.FOUR_VECTOR = type { float, float, float, float }
[llvm] Resulting type: %struct.FOUR_VECTOR = type { float, float, float, float }
[llvm] Getting GEP Return Type from Type: %struct.FOUR_VECTOR = type { float, float, float, float }
[llvm] Getting IndexedType for %struct.FOUR_VECTOR = type { float, float, float, float }
[llvm] is sized
[llvm] is composite
[llvm] Verifying index
[llvm] Refreshing Type
[llvm] Type refreshed to float
[llvm] Idx 2 size 2
[llvm] not nullptr
[llvm] Getting IndexedType for %struct.FOUR_VECTOR = type { float, float, float, float }
[llvm] is sized
[llvm] is composite
[llvm] Verifying index
[llvm] Refreshing Type
[llvm] Type refreshed to float
[llvm] Idx 2 size 2
[llvm] CreateGEP called
[llvm] General case
[llvm] Values: 3
[llvm] PointeeType is nullptr, replacing
[llvm] Base type: %struct.FOUR_VECTOR*, ScalarPointerType: %struct.FOUR_VECTOR*, ElementType: %struct.FOUR_VECTOR = type { float, float, float, float }
[llvm] Resulting type: %struct.FOUR_VECTOR = type { float, float, float, float }
[llvm] Getting GEP Return Type from Type: %struct.FOUR_VECTOR = type { float, float, float, float }
[llvm] Getting IndexedType for %struct.FOUR_VECTOR = type { float, float, float, float }
[llvm] is sized
[llvm] is composite
[llvm] Verifying index
[llvm] Refreshing Type
[llvm] Type refreshed to float
[llvm] Idx 2 size 2
[llvm] not nullptr
[llvm] Getting IndexedType for %struct.FOUR_VECTOR = type { float, float, float, float }
[llvm] is sized
[llvm] is composite
[llvm] Verifying index
[llvm] Refreshing Type
[llvm] Type refreshed to float
[llvm] Idx 2 size 2
OK base gep src:   %basegep = getelementptr %struct.FOUR_VECTOR, %struct.FOUR_VECTOR* %arrayidx7.prol.i.i, i32 0, i32 0   base gep dest:   %basegep27 = getelementptr %struct.FOUR_VECTOR, %struct.FOUR_VECTOR* %arrayidx9.prol.i.i, i32 0, i32 0
Lowering
        to        %basegep27 = getelementptr %struct.FOUR_VECTOR, %struct.FOUR_VECTOR* %arrayidx9.prol.i.i, i32 0, i32 0
        from      %basegep = getelementptr %struct.FOUR_VECTOR, %struct.FOUR_VECTOR* %arrayidx7.prol.i.i, i32 0, i32 0
        based on common float of size 16
[llvm] CreateGEP called
[llvm] General case
[llvm] Values: 3
[llvm] PointeeType is nullptr, replacing
[llvm] Base type: float*, ScalarPointerType: float*, ElementType: float
[llvm] Resulting type: float
[llvm] Getting GEP Return Type from Type: float
[llvm] Getting IndexedType for float
[llvm] is sized
[llvm] nullptr
lavaMD: %%/llvm/include/llvm/IR/Instructions.h: llvm::Type* llvm::checkGEPType(llvm::Type*): Assertion `Ty && "Invalid GetElementPtrInst indices for type!"' failed.

I tried setting https://github.com/cdl-saarland/rv/blob/develop/src/transform/memCopyElision.cpp#L61 as the first check instead of last, which let the pass finish.

I also checked other calls to CreateGEP. Calls with basic types (i8, float, etc..) have only 1 index, calls for complex types (Arrays, structures) have 2 or more. I suspect the issue here is that the common type gets decayed to a basic type, but still supplied with two indexes (https://github.com/cdl-saarland/rv/blob/develop/src/transform/memCopyElision.cpp#L107)

@simoll
Copy link
Member

simoll commented Aug 9, 2018

Thanks for the detailed report. I will need a test_rv test to reproduce this. Maybe you can leverage the existing memcpy test launcher.

@Commaster
Copy link
Contributor Author

I'm still working on converting this test case into a test suite. For now, the module IR that RV receives: https://gist.github.com/Commaster/c8cb1928c22a2b77e358c48c01eb5163

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

No branches or pull requests

2 participants