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

[Hexagon] llvm-options attribute is an array of strings #9011

Merged
merged 1 commit into from
Sep 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions src/target/llvm/codegen_hexagon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -671,11 +671,9 @@ runtime::Module BuildHexagon(IRModule mod, Target target) {
}
return vec;
};
std::string llvm_options_str;
if (const Optional<String> llvm_options = target->GetAttr<String>("llvm-options")) {
llvm_options_str = "llvm," + llvm_options.value();
} else {
llvm_options_str = "llvm";
std::string llvm_options_str = "llvm";
if (const auto& llvm_options = target->GetAttr<Array<String>>("llvm-options")) {
for (const String& s : llvm_options.value()) llvm_options_str += "," + s;
}
// Postprocess the LLVM options string: replace '@' with '=', and ',' with ' '.
for (int i = 0, e = llvm_options_str.size(); i != e; ++i) {
Expand Down
13 changes: 13 additions & 0 deletions tests/python/unittest/test_target_codegen_hexagon.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ def test_alloc_vtcm():
assert "HexagonBackendFreeVTCM" in calls


def test_llvm_options():
if not check_prereq_and_setup():
return
target = tvm.target.hexagon("v66", llvm_options="-hexagon-noopt")
Zero = tvm.te.compute((10,), lambda _: tvm.tir.const(0, "int32"))
s = tvm.te.create_schedule(Zero.op)
tvm.build(s, [Zero], target=target, name="zero")
# Check that BuildHexagon hasn't crashed because of target attribute
# type mismatch.
assert re.search("-hexagon-noopt", str(target))


def test_linked_params_codegen():
if not check_prereq_and_setup():
return
Expand Down Expand Up @@ -176,4 +188,5 @@ def test_linked_params_codegen():
test_basic()
test_llvm_target_features()
test_alloc_vtcm()
test_llvm_options()
test_linked_params_codegen()