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

llvm-gcc4: crash compiling constant expr cast #1226

Closed
nlewycky opened this issue Jul 29, 2006 · 3 comments
Closed

llvm-gcc4: crash compiling constant expr cast #1226

nlewycky opened this issue Jul 29, 2006 · 3 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

@nlewycky
Copy link
Contributor

Bugzilla Link 854
Resolution FIXED
Resolved on Feb 22, 2010 12:43
Version 1.4
OS All
Attachments delta minimized testcase 18257.c

Extended Description

I met an assertion failure in llvm-gcc while compiling the linux kernel.
Testcase attached in a second...

@nlewycky
Copy link
Contributor Author

assigned to @lattner

@nlewycky
Copy link
Contributor Author

I've reduced the testcase by hand:

struct kernel_symbol {
unsigned long value;
};
unsigned long loops_per_jiffy = (1<<12);
static const char __kstrtab_loops_per_jiffy[]
attribute((section("__ksymtab_strings"))) = "loops_per_jiffy";
static const struct kernel_symbol __ksymtab_loops_per_jiffy
attribute((used)) attribute((section("__ksymtab"))) = { (unsigned
long)&loops_per_jiffy, __kstrtab_loops_per_jiffy };

This compiles with GCC 4.0 using "gcc bug.c -S -o bug.s", and the same command
causes llvm-gcc to ICE with the assertion.

@lattner
Copy link
Collaborator

lattner commented Jul 31, 2006

Fixed. Testcase here: Regression/CFrontend/2006-07-31-#854 .c

Patch here:

Index: llvm-convert.cpp

====
--- llvm-convert.cpp (revision 116626)
+++ llvm-convert.cpp (working copy)
@@ -3852,6 +3852,7 @@ Constant *TreeConstantToLLVM::Convert(tr
case STRING_CST: return ConvertSTRING_CST(exp);
case COMPLEX_CST: return ConvertCOMPLEX_CST(exp);
case NOP_EXPR: return ConvertNOP_EXPR(exp);

  • case CONVERT_EXPR: return ConvertCONVERT_EXPR(exp);
    case PLUS_EXPR:
    case MINUS_EXPR: return ConvertBinOp_CST(exp);
    case CONSTRUCTOR: return ConvertCONSTRUCTOR(exp);
    @@ -3986,6 +3987,11 @@ Constant *TreeConstantToLLVM::ConvertNOP
    return ConstantExpr::getCast(Elt, ConvertType(TREE_TYPE(exp)));
    }

+Constant *TreeConstantToLLVM::ConvertCONVERT_EXPR(tree exp) {

  • Constant *Elt = Convert(TREE_OPERAND(exp, 0));
  • return ConstantExpr::getCast(Elt, ConvertType(TREE_TYPE(exp)));
    +}

Constant *TreeConstantToLLVM::ConvertBinOp_CST(tree exp) {
Constant *LHS = Convert(TREE_OPERAND(exp, 0));
Constant *RHS = Convert(TREE_OPERAND(exp, 1));
Index: llvm-internal.h

====
--- llvm-internal.h (revision 116625)
+++ llvm-internal.h (working copy)
@@ -470,6 +470,7 @@ public:
static Constant *ConvertSTRING_CST(tree_node *exp);
static Constant *ConvertCOMPLEX_CST(tree_node *exp);
static Constant *ConvertNOP_EXPR(tree_node *exp);

  • static Constant *ConvertCONVERT_EXPR(tree_node *exp);
    static Constant *ConvertBinOp_CST(tree_node *exp);
    static Constant *ConvertCONSTRUCTOR(tree_node *exp);
    static Constant *ConvertArrayCONSTRUCTOR(tree_node *exp);

@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

2 participants