Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

K&R C compilation failure #1455

Closed
llvmbot opened this issue Jan 6, 2007 · 9 comments
Closed

K&R C compilation failure #1455

llvmbot opened this issue Jan 6, 2007 · 9 comments
Assignees
Labels
bugzilla Issues migrated from bugzilla compile-fail Use [accepts-invalid] and [rejects-valid] instead llvm-tools All llvm tools that do not have corresponding tag

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Jan 6, 2007

Bugzilla Link 1083
Resolution FIXED
Resolved on Nov 07, 2018 00:17
Version 1.9
OS Linux
Reporter LLVM Bugzilla Contributor
CC @asl

Extended Description

$:~/tmp$ llvm-gcc -emit-llvm -c svc.c -o svc.o
cc1: ../../dst-directory/gcc/llvm-convert.cpp:216:
void::FunctionPrologArgumentConversion::HandleScalarArgument(const
llvm::Type*): Assertion `ArgVal->getType()->isIntegral() && LLVMTy->isIntegral()
&& "Lowerings don't match?"' failed.
svc.c: In function ‘svc_register’:
svc.c:11: internal compiler error: Aborted
Please submit a full bug report,

Source: [svc.c from dietlib v0.30]

#include <rpc/rpc.h>

static SVCXPRT **xports;

bool_t svc_register(xprt, prog, vers, dispatch, protocol)
SVCXPRT *xprt;
unsigned long prog;
unsigned long vers;
void (*dispatch) ();
rpcprot_t protocol;
{
return (TRUE);
}

Can be reproduced with:
llvm-gcc [-emit-llvm] -c svc.c -o svc.o

Domagoj

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jan 6, 2007

assigned to @lattner

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jan 6, 2007

aKor has just pointed me to
http://lists.cs.uiuc.edu/pipermail/llvm-commits/attachments/20070104/5c2b9cf1/attachment.txt
suggesting that that patch is the most likely source of the problem.
However, I don't have that patch applied. So, with, or without the patch,
the code seems to be buggy.

To clear any possible confusion, here's my current code:

void HandleScalarArgument(const llvm::Type *LLVMTy) {
  Value *ArgVal = AI;
  if (ArgVal->getType() != LLVMTy) {
    // If this is just a mismatch between integer types, this could be due
    // to K&R prototypes, where the forward proto defines the arg as int and
    // the actual impls is a short or char.
    assert(ArgVal->getType()->isIntegral() && LLVMTy->isIntegral() &&
           "Lowerings don't match?");
    ArgVal =
      CastInst::createInferredCast(ArgVal, LLVMTy, NameStack.back(), CurBB);
  }
  assert(!LocStack.empty());
  Value *Loc = LocStack.back();
  if (cast<PointerType>(Loc->getType())->getElementType() != LLVMTy)
    // This cast only involves pointers, therefore BitCast
    Loc = CastInst::create(Instruction::BitCast, Loc,
                           PointerType::get(LLVMTy), "tmp", CurBB);

  new StoreInst(ArgVal, Loc, CurBB);
  AI->setName(NameStack.back());
  ++AI;
}

$:~/llvm/dst-directory/gcc$ svn info llvm-convert.cpp
Path: llvm-convert.cpp
Name: llvm-convert.cpp
URL: svn://anonsvn.opensource.apple.com/svn/llvm/trunk/gcc/llvm-convert.cpp
Repository Root: svn://anonsvn.opensource.apple.com/svn/llvm
Repository UUID: 51af6f4a-8115-0410-a7cd-c0d7a57f2c62
Revision: 224
Node Kind: file
Schedule: normal
Last Changed Author: jlaskey
Last Changed Rev: 219
Last Changed Date: 2006-12-01 01:54:57 -0800 (Fri, 01 Dec 2006)
Text Last Updated: 2006-12-09 13:16:41 -0800 (Sat, 09 Dec 2006)

      Domagoj

@asl
Copy link
Collaborator

asl commented Jan 6, 2007

Supplied source code includes some platform-dependent code (because it isn't
preprocessed).

However, it fails here too (on Linux/X86) but with another assertion:

cc1: /home/asl/proj/llvm/src/lib/VMCore/Instructions.cpp:1568: static
llvm::CastInst* llvm::CastInst::createIntegerCast(llvm::Value*, const
llvm::Type*, bool, const std::string&, llvm::BasicBlock*): Assertion
`C->getType()->isIntegral() && Ty->isIntegral() && "Invalid cast"' failed.

Will supply preprocessed & reduced source soon

@asl
Copy link
Collaborator

asl commented Jan 6, 2007

delta-reduced testcase
This file fails for me with TOT with assertion message printed before.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jan 6, 2007

just to confirm that Anton's reduced testcase produces the same msg.

Domagoj

@lattner
Copy link
Collaborator

lattner commented Jan 7, 2007

Verified, the reduced testcase crashes with TOT, investigating.

@lattner
Copy link
Collaborator

lattner commented Jan 7, 2007

Further reduced testcase:

int svc_register (void (*dispatch) (int));

int svc_register (dispatch)
void (*dispatch) ();
{}

@lattner
Copy link
Collaborator

lattner commented Jan 7, 2007

Fixed. Testcase here: test/Regression/CFrontend/2007-01-06-KNR-Proto.c

Patch sent to llvm-commits, but the mailing lists are apparently blocked, so no URL provided.

-Chris

@lattner
Copy link
Collaborator

lattner commented Jan 7, 2007

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla compile-fail Use [accepts-invalid] and [rejects-valid] instead llvm-tools All llvm tools that do not have corresponding tag
Projects
None yet
Development

No branches or pull requests

3 participants