fix a problem reported by Eli, caused by not keeping bool as i1

when in a register.

llvm-svn: 46552
This commit is contained in:
Chris Lattner 2008-01-30 07:01:17 +00:00
parent e850fa2452
commit 05ba4cbe17
2 changed files with 14 additions and 2 deletions

View File

@ -115,8 +115,17 @@ RValue CodeGenFunction::EmitLoadOfLValue(LValue LV, QualType ExprType) {
cast<llvm::PointerType>(Ptr->getType())->getElementType();
// Simple scalar l-value.
if (EltTy->isFirstClassType())
return RValue::get(Builder.CreateLoad(Ptr, "tmp"));
if (EltTy->isFirstClassType()) {
llvm::Value *V = Builder.CreateLoad(Ptr, "tmp");
// Bool can have different representation in memory than in registers.
if (ExprType->isBooleanType()) {
if (V->getType() != llvm::Type::Int1Ty)
V = Builder.CreateTrunc(V, llvm::Type::Int1Ty, "tobool");
}
return RValue::get(V);
}
assert(ExprType->isFunctionType() && "Unknown scalar value");
return RValue::get(Ptr);

View File

@ -14,3 +14,6 @@ void *test(int *i) {
a + i;
}
_Bool test2b;
int test2() {if (test2b);}