diff options
author | Abdoulaye Walsimou Gaye <awg@embtoolkit.org> | 2013-05-11 09:24:14 +0200 |
---|---|---|
committer | Abdoulaye Walsimou Gaye <awg@embtoolkit.org> | 2013-05-11 09:24:14 +0200 |
commit | f9b7f4221ef658e3716973b6c2e816af483513f2 (patch) | |
tree | 385391d0ff316a2755def88921ffe06519087cf3 | |
parent | 216a19f9c117ed36f6b224125a7c5ef8015239be (diff) | |
parent | 30b015f044cd0157b68f5737321f685741c17423 (diff) | |
download | llvm-f9b7f4221ef658e3716973b6c2e816af483513f2.tar.gz llvm-f9b7f4221ef658e3716973b6c2e816af483513f2.tar.bz2 llvm-f9b7f4221ef658e3716973b6c2e816af483513f2.tar.xz |
Merge branch 'release_33' of git://github.com/llvm-mirror/llvm into embtk-support-release-3.3
-rw-r--r-- | lib/Transforms/Scalar/CodeGenPrepare.cpp | 7 | ||||
-rw-r--r-- | test/CodeGen/X86/codegen-prepare.ll | 44 | ||||
-rw-r--r-- | unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp | 2 |
3 files changed, 48 insertions, 5 deletions
diff --git a/lib/Transforms/Scalar/CodeGenPrepare.cpp b/lib/Transforms/Scalar/CodeGenPrepare.cpp index 615c517449..f0d29c88a8 100644 --- a/lib/Transforms/Scalar/CodeGenPrepare.cpp +++ b/lib/Transforms/Scalar/CodeGenPrepare.cpp @@ -18,6 +18,7 @@ #include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/Statistic.h" +#include "llvm/ADT/ValueMap.h" #include "llvm/Analysis/DominatorInternals.h" #include "llvm/Analysis/Dominators.h" #include "llvm/Analysis/InstructionSimplify.h" @@ -88,7 +89,7 @@ namespace { /// Keeps track of non-local addresses that have been sunk into a block. /// This allows us to avoid inserting duplicate code for blocks with /// multiple load/stores of the same address. - DenseMap<Value*, Value*> SunkAddrs; + ValueMap<Value*, Value*> SunkAddrs; /// ModifiedDT - If CFG is modified in anyway, dominator tree may need to /// be updated. @@ -1653,10 +1654,6 @@ bool CodeGenPrepare::OptimizeMemoryInst(Instruction *MemoryInst, Value *Addr, // start of the block. CurInstIterator = BB->begin(); SunkAddrs.clear(); - } else { - // This address is now available for reassignment, so erase the table - // entry; we don't want to match some completely different instruction. - SunkAddrs[Addr] = 0; } } ++NumMemoryInsts; diff --git a/test/CodeGen/X86/codegen-prepare.ll b/test/CodeGen/X86/codegen-prepare.ll new file mode 100644 index 0000000000..e8ee070635 --- /dev/null +++ b/test/CodeGen/X86/codegen-prepare.ll @@ -0,0 +1,44 @@ +; RUN: llc < %s -mtriple=x86_64-pc-linux | FileCheck %s + +; Check that the CodeGenPrepare Pass +; does not wrongly rewrite the address computed by Instruction %4 +; as [12 + Base:%this]. + +; This test makes sure that: +; - both the store and the first load instructions +; within basic block labeled 'if.then' are not removed. +; - the store instruction stores a value at address [60 + %this] +; - the first load instruction loads a value at address [12 + %this] + +%class.A = type { %struct.B } +%struct.B = type { %class.C, %class.D, %class.C, %class.D } +%class.C = type { float, float, float } +%class.D = type { [3 x %class.C] } + +define linkonce_odr void @foo(%class.A* nocapture %this, i32 %BoolValue) nounwind uwtable { +entry: + %cmp = icmp eq i32 %BoolValue, 0 + %address1 = getelementptr inbounds %class.A* %this, i64 0, i32 0, i32 3 + %address2 = getelementptr inbounds %class.A* %this, i64 0, i32 0, i32 1 + br i1 %cmp, label %if.else, label %if.then + +if.then: ; preds = %entry + %0 = getelementptr inbounds %class.D* %address2, i64 0, i32 0, i64 0, i32 0 + %1 = load float* %0, align 4 + %2 = getelementptr inbounds float* %0, i64 3 + %3 = load float* %2, align 4 + %4 = getelementptr inbounds %class.D* %address1, i64 0, i32 0, i64 0, i32 0 + store float %1, float* %4, align 4 + br label %if.end + +if.else: ; preds = %entry + br label %if.end + +if.end: ; preds = %if.then, %if.else, %entry + ret void +} + +; CHECK: foo: +; CHECK: movss 12([[THIS:%[a-zA-Z0-9]+]]), [[REGISTER:%[a-zA-Z0-9]+]] +; CHECK-NEXT: movss [[REGISTER]], 60([[THIS]]) + diff --git a/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp b/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp index d8cf6c592d..07ea1afe1a 100644 --- a/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp +++ b/unittests/ExecutionEngine/MCJIT/MCJITCAPITest.cpp @@ -48,6 +48,8 @@ TEST_F(MCJITCAPITest, simple_function) { // Creates a function that returns 42, compiles it, and runs it. LLVMModuleRef module = LLVMModuleCreateWithName("simple_module"); + + LLVMSetTarget(module, HostTriple.c_str()); LLVMValueRef function = LLVMAddFunction( module, "simple_function", LLVMFunctionType(LLVMInt32Type(), 0, 0, 0)); |