Skip to content

Commit e559065

Browse files
Krzysztof Parzyszekylc
authored andcommitted
[Hexagon] llvm-options attribute is an array of strings (apache#9011)
Change the type from String to Array<String> in the code that looks the attribute up.
1 parent 9496a19 commit e559065

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

src/target/llvm/codegen_hexagon.cc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -671,11 +671,9 @@ runtime::Module BuildHexagon(IRModule mod, Target target) {
671671
}
672672
return vec;
673673
};
674-
std::string llvm_options_str;
675-
if (const Optional<String> llvm_options = target->GetAttr<String>("llvm-options")) {
676-
llvm_options_str = "llvm," + llvm_options.value();
677-
} else {
678-
llvm_options_str = "llvm";
674+
std::string llvm_options_str = "llvm";
675+
if (const auto& llvm_options = target->GetAttr<Array<String>>("llvm-options")) {
676+
for (const String& s : llvm_options.value()) llvm_options_str += "," + s;
679677
}
680678
// Postprocess the LLVM options string: replace '@' with '=', and ',' with ' '.
681679
for (int i = 0, e = llvm_options_str.size(); i != e; ++i) {

tests/python/unittest/test_target_codegen_hexagon.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,18 @@ def test_alloc_vtcm():
109109
assert "HexagonBackendFreeVTCM" in calls
110110

111111

112+
def test_llvm_options():
113+
if not check_prereq_and_setup():
114+
return
115+
target = tvm.target.hexagon("v66", llvm_options="-hexagon-noopt")
116+
Zero = tvm.te.compute((10,), lambda _: tvm.tir.const(0, "int32"))
117+
s = tvm.te.create_schedule(Zero.op)
118+
tvm.build(s, [Zero], target=target, name="zero")
119+
# Check that BuildHexagon hasn't crashed because of target attribute
120+
# type mismatch.
121+
assert re.search("-hexagon-noopt", str(target))
122+
123+
112124
def test_linked_params_codegen():
113125
if not check_prereq_and_setup():
114126
return
@@ -176,4 +188,5 @@ def test_linked_params_codegen():
176188
test_basic()
177189
test_llvm_target_features()
178190
test_alloc_vtcm()
191+
test_llvm_options()
179192
test_linked_params_codegen()

0 commit comments

Comments
 (0)