[LLVMbugs] [Bug 14299] New: Incorrect codegen for static local with address of local label in constructor
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Thu Nov 8 22:52:17 PST 2012
http://llvm.org/bugs/show_bug.cgi?id=14299
Bug #: 14299
Summary: Incorrect codegen for static local with address of
local label in constructor
Product: clang
Version: trunk
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: LLVM Codegen
AssignedTo: unassignedclangbugs at nondot.org
ReportedBy: a.bataev at gmx.com
CC: llvmbugs at cs.uiuc.edu
Classification: Unclassified
clang generates incorrect code for the following code:
struct VirtualBase {
VirtualBase() {}
};
struct Mike : virtual VirtualBase {
Mike();
};
Mike::Mike() {
static void *ouch =&&x;
goto *ouch;
x:;
}
struct Dave : virtual Mike {
Dave() {}
};
int main()
{
Mike *m = new Mike();
VirtualBase *v = new Dave;
Mike *m2 = new Mike();
return 0;
}
clang++ -S -emit-llvm -o - test.cpp
Some excerpts from the generated code:
...
@_ZZN4MikeC1EvE4ouch = internal global i8* blockaddress(@_ZN4MikeC2Ev, %x),
align 8
...
define void @_ZN4MikeC1Ev(%struct.Mike* %this) unnamed_addr uwtable ssp align 2
{
...
%2 = load i8** @_ZZN4MikeC1EvE4ouch, align 8
br label %indirectgoto
x: ; preds = %indirectgoto
ret void
indirectgoto: ; preds = %entry
%indirect.goto.dest = phi i8* [ %2, %entry ]
indirectbr i8* %indirect.goto.dest, [label %x]
}
...
define void @_ZN4MikeC2Ev(%struct.Mike* %this, i8** %vtt) unnamed_addr nounwind
uwtable ssp align 2 {
...
%2 = load i8** @_ZZN4MikeC1EvE4ouch, align 8
br label %indirectgoto
x: ; preds = %indirectgoto
ret void
indirectgoto: ; preds = %entry
%indirect.goto.dest = phi i8* [ %2, %entry ]
indirectbr i8* %indirect.goto.dest, [label %x]
}
There is a branch to the code in @_ZN4MikeC2Ev from @_ZN4MikeC1Ev happens.
Building an executable and running the test
clang++ test.cpp
./a.out
Bus error: 10
Alexey Bataev
Software Engineer
Intel Compiler Team
Intel Corp.
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list