-
Notifications
You must be signed in to change notification settings - Fork 12k
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
[TargetLowering] fix index OOB #67494
Merged
nickdesaulniers
merged 2 commits into
llvm:main
from
nickdesaulniers:ff_choose_constraint
Sep 26, 2023
Merged
[TargetLowering] fix index OOB #67494
nickdesaulniers
merged 2 commits into
llvm:main
from
nickdesaulniers:ff_choose_constraint
Sep 26, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I accidentally introduced this in commit 330fa7d ("[TargetLowering] Deduplicate choosing InlineAsm constraint between ISels (llvm#67057)") Fix forward.
@llvm/pr-subscribers-llvm-selectiondag @llvm/pr-subscribers-backend-x86 ChangesI accidentally introduced this in commit 330fa7d ("[TargetLowering] Deduplicate choosing InlineAsm Fix forward. Full diff: https://github.com/llvm/llvm-project/pull/67494.diff 3 Files Affected:
diff --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 3b259d99f0029ca..911d63a75458b54 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -5889,10 +5889,17 @@ void TargetLowering::ComputeConstraintToUse(AsmOperandInfo &OpInfo,
for (const unsigned E = G.size();
BestIdx < E && (G[BestIdx].second == TargetLowering::C_Other ||
G[BestIdx].second == TargetLowering::C_Immediate);
- ++BestIdx)
+ ++BestIdx) {
if (lowerImmediateIfPossible(G[BestIdx], Op, DAG, *this))
break;
+ // If we're out of constraints, just pick the first one.
+ if (BestIdx + 1 == E) {
+ BestIdx = 0;
+ break;
+ }
+ }
+ assert(BestIdx < G.size() && "bad index for best constraint");
OpInfo.ConstraintCode = G[BestIdx].first;
OpInfo.ConstraintType = G[BestIdx].second;
}
diff --git a/llvm/test/CodeGen/X86/inline-asm-bad-constraint-n.ll b/llvm/test/CodeGen/X86/inline-asm-bad-constraint-n.ll
index 41d8a9baa8dd4e1..d27a74620013bbd 100644
--- a/llvm/test/CodeGen/X86/inline-asm-bad-constraint-n.ll
+++ b/llvm/test/CodeGen/X86/inline-asm-bad-constraint-n.ll
@@ -8,3 +8,9 @@ define void @foo() {
call void asm sideeffect "foo $0", "n"(ptr %a) nounwind
ret void
}
+
+; CHECK: error: invalid operand for inline asm constraint 'i'
+define void @bar(i32 %v) {
+ call void asm "", "in"(i32 %v)
+ ret void
+}
diff --git a/llvm/test/CodeGen/X86/inline-asm-n-constraint.ll b/llvm/test/CodeGen/X86/inline-asm-n-constraint.ll
index 669e464f1f6f89f..4774d43ee333f0b 100644
--- a/llvm/test/CodeGen/X86/inline-asm-n-constraint.ll
+++ b/llvm/test/CodeGen/X86/inline-asm-n-constraint.ll
@@ -7,6 +7,10 @@ define void @foo() {
call void asm sideeffect "foo $0", "n"(i32 42) nounwind
; CHECK: #APP
; CHECK-NEXT: foo $42
+; CHECK-NEXT: #NO_APP
+ call void asm "# $0", "in"(i32 1392848979)
+; CHECK-NEXT: #APP
+; CHECK-NEXT: # $1392848979
; CHECK-NEXT: #NO_APP
ret void
; CHECK-NEXT: retq
|
jyknight
reviewed
Sep 26, 2023
jyknight
approved these changes
Sep 26, 2023
legrosbuffle
pushed a commit
to legrosbuffle/llvm-project
that referenced
this pull request
Sep 29, 2023
I accidentally introduced this in commit 330fa7d ("[TargetLowering] Deduplicate choosing InlineAsm constraint between ISels (llvm#67057)") Fix forward.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I accidentally introduced this in
commit 330fa7d ("[TargetLowering] Deduplicate choosing InlineAsm
constraint between ISels (#67057)")
Fix forward.