Skip to content

Commit ac5c6b7

Browse files
committed
Add to support NULL reference parameter
1 parent e16c2e4 commit ac5c6b7

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

lib/Target/CBackend/CBackend.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2886,6 +2886,8 @@ void CWriter::printFunction(Function &F) {
28862886
// print local variable information for the function
28872887
for (inst_iterator I = inst_begin(&F), E = inst_end(&F); I != E; ++I) {
28882888
if (AllocaInst *AI = isDirectAlloca(&*I)) {
2889+
if( AI->getAllocatedType()->isEmptyTy() ) continue; // Ignore empty type local variable
2890+
28892891
unsigned Alignment = AI->getAlignment();
28902892
bool IsOveraligned = Alignment &&
28912893
Alignment > TD->getABITypeAlignment(AI->getAllocatedType());
@@ -4263,6 +4265,12 @@ void CWriter::visitAllocaInst(AllocaInst &I) {
42634265

42644266
void CWriter::printGEPExpression(Value *Ptr, gep_type_iterator I,
42654267
gep_type_iterator E) {
4268+
Type* OperandType = Ptr->getType();
4269+
if( OperandType->isPointerTy() && isEmptyType(OperandType->getPointerElementType()) ) {
4270+
// If the operand type is a pointer to an empty type, just output NULL pointer.
4271+
Out << "0";
4272+
return;
4273+
}
42664274

42674275
// If there are no indices, just print out the pointer.
42684276
if (I == E) {

0 commit comments

Comments
 (0)