mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-28 04:33:05 +00:00
Ignore apparent buffer overruns on external or weak globals. This is a major
source of false positives due to globals being declared in a header with some kind of incomplete (small) type, but the actual definition being bigger. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164912 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
73fab91f2c
commit
b620469223
@ -430,7 +430,10 @@ void Lint::visitMemoryReference(Instruction &I,
|
|||||||
BaseAlign = AI->getAlignment();
|
BaseAlign = AI->getAlignment();
|
||||||
if (BaseAlign == 0 && ATy->isSized())
|
if (BaseAlign == 0 && ATy->isSized())
|
||||||
BaseAlign = TD->getABITypeAlignment(ATy);
|
BaseAlign = TD->getABITypeAlignment(ATy);
|
||||||
} else if (GlobalValue *GV = dyn_cast<GlobalVariable>(Base)) {
|
} else if (GlobalVariable *GV = dyn_cast<GlobalVariable>(Base)) {
|
||||||
|
// If the global may be defined differently in another compilation unit
|
||||||
|
// then don't warn about funky memory accesses.
|
||||||
|
if (GV->hasDefinitiveInitializer()) {
|
||||||
Type *GTy = GV->getType()->getElementType();
|
Type *GTy = GV->getType()->getElementType();
|
||||||
if (GTy->isSized())
|
if (GTy->isSized())
|
||||||
BaseSize = TD->getTypeAllocSize(GTy);
|
BaseSize = TD->getTypeAllocSize(GTy);
|
||||||
@ -438,6 +441,7 @@ void Lint::visitMemoryReference(Instruction &I,
|
|||||||
if (BaseAlign == 0 && GTy->isSized())
|
if (BaseAlign == 0 && GTy->isSized())
|
||||||
BaseAlign = TD->getABITypeAlignment(GTy);
|
BaseAlign = TD->getABITypeAlignment(GTy);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Accesses from before the start or after the end of the object are not
|
// Accesses from before the start or after the end of the object are not
|
||||||
// defined.
|
// defined.
|
||||||
|
@ -9,6 +9,7 @@ declare void @has_noaliases(i32* noalias %p, i32* %q)
|
|||||||
declare void @one_arg(i32)
|
declare void @one_arg(i32)
|
||||||
|
|
||||||
@CG = constant i32 7
|
@CG = constant i32 7
|
||||||
|
@E = external global i8
|
||||||
|
|
||||||
define i32 @foo() noreturn {
|
define i32 @foo() noreturn {
|
||||||
%buf = alloca i8
|
%buf = alloca i8
|
||||||
@ -100,6 +101,10 @@ next:
|
|||||||
ret i32 0
|
ret i32 0
|
||||||
|
|
||||||
foo:
|
foo:
|
||||||
|
; CHECK-NOT: Undefined behavior: Buffer overflow
|
||||||
|
; CHECK-NOT: Memory reference address is misaligned
|
||||||
|
%e = bitcast i8* @E to i64*
|
||||||
|
store i64 0, i64* %e
|
||||||
%z = add i32 0, 0
|
%z = add i32 0, 0
|
||||||
; CHECK: unreachable immediately preceded by instruction without side effects
|
; CHECK: unreachable immediately preceded by instruction without side effects
|
||||||
unreachable
|
unreachable
|
||||||
|
Loading…
Reference in New Issue
Block a user