Set load/store alignment when doing ABI coercions.

- Currently, this is producing poor code, but we prefer correctness
   to performance for now. Eventually we should be able to generally
   avoid having to set the alignment when we control the alignment of
   the alloca.

 - This knocks out 33/1000 failures on my single argument ABI tests,
   down to 22/1000 and 18 of these appear to be gcc bugs. Woot.

llvm-svn: 64001
This commit is contained in:
Daniel Dunbar 2009-02-07 02:46:03 +00:00
parent 8ba7132128
commit ee9e4c274b
1 changed files with 14 additions and 4 deletions

View File

@ -959,7 +959,10 @@ static llvm::Value *CreateCoercedLoad(llvm::Value *SrcPtr,
if (SrcSize == DstSize) {
llvm::Value *Casted =
CGF.Builder.CreateBitCast(SrcPtr, llvm::PointerType::getUnqual(Ty));
return CGF.Builder.CreateLoad(Casted);
llvm::LoadInst *Load = CGF.Builder.CreateLoad(Casted);
// FIXME: Use better alignment / avoid requiring aligned load.
Load->setAlignment(1);
return Load;
} else {
assert(SrcSize < DstSize && "Coercion is losing source bits!");
@ -968,7 +971,10 @@ static llvm::Value *CreateCoercedLoad(llvm::Value *SrcPtr,
llvm::Value *Tmp = CGF.CreateTempAlloca(Ty);
llvm::Value *Casted =
CGF.Builder.CreateBitCast(Tmp, llvm::PointerType::getUnqual(SrcTy));
CGF.Builder.CreateStore(CGF.Builder.CreateLoad(SrcPtr), Casted);
llvm::StoreInst *Store =
CGF.Builder.CreateStore(CGF.Builder.CreateLoad(SrcPtr), Casted);
// FIXME: Use better alignment / avoid requiring aligned store.
Store->setAlignment(1);
return CGF.Builder.CreateLoad(Tmp);
}
}
@ -992,7 +998,8 @@ static void CreateCoercedStore(llvm::Value *Src,
if (SrcSize == DstSize) {
llvm::Value *Casted =
CGF.Builder.CreateBitCast(DstPtr, llvm::PointerType::getUnqual(SrcTy));
CGF.Builder.CreateStore(Src, Casted);
// FIXME: Use better alignment / avoid requiring aligned store.
CGF.Builder.CreateStore(Src, Casted)->setAlignment(1);
} else {
assert(SrcSize > DstSize && "Coercion is missing bits!");
@ -1002,7 +1009,10 @@ static void CreateCoercedStore(llvm::Value *Src,
CGF.Builder.CreateStore(Src, Tmp);
llvm::Value *Casted =
CGF.Builder.CreateBitCast(Tmp, llvm::PointerType::getUnqual(DstTy));
CGF.Builder.CreateStore(CGF.Builder.CreateLoad(Casted), DstPtr);
llvm::LoadInst *Load = CGF.Builder.CreateLoad(Casted);
// FIXME: Use better alignment / avoid requiring aligned load.
Load->setAlignment(1);
CGF.Builder.CreateStore(Load, DstPtr);
}
}