[llvm-commits] [llvm] r122264 - in /llvm/trunk: include/llvm/InitializePasses.h include/llvm/LinkAllPasses.h include/llvm/Transforms/Scalar.h lib/Transforms/Utils/CMakeLists.txt lib/Transforms/Utils/Utils.cpp

Duncan Sands baldrick at free.fr
Tue Dec 21 08:19:28 PST 2010


Hi Nick,

>> Add a new convenience pass for testing InstructionSimplify. Previously
>> it could only be tested indirectly, via instcombine, gvn or some other
>> pass that makes use of InstructionSimplify, which means that testcases
>> had to be carefully contrived to dance around any other transformations
>> that that pass did.
>
> If you're interested, you could also test it with the unit testing framework by
> making calls to SimplifyInstruction. It would look something like:

thanks for the interesting suggestion but I think using a pass is simpler.

Ciao, Duncan.

>
> TEST(InstructionSimplify, AddTest) {
> LLVMContext context;
> Argument *A = new Argument(Type::Int64Ty);
> Instruction *I = BinaryOperator::CreateNeg(
> BinaryOperator::CreateSub(
> ConstantInt::get(Type::Int64Ty, -1),
> A
> )
> );
> Instruction *J = SimplifyInstruction(I);
> EXPECT_EQ(J->getOpcode(), Instruction::Add);
> EXPECT_EQ(J->getOperand(0), A);
> EXPECT_EQ(J->getOperand(1), ConstantInt::get(Type::Int64Ty), 1));
> }
>
> Since the C++ API is bulky, you can also use ParseAssemblyString to produce a
> Module from inline .ll, see unittests/ExecutionEngine/JIT/JITTest.cpp for
> inspiration.
>
> Nick



More information about the llvm-commits mailing list