diff options
author | David Majnemer <david.majnemer@gmail.com> | 2016-06-25 07:37:27 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2016-06-25 07:37:27 +0000 |
commit | 1fea77c6fc6ab0d5557078656be6c54eba769b42 (patch) | |
tree | 018f2212532c40b25e7f9547fc881c10faf96285 /llvm/lib/Transforms/Utils/SimplifyCFG.cpp | |
parent | 50e3dfe9d0a79d799e246884768f49c3d96746be (diff) | |
download | llvm-1fea77c6fc6ab0d5557078656be6c54eba769b42.zip llvm-1fea77c6fc6ab0d5557078656be6c54eba769b42.tar.gz llvm-1fea77c6fc6ab0d5557078656be6c54eba769b42.tar.bz2 |
[SimplifyCFG] Replace calls to null/undef with unreachable
Calling null is undefined behavior, a call to undef can be trivially
treated as a call to null.
llvm-svn: 273776
Diffstat (limited to 'llvm/lib/Transforms/Utils/SimplifyCFG.cpp')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index d22f5c6..7924c33 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp @@ -5388,7 +5388,7 @@ static bool passingValueIsAlwaysUndefined(Value *V, Instruction *I) { if (I->use_empty()) return false; - if (C->isNullValue()) { + if (C->isNullValue() || isa<UndefValue>(C)) { // Only look at the first use, avoid hurting compile time with long uselists User *Use = *I->user_begin(); @@ -5417,6 +5417,10 @@ static bool passingValueIsAlwaysUndefined(Value *V, Instruction *I) { if (!SI->isVolatile()) return SI->getPointerAddressSpace() == 0 && SI->getPointerOperand() == I; + + // A call to null is undefined. + if (auto CS = CallSite(Use)) + return CS.getCalledValue() == I; } return false; } |