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

ARROW-8968: [C++][Gandiva] set data layout for pre-compiled IR to llvm::module #7295

Closed
wants to merge 6 commits into from

Conversation

kiszk
Copy link
Member

@kiszk kiszk commented May 27, 2020

This PR explicitly sets data layout for pre-compiled IR to llvm:module. Without the PR, the following warning message is shown at link time of gandiva.

Most of this code comes from https://reviews.llvm.org/D80130 by @imaihal in llvm.

~/arrow/cpp/src/gandiva$ ../../build/debug/gandiva-binary-test -V
Running main() from /home/ishizaki/arrow/cpp/googletest_ep-prefix/src/googletest_ep/googletest/src/gtest_main.cc
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from TestBinary
[ RUN      ] TestBinary.TestSimple
warning: Linking two modules of different data layouts: 'precompiled' is 'E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64' whereas 'codegen' is 'E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64'

[       OK ] TestBinary.TestSimple (41 ms)
[----------] 1 test from TestBinary (41 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (41 ms total)
[  PASSED  ] 1 test.

@github-actions
Copy link

@kou kou changed the title ARROW-8968: [C++][gandiva] set data layout for pre-compiled IR to llvm::module ARROW-8968: [C++][Gandiva] set data layout for pre-compiled IR to llvm::module May 27, 2020
Copy link
Member

@wesm wesm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Most of this code comes from https://reviews.llvm.org/D80130 by @imaihal in llvm.

I presume this code is covered by the LLVM license, do we need to put that somewhere?

@@ -150,6 +152,27 @@ Status Engine::Make(const std::shared_ptr<Configuration>& conf,
return Status::OK();
}

static void setDataLayout(llvm::Module* module) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: SetDataLayout

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, addressed all of them.

@@ -150,6 +152,27 @@ Status Engine::Make(const std::shared_ptr<Configuration>& conf,
return Status::OK();
}

static void setDataLayout(llvm::Module* module) {
auto targetTriple = llvm::sys::getDefaultTargetTriple();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use lower_with_underscores for local variables

llvm::StringMap<bool> hostFeatures;

if (llvm::sys::getHostCPUFeatures(hostFeatures))
for (auto& f : hostFeatures) features.AddFeature(f.first(), f.second);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: please use braces

@kiszk
Copy link
Member Author

kiszk commented May 28, 2020

Regarding the licence, I will add a link to the file at https://github.com/llvm/llvm-project/blob/master/mlir/LICENSE.TXT.
Could you please let me know if we need to create a separate file as https://github.com/apache/arrow/blob/master/cpp/src/arrow/util/bpacking_default.h

@wesm
Copy link
Member

wesm commented May 28, 2020

@kiszk see https://github.com/apache/arrow/blob/master/LICENSE.txt#L1071

Perhaps change "3rdparty dependency LLVM is statically linked in certain binary distributions." to "3rdparty dependency LLVM is statically linked in certain binary distributions. Additionally some sections of source code have been derived from sources in LLVM and have been clearly labeled as such."

@kiszk
Copy link
Member Author

kiszk commented May 28, 2020

@wesm, thank you. I will update it.

Another question. I have just realized the LLVM license is included in the file https://github.com/apache/arrow/blob/master/LICENSE.txt. LLVM changes its license from LLVM9 as Apache2 with LLVM exception. Should we update the file https://github.com/apache/arrow/blob/master/LICENSE.txt#L1074-L1141 when #7280 is merged?

@wesm
Copy link
Member

wesm commented May 28, 2020

@kiszk yes I think that's a good idea cc @kou

@wesm wesm closed this in bbc3e30 May 28, 2020
bkietz pushed a commit to bkietz/arrow that referenced this pull request May 29, 2020
…m::module

This PR explicitly sets data layout for pre-compiled IR to `llvm:module`. Without the PR, the following warning message is shown at link time of gandiva.

Most of this code comes from https://reviews.llvm.org/D80130 by @imaihal in llvm.

```
~/arrow/cpp/src/gandiva$ ../../build/debug/gandiva-binary-test -V
Running main() from /home/ishizaki/arrow/cpp/googletest_ep-prefix/src/googletest_ep/googletest/src/gtest_main.cc
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from TestBinary
[ RUN      ] TestBinary.TestSimple
warning: Linking two modules of different data layouts: 'precompiled' is 'E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-a:8:16-n32:64' whereas 'codegen' is 'E-m:e-i1:8:16-i8:8:16-i64:64-f128:64-v128:64-a:8:16-n32:64'

[       OK ] TestBinary.TestSimple (41 ms)
[----------] 1 test from TestBinary (41 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (41 ms total)
[  PASSED  ] 1 test.
```

Closes apache#7295 from kiszk/ARROW-8968

Authored-by: Kazuaki Ishizaki <ishizaki@jp.ibm.com>
Signed-off-by: Wes McKinney <wesm+git@apache.org>
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