Skip to content

Commit

Permalink
[Hexagon] llvm-options attribute is an array of strings (apache#9011)
Browse files Browse the repository at this point in the history
Change the type from String to Array<String> in the code that looks
the attribute up.
  • Loading branch information
Krzysztof Parzyszek authored and ylc committed Sep 29, 2021
1 parent 9496a19 commit e559065
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
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()

0 comments on commit e559065

Please sign in to comment.