[llvm] r289215 - [SCEVExpander] Use llvm data structures; NFC

Sanjoy Das via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 12 14:37:07 PST 2016


Interesting -- this looks like a hole in AssertingVH itself (that is,
it can't be used as keys in a DenseMap without introducing UB)?

On Mon, Dec 12, 2016 at 2:26 PM, Mike Aizatsky <aizatsky at google.com> wrote:
> Sanjoy,
>
> I think this breaks ubsan build:
>
> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/1281/steps/check-llvm%20ubsan/logs/stdio
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/IR/ValueHandle.h:212:39:
> runtime error: downcast of misaligned address 0xfffffffffffffffc for type
> 'llvm::PHINode', which requires 8 byte alignment
> 0xfffffffffffffffc: note: pointer points here
> <memory cannot be printed>
>     #0 0x25cf100 in llvm::AssertingVH<llvm::PHINode>::getValPtr() const
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/IR/ValueHandle.h:212:39
>     #1 0x25cea20 in
> llvm::AssertingVH<llvm::PHINode>::operator=(llvm::AssertingVH<llvm::PHINode>
> const&)
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/IR/ValueHandle.h:234:19
>     #2 0x25d0092 in
> llvm::DenseMapBase<llvm::DenseMap<llvm::AssertingVH<llvm::PHINode>,
> llvm::detail::DenseSetEmpty,
> llvm::DenseMapInfo<llvm::AssertingVH<llvm::PHINode> >,
> llvm::detail::DenseSetPair<llvm::AssertingVH<llvm::PHINode> > >,
> llvm::AssertingVH<llvm::PHINode>, llvm::detail::DenseSetEmpty,
> llvm::DenseMapInfo<llvm::AssertingVH<llvm::PHINode> >,
> llvm::detail::DenseSetPair<llvm::AssertingVH<llvm::PHINode> > >::clear()
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/include/llvm/ADT/DenseMap.h:113:23
>     #3 0x2595c19 in (anonymous
> namespace)::LSRInstance::ImplementSolution(llvm::SmallVectorImpl<(anonymous
> namespace)::Formula const*> const&)
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:4807:12
>     #4 0x258eeb1 in (anonymous
> namespace)::LSRInstance::LSRInstance(llvm::Loop*, llvm::IVUsers&,
> llvm::ScalarEvolution&, llvm::DominatorTree&, llvm::LoopInfo&,
> llvm::TargetTransformInfo const&)
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:4918:3
>     #5 0x258dce7 in ReduceLoopStrength(llvm::Loop*, llvm::IVUsers&,
> llvm::ScalarEvolution&, llvm::DominatorTree&, llvm::LoopInfo&,
> llvm::TargetTransformInfo const&)
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp:5021:14
>     #6 0x2bd4647 in llvm::LPPassManager::runOnFunction(llvm::Function&)
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/Analysis/LoopPass.cpp:201:23
>     #7 0x236965e in llvm::FPPassManager::runOnFunction(llvm::Function&)
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/IR/LegacyPassManager.cpp:1513:27
>     #8 0x2369a3b in llvm::FPPassManager::runOnModule(llvm::Module&)
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/IR/LegacyPassManager.cpp:1534:16
>     #9 0x236a4b3 in (anonymous
> namespace)::MPPassManager::runOnModule(llvm::Module&)
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/IR/LegacyPassManager.cpp:1590:27
>     #10 0x2369e73 in llvm::legacy::PassManagerImpl::run(llvm::Module&)
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/lib/IR/LegacyPassManager.cpp:1693:44
>     #11 0x8d9163 in compileModule(char**, llvm::LLVMContext&)
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/llc/llc.cpp:525:8
>     #12 0x8d7f0a in main
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/llc/llc.cpp:283:22
>     #13 0x7efcf3e8ef44 in __libc_start_main
> (/lib/x86_64-linux-gnu/libc.so.6+0x21f44)
>     #14 0x8b175d in _start
> (/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/bin/llc+0x8b175d)
>
> FileCheck error: '-' is empty.
> FileCheck command line:
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm_build_ubsan/./bin/FileCheck
> -check-prefix=GCN -check-prefix=CI
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/test/CodeGen/AMDGPU/drop-mem-operand-move-smrd.ll
>
>
> On Fri, Dec 9, 2016 at 6:52 AM Sanjoy Das via llvm-commits
> <llvm-commits at lists.llvm.org> wrote:
>>
>> Author: sanjoy
>> Date: Fri Dec  9 08:42:11 2016
>> New Revision: 289215
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=289215&view=rev
>> Log:
>> [SCEVExpander] Use llvm data structures; NFC
>>
>> Modified:
>>     llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h
>>
>> Modified: llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h?rev=289215&r1=289214&r2=289215&view=diff
>>
>> ==============================================================================
>> --- llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h (original)
>> +++ llvm/trunk/include/llvm/Analysis/ScalarEvolutionExpander.h Fri Dec  9
>> 08:42:11 2016
>> @@ -14,13 +14,14 @@
>>  #ifndef LLVM_ANALYSIS_SCALAREVOLUTIONEXPANDER_H
>>  #define LLVM_ANALYSIS_SCALAREVOLUTIONEXPANDER_H
>>
>> +#include "llvm/ADT/DenseMap.h"
>> +#include "llvm/ADT/DenseSet.h"
>>  #include "llvm/ADT/Optional.h"
>>  #include "llvm/Analysis/ScalarEvolutionExpressions.h"
>>  #include "llvm/Analysis/ScalarEvolutionNormalization.h"
>>  #include "llvm/Analysis/TargetFolder.h"
>>  #include "llvm/IR/IRBuilder.h"
>>  #include "llvm/IR/ValueHandle.h"
>> -#include <set>
>>
>>  namespace llvm {
>>    class TargetTransformInfo;
>> @@ -43,11 +44,12 @@ namespace llvm {
>>      const char* IVName;
>>
>>      // InsertedExpressions caches Values for reuse, so must track RAUW.
>> -    std::map<std::pair<const SCEV *, Instruction *>, TrackingVH<Value> >
>> -      InsertedExpressions;
>> +    DenseMap<std::pair<const SCEV *, Instruction *>, TrackingVH<Value>>
>> +        InsertedExpressions;
>> +
>>      // InsertedValues only flags inserted instructions so needs no RAUW.
>> -    std::set<AssertingVH<Value> > InsertedValues;
>> -    std::set<AssertingVH<Value> > InsertedPostIncValues;
>> +    DenseSet<AssertingVH<Value>> InsertedValues;
>> +    DenseSet<AssertingVH<Value>> InsertedPostIncValues;
>>
>>      /// A memoization of the "relevant" loop for a given SCEV.
>>      DenseMap<const SCEV *, const Loop *> RelevantLoops;
>> @@ -68,7 +70,7 @@ namespace llvm {
>>      Instruction *IVIncInsertPos;
>>
>>      /// \brief Phis that complete an IV chain. Reuse
>> -    std::set<AssertingVH<PHINode> > ChainedPhis;
>> +    DenseSet<AssertingVH<PHINode>> ChainedPhis;
>>
>>      /// \brief When true, expressions are expanded in "canonical" form.
>> In
>>      /// particular, addrecs are expanded as arithmetic based on a
>> canonical
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
> --
> Mike
> Sent from phone



-- 
Sanjoy Das
http://playingwithpointers.com


More information about the llvm-commits mailing list