This is an archive of the discontinued LLVM Phabricator instance.

PR17623 -- GlobalsModRef alias error fix
AbandonedPublic

Authored by david2050 on Feb 5 2015, 4:02 PM.

Details

Reviewers
nicholas
Summary

PR17623 exposes a bug through LTO in GlobalsModRef where the notion of a global that indirectly owns memory is only true if it is not initialized to point to some other named memory. The revision filters candidate globals by this new condition.

Diff Detail

Event Timeline

david2050 updated this revision to Diff 19438.Feb 5 2015, 4:02 PM
david2050 retitled this revision from to PR17623 -- GlobalsModRef alias error fix.
david2050 updated this object.
david2050 edited the test plan for this revision. (Show Details)
david2050 added a reviewer: chandlerc.
david2050 set the repository for this revision to rL LLVM.
david2050 added subscribers: freik, Unknown Object (MLST).

David Callahan wrote:

Hi chandlerc,

PR17623 exposes a bug through LTO in GlobalsModRef where the notion of a global that indirectly owns memory is only true if it is not initialized to point to some other named memory. The revision filters candidate globals by this new condition.

+/// hasNullInitilaizer -- for a global variable which is non-address-taken,

(Unless it is the prevailing form in this file,) please don't repeat the
function name in the comment. Also, it has a typo.

+ // If initilazed to the null pointer, ignore it.

Typo again.

At a high level, I have some problems with globals-mod-ref-aa. It's
relying on LLVM IR types, which is a bad idea (consider a global union {
intptr_t i; char *p; }). The AnalyzeGlobals function appears to be
computing whether things have their address taken, and doesn't read nor
write unnamed_addr.

I don't understand why you didn't add the "is null" to
AnalyzeIndirectGlobalMemory. It seems to go with "non-aliased heap
memory" because heap allocators can return null. If all stores to it
store the result of malloc or a nullptr, it should be fine for it to
detect a store internally. It looks like it tries to handle a global
that always points to the result of malloc, but different malloc's in
different places.

Also, do we ever have it initialized to undef? Or do we canonicalize
those hasInitializer() == false?

Nick

REPOSITORY

rL LLVM

http://reviews.llvm.org/D7451

Files:

lib/Analysis/IPA/GlobalsModRef.cpp
test/Analysis/GlobalsModRef/pr17623.ll

EMAIL PREFERENCES

http://reviews.llvm.org/settings/panel/emailpreferences/

llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

david2050 updated this revision to Diff 20329.Feb 19 2015, 12:18 PM
david2050 removed rL LLVM as the repository for this revision.

Updated based on previous comments.

Thanks Nick, I applied your suggested comments.

I will leave it to others to defend the analysis but at least we can fix the obvious bugs.
david

chandlerc resigned from this revision.Mar 29 2015, 7:59 PM
chandlerc edited reviewers, added: nicholas; removed: chandlerc.

Leaving this review to Nick.

david2050 abandoned this revision.Aug 3 2016, 1:47 PM