Skip to content

[TargetLowering] fix index OOB #67494

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

Merged
merged 2 commits into from
Sep 26, 2023
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: 7 additions & 1 deletion llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5889,9 +5889,15 @@ 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;
}
}

OpInfo.ConstraintCode = G[BestIdx].first;
OpInfo.ConstraintType = G[BestIdx].second;
Expand Down
6 changes: 6 additions & 0 deletions llvm/test/CodeGen/X86/inline-asm-bad-constraint-n.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
4 changes: 4 additions & 0 deletions llvm/test/CodeGen/X86/inline-asm-n-constraint.ll
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down