forked from OSchip/llvm-project
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:
parent
e850fa2452
commit
05ba4cbe17
|
@ -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);
|
||||
|
|
|
@ -14,3 +14,6 @@ void *test(int *i) {
|
|||
a + i;
|
||||
}
|
||||
|
||||
_Bool test2b;
|
||||
int test2() {if (test2b);}
|
||||
|
||||
|
|
Loading…
Reference in New Issue