[llvm-commits] [llvm] r94454 - in /llvm/trunk: lib/Bitcode/Reader/BitcodeReader.cpp test/Bitcode/flags.ll
Dan Gohman
gohman at apple.com
Mon Jan 25 13:55:40 PST 2010
Author: djg
Date: Mon Jan 25 15:55:39 2010
New Revision: 94454
URL: http://llvm.org/viewvc/llvm-project?rev=94454&view=rev
Log:
Fix the bitcode reader to deserialize nuw/nsw/etc. bits properly in the case
of a forward-reference, which doesn't use an "abbrev" encoding.
Added:
llvm/trunk/test/Bitcode/flags.ll
Modified:
llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=94454&r1=94453&r2=94454&view=diff
==============================================================================
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Mon Jan 25 15:55:39 2010
@@ -1702,12 +1702,12 @@
if (Opc == Instruction::Add ||
Opc == Instruction::Sub ||
Opc == Instruction::Mul) {
- if (Record[3] & (1 << bitc::OBO_NO_SIGNED_WRAP))
+ if (Record[OpNum] & (1 << bitc::OBO_NO_SIGNED_WRAP))
cast<BinaryOperator>(I)->setHasNoSignedWrap(true);
- if (Record[3] & (1 << bitc::OBO_NO_UNSIGNED_WRAP))
+ if (Record[OpNum] & (1 << bitc::OBO_NO_UNSIGNED_WRAP))
cast<BinaryOperator>(I)->setHasNoUnsignedWrap(true);
} else if (Opc == Instruction::SDiv) {
- if (Record[3] & (1 << bitc::SDIV_EXACT))
+ if (Record[OpNum] & (1 << bitc::SDIV_EXACT))
cast<BinaryOperator>(I)->setIsExact(true);
}
}
Added: llvm/trunk/test/Bitcode/flags.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bitcode/flags.ll?rev=94454&view=auto
==============================================================================
--- llvm/trunk/test/Bitcode/flags.ll (added)
+++ llvm/trunk/test/Bitcode/flags.ll Mon Jan 25 15:55:39 2010
@@ -0,0 +1,27 @@
+; RUN: llvm-as < %s | llvm-dis > %t0
+; RUN: opt -S < %s > %t1
+; RUN: diff %t0 %t1
+; PR6140
+
+; Make sure the flags are serialized/deserialized properly for both
+; forward and backward references.
+
+define void @foo() nounwind {
+entry:
+ br label %first
+
+second: ; preds = %first
+ %u = add nuw i32 %a, 0 ; <i32> [#uses=0]
+ %s = add nsw i32 %a, 0 ; <i32> [#uses=0]
+ %us = add nuw nsw i32 %a, 0 ; <i32> [#uses=0]
+ %z = add i32 %a, 0 ; <i32> [#uses=0]
+ unreachable
+
+first: ; preds = %entry
+ %a = bitcast i32 0 to i32 ; <i32> [#uses=8]
+ %uu = add nuw i32 %a, 0 ; <i32> [#uses=0]
+ %ss = add nsw i32 %a, 0 ; <i32> [#uses=0]
+ %uuss = add nuw nsw i32 %a, 0 ; <i32> [#uses=0]
+ %zz = add i32 %a, 0 ; <i32> [#uses=0]
+ br label %second
+}
More information about the llvm-commits
mailing list