[LLVMbugs] [Bug 157] [llvmgcc] Pointer & constant results in invalid shift
bugzilla-daemon at zion.cs.uiuc.edu
bugzilla-daemon at zion.cs.uiuc.edu
Tue Nov 25 23:38:21 PST 2003
http://llvm.cs.uiuc.edu/bugs/show_bug.cgi?id=157
sabre at nondot.org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|NEW |RESOLVED
Keywords| |compile-fail
OS/Version|Linux |All
Platform|PC |All
Resolution| |FIXED
Summary|CFE fails to bit-and a |[llvmgcc] Pointer & constant
|constant int with a ptr |results in invalid shift
|casted to long |
Target Milestone|--- |1.1
Version|trunk |1.0
------- Additional Comments From sabre at nondot.org 2003-11-26 01:38 -------
Fixed.
Testcase here: llvm/test/Regression/CFrontend/2003-11-26-PointerShift.c
Two bug fixes here:
1. The silly asmparser should not spew tons of problems then assert out
when a problem occurs. Instead of handling this at every "ThrowException"
call, we just handle it in ONE place, if an exception is thrown:
http://mail.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20031124/009890.html
2. The C front-end is generating illegal shr instructions. This is bad. :)
$ diff -u llvm-expand.c~ llvm-expand.c
--- llvm-expand.c~ 2003-11-26 01:27:26.000000000 -0600
+++ llvm-expand.c 2003-11-26 01:32:35.000000000 -0600
@@ -5452,6 +5452,8 @@
case LSHIFT_EXPR:
case RSHIFT_EXPR: /* Shift amount -> ubyte */
op1 = cast_if_type_not_equal(Fn, op1, UByteTy);
+ if (op0->Ty->ID == PointerTyID)
+ op0 = cast_if_type_not_equal(Fn, op0, LongTy);
break;
case NE_EXPR:
$ diff -u llvm-representation.c~ llvm-representation.c
--- llvm-representation.c~ 2003-11-06 10:24:52.000000000 -0600
+++ llvm-representation.c 2003-11-26 01:28:29.000000000 -0600
@@ -533,7 +533,10 @@
New->Operands[0] = Op1;
New->Operands[1] = Op2;
- if (Opc != O_Shr && Opc != O_Shl)
+ if (Opc == O_Shr || Opc == O_Shl)
+ assert(llvm_type_is_integer(Op1->Ty) && Op2->Ty == UByteTy &&
+ "Illegal operands for shift instructions!");
+ else
assert(Op1->Ty == Op2->Ty &&
"Binary operator operands must have compatible types!");
if (Opc == O_Add || Opc == O_Sub || Opc == O_Mul || Opc == O_Div ||
------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.
More information about the llvm-bugs
mailing list