Many tests fail on Win64

Hi,

I check-out the latest version of LLVM and see many failures (on Win64):

In a debug build you should get a stack trace by default, which would
be helpful here.

I can try to repro later today, but I'm not surprised there are issues
because most people I know stick with 32-bit builds even on 64-bit
Windows.

I fell over this issue yesterday myself with lots of asserts being thrown.

I think the issue is in lib/IR/AsmWriter.cpp:1618 in the function
AssemblyWriter::printFunction(const Function *F)

Looking at the code I think the 2nd for loop should be preceded by the test
...

   if (Idx < AS.getNumSlots())

Not sure why it doesn't fail on other platforms as it looks like it should
be a genuine issue on all platform.

That change significantly reduced the failures on my Windows build.

Keith

See bills commit and chris’s revert. Please fix.

W:\LLVM_org\build64\bin\Debug>opt.EXE < W:\LLVM_org\llvm\test\Transforms\IPConstantProp\dangling-block-address.ll -internalize -ipsccp -S
Assertion failed: begin() + idx < end(), file W:\LLVM_org\llvm\include\llvm/ADT/SmallVector.h, line 140
Stack dump:
0. Program arguments: opt.EXE -internalize -ipsccp -S
1. Running pass 'Print module to stderr' on module '<stdin>'.
0x0000000050D156EF (0x000000000000000A 0x0000000000000000 0x0000000000A3DCC8 0x00000001406C6FAC), _get_pgmptr() + 0x2AF bytes(s)
0x0000000050E365F4 (0x0000000000A3DCF0 0x000000000000021C 0x0000000050EBCB70 0x0000000140BD3500), abort() + 0x24 bytes(s)
0x0000000050E2283E (0x0000000140BD3500 0x0000000140BD3540 0xCCCCCCCC0000008C 0xCCCCCCCCCCCCCCCC), _wassert() + 0x10E bytes(s)
0x00000001405745FA (0x0000000000B43510 0xCCCCCCCC00000001 0xCCCCCCCCCCCCCCCC 0xCCCCCCCCCCCCCCCC), llvm::SmallVectorTemplateCommon<std::pair<
unsigned int,llvm::AttributeSetNode * __ptr64>,void>::operator() + 0x6A bytes(s), w:\llvm_org\llvm\include\llvm\adt\smallvector.h, line 14
0 + 0x48 byte(s)
0x0000000140573677 (0x0000000000B43500 0xCCCCCCCC00000001 0xCCCCCCCCCCCCCCCC 0xCCCCCCCCCCCCCCCC), llvm::AttributeSetImpl::begin() + 0x37 byt
es(s), w:\llvm_org\llvm\lib\ir\attributeimpl.h, line 252 + 0x37 byte(s)
0x0000000140571382 (0x0000000000A3E918 0x0000000000000001 0xCCCCCCCCCCCCCCCC 0xCCCCCCCCCCCCCCCC), llvm::AttributeSet::begin() + 0x52 bytes(s
), w:\llvm_org\llvm\lib\ir\attributes.cpp, line 870
0x00000001404B9C7E (0x0000000000A3F020 0x0000000000B435B0 0x0000000000000000 0xCCCCCCCCCCCCCCCC), `anonymous namespace'::AssemblyWriter::pri
ntFunction() + 0x17E bytes(s), w:\llvm_org\llvm\lib\ir\asmwriter.cpp, line 1618 + 0x13 byte(s)
0x00000001404B8AC2 (0x0000000000A3F020 0x0000000000B1B470 0x0000000000A3EF00 0x0000000000B1B470), `anonymous namespace'::AssemblyWriter::pri
ntModule() + 0x682 bytes(s), w:\llvm_org\llvm\lib\ir\asmwriter.cpp, line 1378 + 0x1D byte(s)
0x00000001404BD1DC (0x0000000000B1B470 0x0000000000B19238 0x0000000000000000 0xCCCCCCCCCCCCCCCC), llvm::Module::print() + 0x9C bytes(s), w:\
llvm_org\llvm\lib\ir\asmwriter.cpp, line 2172
0x000000013F819EE5 (0x0000000000B19238 0x0000000000B1B470 0xCCCCCCCCCCCCCCCC 0xCCCCCCCCCCCCCCCC), llvm::operator<<() + 0x35 bytes(s), w:\llv
m_org\llvm\include\llvm\ir\module.h, line 584
0x00000001404E581A (0x0000000000B22220 0x0000000000B1B470 0x0000000000B1B470 0xCCCCCCCC00000005), `anonymous namespace'::PrintModulePass::ru
nOnModule() + 0x4A bytes(s), w:\llvm_org\llvm\lib\ir\printmodulepass.cpp, line 41
0x00000001404983E1 (0x0000000000B21E80 0x0000000000B1B470 0xCCCCCCCCCCCCCCCC 0xCCCCCCCCCCCCCCCC), llvm::MPPassManager::runOnModule() + 0x311
bytes(s), w:\llvm_org\llvm\lib\ir\passmanager.cpp, line 1608 + 0x40 byte(s)
0x0000000140498C04 (0x0000000000B21B40 0x0000000000B1B470 0xCCCCCCCCCCCCCCCC 0xCCCCCCCCCCCCCCCC), llvm::PassManagerImpl::run() + 0x174 bytes
(s), w:\llvm_org\llvm\lib\ir\passmanager.cpp, line 1703 + 0x2A byte(s)
0x0000000140498EB6 (0x0000000000A3F808 0x0000000000B1B470 0x0000000000A3FB60 0xCCCCCCCC00000004), llvm::PassManager::run() + 0x36 bytes(s),
w:\llvm_org\llvm\lib\ir\passmanager.cpp, line 1739
0x000000013F62273B (0x0000000100000004 0x0000000000B17EE0 0x0000000000000000 0x000000014075FD6E), main() + 0x1B2B bytes(s), w:\llvm_org\llvm
\tools\opt\opt.cpp, line 827
0x000000014075EDBC (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000), __tmainCRTStartup() + 0x19C bytes(s), f:\d
d\vctools\crt_bld\self_64_amd64\crt\src\crtexe.c, line 555 + 0x19 byte(s)
0x000000014075EC0E (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000), mainCRTStartup() + 0xE bytes(s), f:\dd\vct
ools\crt_bld\self_64_amd64\crt\src\crtexe.c, line 371
0x000000007753652D (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000), BaseThreadInitThunk() + 0xD bytes(s)
0x000000007766C521 (0x0000000000000000 0x0000000000000000 0x0000000000000000 0x0000000000000000), RtlUserThreadStart() + 0x21 bytes(s)