-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[NFC][X86] Fix Werror=extra error due to enum #112812
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
Conversation
This is one of the many PRs to fix errors with LLVM_ENABLE_WERROR=on. Built by GCC 11.
Fix warnings:
llvm-project/llvm/lib/Target/X86/X86FastISel.cpp: In member function ‘virtual bool {anonymous}::X86FastISel::fastLowerCall(llvm::FastISel::CallLoweringInfo&)’:
llvm-project/llvm/lib/Target/X86/X86FastISel.cpp:3547: error: enumerated and non-enumerated type in conditional expression [-Werror=extra]
3547 | MIB.addReg(Is64Bit ? X86::RIP : 0).addImm(1).addReg(0);
|
@llvm/pr-subscribers-backend-x86 Author: Jinsong Ji (jsji) ChangesThis is one of the many PRs to fix errors with LLVM_ENABLE_WERROR=on. Built by GCC 11. Fix warnings: Full diff: https://github.com/llvm/llvm-project/pull/112812.diff 2 Files Affected:
diff --git a/llvm/lib/Target/X86/X86FastISel.cpp b/llvm/lib/Target/X86/X86FastISel.cpp
index 4bf660b5e234ae..9e4e5547c642cc 100644
--- a/llvm/lib/Target/X86/X86FastISel.cpp
+++ b/llvm/lib/Target/X86/X86FastISel.cpp
@@ -3544,7 +3544,7 @@ bool X86FastISel::fastLowerCall(CallLoweringInfo &CLI) {
MIB = BuildMI(*FuncInfo.MBB, FuncInfo.InsertPt, MIMD, TII.get(CallOpc));
if (NeedLoad)
- MIB.addReg(Is64Bit ? X86::RIP : 0).addImm(1).addReg(0);
+ MIB.addReg(Is64Bit ? X86::RIP : X86::NoRegister).addImm(1).addReg(0);
if (Symbol)
MIB.addSym(Symbol, OpFlags);
else
diff --git a/llvm/lib/Target/X86/X86ISelLowering.cpp b/llvm/lib/Target/X86/X86ISelLowering.cpp
index db633d10edc49a..a469a5a554354f 100644
--- a/llvm/lib/Target/X86/X86ISelLowering.cpp
+++ b/llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -29986,7 +29986,7 @@ static SDValue LowerShift(SDValue Op, const X86Subtarget &Subtarget,
MVT::getVectorVT(NarrowScalarVT, WideNumElts), dl, AmtWideElts);
AmtWide = DAG.getZExtOrTrunc(AmtWide, dl, WideVT);
// Perform the actual shift.
- unsigned LogicalOpc = Opc == ISD::SRA ? ISD::SRL : Opc;
+ unsigned LogicalOpc = Opc == ISD::SRA ? (unsigned)ISD::SRL : Opc;
SDValue ShiftedR = DAG.getNode(LogicalOpc, dl, WideVT, RWide, AmtWide);
// Now we need to construct a mask which will "drop" bits that get
// shifted past the LSB/MSB. For a logical shift left, it will look
|
| AmtWide = DAG.getZExtOrTrunc(AmtWide, dl, WideVT); | ||
| // Perform the actual shift. | ||
| unsigned LogicalOpc = Opc == ISD::SRA ? ISD::SRL : Opc; | ||
| unsigned LogicalOpc = Opc == ISD::SRA ? (unsigned)ISD::SRL : Opc; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why need (unsigned) here? If the ISD::XXX is not a unsigned value, I think we would have more warn/error when comparing with Opc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, maybe because we just use == and != here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is about Opc is unsigned and ISD::SRL is enum, and they are used in the ?: operator, so type mismatch.
phoebewang
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
This is one of the many PRs to fix errors with LLVM_ENABLE_WERROR=on. Built by GCC 11.
Fix warnings:
llvm-project/llvm/lib/Target/X86/X86FastISel.cpp: In member function ‘virtual bool {anonymous}::X86FastISel::fastLowerCall(llvm::FastISel::CallLoweringInfo&)’:
llvm-project/llvm/lib/Target/X86/X86FastISel.cpp:3547: error: enumerated and non-enumerated type in conditional expression [-Werror=extra]
3547 | MIB.addReg(Is64Bit ? X86::RIP : 0).addImm(1).addReg(0);