Skip to content
Open
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: 5 additions & 3 deletions llvm/lib/MC/MCSubtargetInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ void ClearImpliedBits(FeatureBitset &Bits, unsigned Value,

static void ApplyFeatureFlag(FeatureBitset &Bits, StringRef Feature,
ArrayRef<SubtargetFeatureKV> FeatureTable) {
assert(SubtargetFeatures::hasFlag(Feature) &&
"Feature flags should start with '+' or '-'");

if (!SubtargetFeatures::hasFlag(Feature)) {
errs() << "Feature flag '" << Feature
<< "' must start with either '+' or '-' (ignoring feature)\n";
return;
}
// Find feature in table.
const SubtargetFeatureKV *FeatureEntry =
Find(SubtargetFeatures::StripFlag(Feature), FeatureTable);
Expand Down
9 changes: 9 additions & 0 deletions llvm/test/CodeGen/Generic/invalid-target-feature.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
; Check that we handle a malformed feature flag gracefully.

; RUN: llc %s -o - 2>&1 | FileCheck %s

; CHECK: Feature flag 'foobar' must start with either '+' or '-' (ignoring feature)
define void @f() "target-features"="foobar" {
entry:
ret void
}